-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
126 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/qovery/qovery-cli/utils" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
var helmEnvOverrideCmd = &cobra.Command{ | ||
Use: "override", | ||
Short: "Manage helm environment variable and secret overrides", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
utils.Capture(cmd) | ||
|
||
if len(args) == 0 { | ||
_ = cmd.Help() | ||
os.Exit(0) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
helmEnvCmd.AddCommand(helmEnvOverrideCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/pterm/pterm" | ||
"github.com/qovery/qovery-cli/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var helmEnvOverrideCreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Override helm environment variable or secret", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
utils.Capture(cmd) | ||
|
||
tokenType, token, err := utils.GetAccessToken() | ||
if err != nil { | ||
utils.PrintlnError(err) | ||
os.Exit(1) | ||
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
client := utils.GetQoveryClient(tokenType, token) | ||
_, projectId, envId, err := getOrganizationProjectEnvironmentContextResourcesIds(client) | ||
|
||
if err != nil { | ||
utils.PrintlnError(err) | ||
os.Exit(1) | ||
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
helms, _, err := client.HelmsAPI.ListHelms(context.Background(), envId).Execute() | ||
|
||
if err != nil { | ||
utils.PrintlnError(err) | ||
os.Exit(1) | ||
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
helm := utils.FindByHelmName(helms.GetResults(), helmName) | ||
|
||
if helm == nil { | ||
utils.PrintlnError(fmt.Errorf("helm %s not found", helmName)) | ||
utils.PrintlnInfo("You can list all helms with: qovery helm list") | ||
os.Exit(1) | ||
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
err = utils.CreateOverride(client, projectId, envId, helm.Id, utils.HelmType, utils.Key, utils.Value, utils.HelmScope) | ||
|
||
if err != nil { | ||
utils.PrintlnError(err) | ||
os.Exit(1) | ||
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
utils.Println(fmt.Sprintf("%s has been overidden", pterm.FgBlue.Sprintf(utils.Key))) | ||
}, | ||
} | ||
|
||
func init() { | ||
helmEnvOverrideCmd.AddCommand(helmEnvOverrideCreateCmd) | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&organizationName, "organization", "", "", "Organization Name") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&projectName, "project", "", "", "Project Name") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&environmentName, "environment", "", "", "Environment Name") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&helmName, "helm", "n", "", "helm Name") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&utils.Key, "key", "k", "", "Environment variable or secret key") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&utils.Value, "value", "", "", "Environment variable or secret value") | ||
helmEnvOverrideCreateCmd.Flags().StringVarP(&utils.HelmScope, "scope", "", "HELM", "Scope of this alias <PROJECT|ENVIRONMENT|HELM>") | ||
|
||
_ = helmEnvOverrideCreateCmd.MarkFlagRequired("key") | ||
_ = helmEnvOverrideCreateCmd.MarkFlagRequired("helm") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.