diff --git a/cmd/drone-server/config/config.go b/cmd/drone-server/config/config.go index bec51172..43c84baf 100644 --- a/cmd/drone-server/config/config.go +++ b/cmd/drone-server/config/config.go @@ -320,6 +320,10 @@ type ( SkipVerify bool `envconfig:"DRONE_CONVERT_PLUGIN_SKIP_VERIFY"` CacheSize int `envconfig:"DRONE_CONVERT_PLUGIN_CACHE_SIZE" default:"10"` Timeout time.Duration `envconfig:"DRONE_CONVERT_TIMEOUT" default:"1m"` + + // this flag can be removed once we solve for + // https://github.com/harness/drone/pull/2994#issuecomment-795955312 + Multi bool `envconfig:"DRONE_CONVERT_MULTI" default:"1m"` } // Validate provides the validation webhook configuration. diff --git a/cmd/drone-server/inject_plugin.go b/cmd/drone-server/inject_plugin.go index 34b34964..dfd80a9b 100644 --- a/cmd/drone-server/inject_plugin.go +++ b/cmd/drone-server/inject_plugin.go @@ -78,6 +78,7 @@ func provideConfigPlugin(client *scm.Client, contents core.FileService, conf spe // configuration. func provideConvertPlugin(client *scm.Client, fileService core.FileService, conf spec.Config, templateStore core.TemplateStore) core.ConvertService { return converter.Combine( + conf.Convert.Multi, converter.Legacy(false), converter.Starlark( conf.Starlark.Enabled, diff --git a/plugin/converter/combine.go b/plugin/converter/combine.go index a80151fc..05144807 100644 --- a/plugin/converter/combine.go +++ b/plugin/converter/combine.go @@ -22,12 +22,16 @@ import ( // Combine combines the conversion services, provision support // for multiple conversion utilities. -func Combine(services ...core.ConvertService) core.ConvertService { - return &combined{services} +func Combine(multi bool, services ...core.ConvertService) core.ConvertService { + return &combined{multi: multi, sources: services} } type combined struct { sources []core.ConvertService + + // this feature flag can be removed once we solve for + // https://github.com/harness/drone/pull/2994#issuecomment-795955312 + multi bool } func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Config, error) { @@ -42,7 +46,11 @@ func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Co if config.Data == "" { continue } - return config, nil + if c.multi { + req.Config = config + } else { + return config, nil + } } return req.Config, nil } diff --git a/plugin/converter/combine_test.go b/plugin/converter/combine_test.go index 1e4117e5..28d839ef 100644 --- a/plugin/converter/combine_test.go +++ b/plugin/converter/combine_test.go @@ -39,7 +39,7 @@ func TestCombine(t *testing.T) { service := mock.NewMockConvertService(controller) service.EXPECT().Convert(noContext, args).Return(resp, nil) - result, err := Combine(service).Convert(noContext, args) + result, err := Combine(false, service).Convert(noContext, args) if err != nil { t.Error(err) return @@ -58,7 +58,7 @@ func TestCombineErr(t *testing.T) { service := mock.NewMockConvertService(controller) service.EXPECT().Convert(noContext, nil).Return(nil, resp) - _, err := Combine(service).Convert(noContext, nil) + _, err := Combine(false, service).Convert(noContext, nil) if err != resp { t.Errorf("expected convert service error") } @@ -85,7 +85,7 @@ func TestCombineNoConfig(t *testing.T) { service3 := mock.NewMockConvertService(controller) service3.EXPECT().Convert(noContext, args).Return(resp, nil) - result, err := Combine(service1, service2, service3).Convert(noContext, args) + result, err := Combine(false, service1, service2, service3).Convert(noContext, args) if err != nil { t.Error(err) return @@ -110,7 +110,7 @@ func TestCombineEmptyConfig(t *testing.T) { service1 := mock.NewMockConvertService(controller) service1.EXPECT().Convert(noContext, args).Return(nil, nil) - result, err := Combine(service1).Convert(noContext, args) + result, err := Combine(false, service1).Convert(noContext, args) if err != nil { t.Error(err) return