Skip to content

CR-18810-fix-create-gs #695

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

Merged
merged 6 commits into from
May 23, 2023
Merged

CR-18810-fix-create-gs #695

merged 6 commits into from
May 23, 2023

Conversation

noam-codefresh
Copy link
Contributor

@noam-codefresh noam-codefresh commented May 23, 2023

What

  • fixed cf git-source create command to not crash (and handle runtime namespace correctly)
  • fixed cf runtime uninstall to get runtime namespace from platform

Why

the cf git-source create command was crashing, the cf runtime uninstall was working (even when runtimeName !== runtimeNamespace), but in a less safe way


"github.com/Masterminds/semver/v3"
"github.com/argoproj-labs/argocd-autopilot/pkg/kube"
apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reorder and add alias

@@ -38,8 +38,7 @@ import (
"github.com/codefresh-io/cli-v2/pkg/util/kube"
routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing"

"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reorder and add alias

Comment on lines -747 to -763
func isRuntimeManaged(ctx context.Context, runtimeName string) (bool, error) {
rt, err := getRuntime(ctx, runtimeName)
if err != nil {
return false, err
}

return rt.Managed, nil
}

func getRuntimeInstallationType(ctx context.Context, runtimeName string) (*platmodel.InstallationType, error) {
rt, err := getRuntime(ctx, runtimeName)
if err != nil {
return nil, err
}

return &rt.InstallationType, nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need for those two funcs, were used in install prerun func before

Comment on lines +33 to +35
apapp "github.com/argoproj-labs/argocd-autopilot/pkg/application"
apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs"
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reorder and add alias

Comment on lines +191 to +199
runtimeName := args[0]
runtime, err := getRuntime(ctx, runtimeName)
if err != nil {
return err
}

runtimeNamespace := runtimeName
if runtime.Metadata.Namespace != nil {
runtimeNamespace = *runtime.Metadata.Namespace
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix for git-source create command

return errors.New("This runtime was installed using Helm, please use Helm to uninstall it as well.")
}

if !opts.SkipChecks {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed all usage of SkipChecks

if !opts.Managed {
opts.kubeContext, err = getKubeContextName(cmd.Flag("context"), cmd.Flag("kubeconfig"))
if rt.Metadata.Namespace != nil {
opts.runtimeNamespace = *rt.Metadata.Namespace
Copy link
Contributor Author

Choose a reason for hiding this comment

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

get namespace from platform runtime object

Comment on lines +49 to +50
apapp "github.com/argoproj-labs/argocd-autopilot/pkg/application"
apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reorder and add alias

@@ -2191,3 +2192,22 @@ func patchClusterResourcesAppSet(fs fs.FS) error {
appSet.ObjectMeta.Labels[store.Get().LabelKeyCFInternal] = "true"
return fs.WriteYamls(name, appSet)
}

func getRuntimeNamespace(cmd *cobra.Command, runtimeName string, runtimeVersion *semver.Version) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from runtime.go to runtime_install.go - only used inside this file

@@ -40,7 +40,6 @@ cli-v2 runtime uninstall [RUNTIME_NAME] [flags]
-n, --namespace string If present, the namespace scope for this CLI request
--repo string Repository URL [GIT_REPO]
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
--skip-checks If true, will not verify that runtime exists before uninstalling
Copy link
Contributor Author

Choose a reason for hiding this comment

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

marked as deprecated - so it doesn't appear in help text

@noam-codefresh noam-codefresh merged commit 7e5ecfe into main May 23, 2023
@noam-codefresh noam-codefresh deleted the CR-18810-fix-create-gs branch May 23, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants