Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get service account file only for GCP CCS #196

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions cmd/ocm/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func run(cmd *cobra.Command, argv []string) error {
computeNodes = 9
}

if args.gcpServiceAccount != "" {
if args.provider == "gcp" && args.gcpServiceAccount != "" {
err = constructGCPCredentials(args.gcpServiceAccount, &args.ccs)
if err != nil {
return err
Expand Down Expand Up @@ -333,16 +333,19 @@ func fetchFlavours(client *cmv1.Client) (flavours []*cmv1.Flavour, err error) {
}

func constructGCPCredentials(filePath arguments.FilePath, value *cluster.CCS) error {
// Open our jsonFile
jsonFile, err := os.Open(filePath.String())
if err != nil {
return err
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
err = json.Unmarshal(byteValue, &value.GCP)
if err != nil {
return err
if value.Enabled {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func is only called when the flag is set (!= "").
This change makes it easier to ignore this flag when not relevant, right?
I propose instead returning error when it's set but not relevant — see #199. WDYT?

// Open our jsonFile
jsonFile, err := os.Open(filePath.String())
if err != nil {
return err
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
err = json.Unmarshal(byteValue, &value.GCP)
if err != nil {
return err
}
return nil
}
return nil

Expand Down