-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uninstalls Consul on Kubernetes with options to delete all Consul installation related resources. Also removes a hack using HELM_NAMESPACE environment variable to set the Helm Go SDK Kube Client namespace and replaces it with common.InitActionConfig, which also uses a slight hack. That hack can be removed when helm/helm#10148 is merged.
- Loading branch information
1 parent
e2d07a3
commit 9a974c1
Showing
9 changed files
with
889 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"helm.sh/helm/v3/pkg/action" | ||
helmCLI "helm.sh/helm/v3/pkg/cli" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
) | ||
|
||
const ( | ||
DefaultReleaseName = "consul" | ||
DefaultReleaseNamespace = "consul" | ||
) | ||
|
||
// Abort returns true if the raw input string is not equal to "y" or "yes". | ||
func Abort(raw string) bool { | ||
confirmation := strings.TrimSuffix(raw, "\n") | ||
if !(strings.ToLower(confirmation) == "y" || strings.ToLower(confirmation) == "yes") { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// InitActionConfig initializes a Helm Go SDK action configuration. This function currently uses a hack to override the | ||
// namespace field that gets set in the K8s client set up by the SDK. | ||
func InitActionConfig(actionConfig *action.Configuration, namespace string, settings *helmCLI.EnvSettings, logger action.DebugLog) (*action.Configuration, error) { | ||
getter := settings.RESTClientGetter() | ||
configFlags := getter.(*genericclioptions.ConfigFlags) | ||
configFlags.Namespace = &namespace | ||
err := actionConfig.Init(settings.RESTClientGetter(), namespace, | ||
os.Getenv("HELM_DRIVER"), logger) | ||
if err != nil { | ||
return nil, fmt.Errorf("error setting up helm action configuration to find existing installations: %s", err) | ||
} | ||
return actionConfig, nil | ||
} |
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
Oops, something went wrong.