From 70d3119fc5f075ff9cf715e6bfe0a8ce00e05736 Mon Sep 17 00:00:00 2001 From: Hung-Ting Wen Date: Wed, 16 Oct 2019 19:16:38 -0700 Subject: [PATCH] Fix KfConfig conversion bugs (#4320) * copy kind in v1beta1 * infer platform from plugins * update * fix test --- .../testdata/kfconfig_v1beta1.yaml | 1 + .../pkg/apis/apps/configconverters/v1beta1.go | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bootstrap/pkg/apis/apps/configconverters/testdata/kfconfig_v1beta1.yaml b/bootstrap/pkg/apis/apps/configconverters/testdata/kfconfig_v1beta1.yaml index adf0790117e..d77930418e4 100644 --- a/bootstrap/pkg/apis/apps/configconverters/testdata/kfconfig_v1beta1.yaml +++ b/bootstrap/pkg/apis/apps/configconverters/testdata/kfconfig_v1beta1.yaml @@ -7,6 +7,7 @@ metadata: spec: project: foo-project email: foo@gmail.com + platform: gcp applications: - kustomizeConfig: parameters: diff --git a/bootstrap/pkg/apis/apps/configconverters/v1beta1.go b/bootstrap/pkg/apis/apps/configconverters/v1beta1.go index d23d99a6861..be7a1841780 100644 --- a/bootstrap/pkg/apis/apps/configconverters/v1beta1.go +++ b/bootstrap/pkg/apis/apps/configconverters/v1beta1.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/ghodss/yaml" kfapis "github.com/kubeflow/kubeflow/bootstrap/v3/pkg/apis" + kftypesv3 "github.com/kubeflow/kubeflow/bootstrap/v3/pkg/apis/apps" kfconfig "github.com/kubeflow/kubeflow/bootstrap/v3/pkg/apis/apps/kfconfig" kfdeftypes "github.com/kubeflow/kubeflow/bootstrap/v3/pkg/apis/apps/kfdef/v1beta1" ) @@ -12,6 +13,21 @@ import ( type V1beta1 struct { } +func maybeGetPlatform(pluginKind string) string { + platforms := map[string]string{ + string(kfconfig.AWS_PLUGIN_KIND): kftypesv3.AWS, + string(kfconfig.GCP_PLUGIN_KIND): kftypesv3.GCP, + string(kfconfig.EXISTING_ARRIKTO_PLUGIN_KIND): kftypesv3.EXISTING_ARRIKTO, + } + + p, ok := platforms[pluginKind] + if ok { + return p + } else { + return "" + } +} + func (v V1beta1) ToKfConfig(appdir string, kfdefBytes []byte) (*kfconfig.KfConfig, error) { kfdef := &kfdeftypes.KfDef{} if err := yaml.Unmarshal(kfdefBytes, kfdef); err != nil { @@ -109,6 +125,9 @@ func (v V1beta1) ToKfConfig(appdir string, kfdefBytes []byte) (*kfconfig.KfConfi config.Spec.Zone = z.(string) } } + if p := maybeGetPlatform(plugin.Kind); p != "" { + config.Spec.Platform = p + } } for _, secret := range kfdef.Spec.Secrets { @@ -204,6 +223,7 @@ func (v V1beta1) ToKfDefSerialized(config kfconfig.KfConfig) ([]byte, error) { Spec: plugin.Spec, } p.Name = plugin.Name + p.Kind = string(plugin.Kind) kfdef.Spec.Plugins = append(kfdef.Spec.Plugins, p) }