Skip to content

Commit

Permalink
update manifest migrate commands (istio#591)
Browse files Browse the repository at this point in the history
* update migrate script

* Address comment

* Address comment

* Address comment
  • Loading branch information
richardwxn authored and istio-testing committed Nov 15, 2019
1 parent 378826a commit 45b51b4
Show file tree
Hide file tree
Showing 7 changed files with 731 additions and 703 deletions.
14 changes: 9 additions & 5 deletions cmd/mesh/manifest-migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/gogo/protobuf/jsonpb"
"github.com/spf13/cobra"

"istio.io/operator/pkg/apis/istio/v1alpha2"
"istio.io/operator/pkg/kubectlcmd"
"istio.io/operator/pkg/translate"
"istio.io/operator/pkg/util"
Expand Down Expand Up @@ -65,7 +66,7 @@ func manifestMigrateCmd(rootArgs *rootArgs, mmArgs *manifestMigrateArgs) *cobra.
}

func valueFileFilter(path string) bool {
return filepath.Base(path) == "values.yaml"
return filepath.Base(path) == "values.yaml" || filepath.Base(path) == "global.yaml"
}

// migrateFromFiles handles migration for local values.yaml files
Expand Down Expand Up @@ -93,16 +94,19 @@ func translateFunc(values []byte, l *logger) {
if err != nil {
l.logAndFatal("error translating values.yaml: ", err.Error())
}
isCP := &v1alpha2.IstioControlPlane{Spec: isCPSpec, Kind: "IstioControlPlane", ApiVersion: "install.istio.io/v1alpha2"}

ms := jsonpb.Marshaler{}
gotString, err := ms.MarshalToString(isCPSpec)
gotString, err := ms.MarshalToString(isCP)
if err != nil {
l.logAndFatal("error marshaling translated IstioControlPlaneSpec: ", err.Error())
l.logAndFatal("error marshaling translated IstioControlPlane: ", err.Error())
}
cpYaml, _ := yaml.JSONToYAML([]byte(gotString))

isCPYaml, _ := yaml.JSONToYAML([]byte(gotString))
if err != nil {
l.logAndFatal("error converting JSON: ", gotString, "\n", err.Error())
}
l.print(string(cpYaml) + "\n")
l.print(string(isCPYaml) + "\n")
}

// migrateFromClusterConfig handles migration for in cluster config.
Expand Down
Loading

0 comments on commit 45b51b4

Please sign in to comment.