Skip to content

Commit

Permalink
Fix KfConfig conversion bugs (kubeflow#4320)
Browse files Browse the repository at this point in the history
* copy kind in v1beta1

* infer platform from plugins

* update

* fix test
  • Loading branch information
gabrielwen authored and k8s-ci-robot committed Oct 17, 2019
1 parent a057745 commit 70d3119
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
spec:
project: foo-project
email: [email protected]
platform: gcp
applications:
- kustomizeConfig:
parameters:
Expand Down
20 changes: 20 additions & 0 deletions bootstrap/pkg/apis/apps/configconverters/v1beta1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 70d3119

Please sign in to comment.