From 752b5734619d93358d53f9e18dd4f08374929577 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Sun, 12 Nov 2023 14:21:20 +0200 Subject: [PATCH] CR-21047-helm-migrate (#717) ## What added "migrate" command ## Why migrate cli-runtime resources to helm-runtime structure (git-sources and remote argo-rollouts installations) ## Notes also updated go.mod and dockerfile to use golang 1.21.3 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- CODEOWNERS | 2 +- Dockerfile | 6 +- Makefile | 4 +- build/Dockerfile.helper | 6 +- build/ci.yaml | 2 +- cmd/commands/cluster.go | 10 +- cmd/commands/common.go | 35 +- cmd/commands/git-source.go | 2 +- cmd/commands/helm.go | 15 +- cmd/commands/migrate.go | 608 ++++++++++++++++++++++++++++ cmd/commands/root.go | 1 + cmd/commands/runtime.go | 8 +- docs/commands/cli-v2.md | 1 + docs/commands/cli-v2_migrate.md | 42 ++ docs/requirements.txt | 2 +- go.mod | 22 +- go.sum | 51 ++- pkg/config/config.go | 5 +- pkg/store/store.go | 282 ++++++------- pkg/templates/argo-rollouts.tmpl | 25 ++ pkg/templates/git-source.tmpl | 37 ++ pkg/templates/rbac.tmpl | 30 ++ pkg/templates/rollout-reporter.tmpl | 178 ++++++++ pkg/templates/templates.go | 95 +++++ pkg/util/aputil/aputil.go | 28 +- pkg/util/helm/helm.go | 53 ++- pkg/util/helm/mocks/helm.go | 16 + pkg/util/kube/kube.go | 10 + pkg/util/openshift/util.go | 2 +- pkg/util/routing/gatewayapi.go | 37 +- 30 files changed, 1349 insertions(+), 266 deletions(-) create mode 100644 cmd/commands/migrate.go create mode 100644 docs/commands/cli-v2_migrate.md create mode 100644 pkg/templates/argo-rollouts.tmpl create mode 100644 pkg/templates/git-source.tmpl create mode 100644 pkg/templates/rbac.tmpl create mode 100644 pkg/templates/rollout-reporter.tmpl create mode 100644 pkg/templates/templates.go diff --git a/CODEOWNERS b/CODEOWNERS index bd7775faa..78f52e164 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* roi.kramer@codefresh.io noam.gal@codefresh.io daniel.maizel@codefresh.io pavel@codefresh.io ziv@codefresh.io itai@codefresh.io daniel.soifer@codefresh.io +* noam.gal@codefresh.io daniel.maizel@codefresh.io pavel@codefresh.io daniel.soifer@codefresh.io diff --git a/Dockerfile b/Dockerfile index dabc51ea5..0274357b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine3.16 as base +FROM golang:1.21.4-alpine3.18 as base WORKDIR /go/src/github.com/codefresh-io/cli-v2 @@ -26,7 +26,7 @@ RUN go mod verify ############################### CLI ############################### ### Compile -FROM golang:1.19-alpine3.16 as codefresh-build +FROM golang:1.21.4-alpine3.18 as codefresh-build WORKDIR /go/src/github.com/codefresh-io/cli-v2 @@ -44,7 +44,7 @@ ARG SEGMENT_WRITE_KEY RUN make local DEV_MODE=false SEGMENT_WRITE_KEY=${SEGMENT_WRITE_KEY} ### Run -FROM alpine:3.16 as codefresh +FROM alpine:3.18 as codefresh WORKDIR /go/src/github.com/codefresh-io/cli-v2 diff --git a/Makefile b/Makefile index d9b2eb50a..a96c9c646 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.1.51 +VERSION=v0.1.52 OUT_DIR=dist YEAR?=$(shell date +"%Y") @@ -176,4 +176,4 @@ $(GOBIN)/mockgen: $(GOBIN)/golangci-lint: @mkdir dist || true @echo installing: golangci-lint - @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.52.2 + @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.55.2 diff --git a/build/Dockerfile.helper b/build/Dockerfile.helper index 8b7556c0b..332cfbdf3 100644 --- a/build/Dockerfile.helper +++ b/build/Dockerfile.helper @@ -1,4 +1,4 @@ -FROM golang:1.21.1-alpine3.18 +FROM golang:1.21.4-alpine3.18 RUN apk -U add --no-cache \ bash \ @@ -12,14 +12,14 @@ RUN apk -U add --no-cache \ openssl \ && update-ca-certificates -ARG GH_VERSION=2.35.0 +ARG GH_VERSION=2.38.0 RUN curl -L https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz --output gh.tar.gz \ && tar -xzf gh.tar.gz \ && mv gh_${GH_VERSION}_linux_amd64/bin/gh /usr/local/bin \ && rm gh.tar.gz \ && rm -rf gh_${GH_VERSION}_linux_amd64 -ARG KUSTOMIZE_VERSION=5.1.1 +ARG KUSTOMIZE_VERSION=5.2.1 RUN curl -Ls https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz --output kustomize.tar.gz \ && tar -xzf kustomize.tar.gz \ && mv ./kustomize /usr/bin \ diff --git a/build/ci.yaml b/build/ci.yaml index a12442398..762eae03b 100644 --- a/build/ci.yaml +++ b/build/ci.yaml @@ -20,7 +20,7 @@ steps: prepare_env_vars: &deps stage: Prepare title: prepare-env - image: quay.io/codefresh/golang-ci-helper:1.20.3 + image: quay.io/codefresh/golang-ci-helper:1.21.4 commands: - cf_export GO111MODULE=on - cf_export GOCACHE=/codefresh/volume/gocache # change gopath to codefresh shared volume diff --git a/cmd/commands/cluster.go b/cmd/commands/cluster.go index 6ce3edc40..16be3e3fa 100644 --- a/cmd/commands/cluster.go +++ b/cmd/commands/cluster.go @@ -121,7 +121,7 @@ func newClusterAddCommand() *cobra.Command { ctx := cmd.Context() - opts.runtimeName, err = ensureRuntimeName(ctx, args, true) + opts.runtimeName, err = ensureRuntimeName(ctx, args, nil) if err != nil { return err } @@ -451,7 +451,7 @@ func newClusterRemoveCommand() *cobra.Command { ctx := cmd.Context() - opts.runtimeName, err = ensureRuntimeName(ctx, args, true) + opts.runtimeName, err = ensureRuntimeName(ctx, args, nil) if err != nil { return err } @@ -523,12 +523,12 @@ func runClusterList(ctx context.Context, runtimeName string) error { sort.SliceStable(clusters, func(i, j int) bool { c1 := clusters[i] - if c1.Metadata.Name == "in-cluster" { + if c1.Metadata.Name == store.Get().InClusterName { return true } c2 := clusters[j] - if c2.Metadata.Name == "in-cluster" { + if c2.Metadata.Name == store.Get().InClusterName { return false } @@ -597,7 +597,7 @@ func newClusterCreateArgoRolloutsCommand() *cobra.Command { PreRunE: func(cmd *cobra.Command, args []string) error { var err error - opts.runtimeName, err = ensureRuntimeName(cmd.Context(), args, true) + opts.runtimeName, err = ensureRuntimeName(cmd.Context(), args, nil) return err }, RunE: func(cmd *cobra.Command, _ []string) error { diff --git a/cmd/commands/common.go b/cmd/commands/common.go index 1f54230bf..c774c6dfc 100644 --- a/cmd/commands/common.go +++ b/cmd/commands/common.go @@ -179,7 +179,7 @@ func getRepoFromUserInput(cmd *cobra.Command) error { return cmd.Flags().Set("repo", repoInput) } -func ensureRuntimeName(ctx context.Context, args []string, allowManaged bool) (string, error) { +func ensureRuntimeName(ctx context.Context, args []string, filter func(runtime *platmodel.Runtime) bool) (string, error) { var ( runtimeName string err error @@ -190,7 +190,7 @@ func ensureRuntimeName(ctx context.Context, args []string, allowManaged bool) (s } if !store.Get().Silent { - runtimeName, err = getRuntimeNameFromUserSelect(ctx, allowManaged) + runtimeName, err = getRuntimeNameFromUserSelect(ctx, filter) if err != nil { return "", err } @@ -203,7 +203,7 @@ func ensureRuntimeName(ctx context.Context, args []string, allowManaged bool) (s return runtimeName, nil } -func getRuntimeNameFromUserSelect(ctx context.Context, allowManaged bool) (string, error) { +func getRuntimeNameFromUserSelect(ctx context.Context, filter func(runtime *platmodel.Runtime) bool) (string, error) { runtimes, err := cfConfig.NewClient().V2().Runtime().List(ctx) if err != nil { return "", err @@ -213,35 +213,34 @@ func getRuntimeNameFromUserSelect(ctx context.Context, allowManaged bool) (strin return "", fmt.Errorf("no runtimes were found") } - var runtimeNames []string - - for _, rt := range runtimes { - rtDisplay := rt.Metadata.Name - if rt.Managed { - if !allowManaged { - // preventing hosted runtimes to prompt - continue + var filteredRuntimes []platmodel.Runtime + if filter != nil { + filteredRuntimes = make([]platmodel.Runtime, 0) + for _, rt := range runtimes { + if filter(&rt) { + filteredRuntimes = append(filteredRuntimes, rt) } - rtDisplay = fmt.Sprintf("%s (hosted)", rtDisplay) } - runtimeNames = append(runtimeNames, rtDisplay) + } else { + filteredRuntimes = runtimes } templates := &promptui.SelectTemplates{ - Selected: "{{ . | yellow }} ", + Active: fmt.Sprintf("%s {{ .Metadata.Name | underline }}{{ if ne .InstallationType \"HELM\" }}{{ printf \" (%%s)\" .InstallationType | underline }}{{ end }}", promptui.IconSelect), + Inactive: " {{ .Metadata.Name }}{{ if ne .InstallationType \"HELM\" }}{{ printf \" (%s)\" .InstallationType }}{{ end }}", + Selected: "{{ .Metadata.Name | yellow }}", } labelStr := fmt.Sprintf("%vSelect runtime%v", CYAN, COLOR_RESET) prompt := promptui.Select{ Label: labelStr, - Items: runtimeNames, + Items: filteredRuntimes, Templates: templates, } - _, result, err := prompt.Run() - resultSplit := strings.Split(result, " ") - return resultSplit[0], err + i, _, err := prompt.Run() + return filteredRuntimes[i].Metadata.Name, err } func getRuntimeNameFromUserInput() (string, error) { diff --git a/cmd/commands/git-source.go b/cmd/commands/git-source.go index 7af60406f..96125c176 100644 --- a/cmd/commands/git-source.go +++ b/cmd/commands/git-source.go @@ -236,7 +236,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error err = appProxy.AppProxyGitSources().Create(ctx, &apmodel.CreateGitSourceInput{ AppName: opts.GsName, AppSpecifier: appSpecifier, - DestServer: store.Get().InCluster, + DestServer: store.Get().InClusterServerURL, DestNamespace: &opts.RuntimeNamespace, IsInternal: &isInternal, Include: &opts.Include, diff --git a/cmd/commands/helm.go b/cmd/commands/helm.go index 793bb44ab..2d9ec289f 100644 --- a/cmd/commands/helm.go +++ b/cmd/commands/helm.go @@ -26,6 +26,7 @@ import ( cfgit "github.com/codefresh-io/cli-v2/pkg/git" "github.com/codefresh-io/cli-v2/pkg/log" + "github.com/codefresh-io/cli-v2/pkg/store" "github.com/codefresh-io/cli-v2/pkg/util" "github.com/codefresh-io/cli-v2/pkg/util/helm" "github.com/codefresh-io/cli-v2/pkg/util/kube" @@ -49,10 +50,6 @@ type ( } ) -const ( - CODEFRESH_TOKEN = "codefresh-token" -) - var ( ErrRuntimeTokenNotFound = errors.New("runtime token not found") ) @@ -97,7 +94,7 @@ func NewHelmValidateValuesCommand() *cobra.Command { cmd.Flags().StringVarP(&opts.valuesFile, "values", "f", "", "specify values in a YAML file or a URL") cmd.Flags().BoolVar(&opts.hook, "hook", false, "set to true when running inside a helm-hook") - opts.helm = helm.AddFlags(cmd.Flags()) + opts.helm, _ = helm.AddFlags(cmd.Flags()) opts.kubeFactory = apkube.AddFlags(cmd.Flags()) util.Die(cmd.Flags().MarkHidden("hook")) @@ -165,7 +162,7 @@ func checkPlatform(ctx context.Context, opts *HelmValidateValuesOptions, values } func validateWithRuntimeToken(ctx context.Context, opts *HelmValidateValuesOptions, codefreshValues chartutil.Values, runtimeName string) error { - runtimeToken, _ := kube.GetValueFromSecret(ctx, opts.kubeFactory, opts.namespace, CODEFRESH_TOKEN, "token") + runtimeToken, _ := kube.GetValueFromSecret(ctx, opts.kubeFactory, opts.namespace, store.Get().CFTokenSecret, "token") if runtimeToken == "" { return ErrRuntimeTokenNotFound } @@ -201,7 +198,7 @@ func validateWithUserToken(ctx context.Context, opts *HelmValidateValuesOptions, return "", "", err } - if !user.IsActiveAccountAdmin() { + if !user.IsActiveAccountAdmin() { return "", "", fmt.Errorf("user \"%s\" does not have Admin role in account \"%s\"", user.Name, *user.ActiveAccount.Name) } @@ -565,3 +562,7 @@ func getValueFromSecretKeyRef(ctx context.Context, opts *HelmValidateValuesOptio return kube.GetValueFromSecret(ctx, opts.kubeFactory, opts.namespace, name, key) } + +func filterOnlyClidRuntime(rt *platmodel.Runtime) bool { + return rt.InstallationType == platmodel.InstallationTypeCli +} diff --git a/cmd/commands/migrate.go b/cmd/commands/migrate.go new file mode 100644 index 000000000..f8e97e453 --- /dev/null +++ b/cmd/commands/migrate.go @@ -0,0 +1,608 @@ +// Copyright 2023 The Codefresh Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package commands + +import ( + "context" + "fmt" + "net/url" + "strings" + + argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + "github.com/codefresh-io/cli-v2/pkg/log" + "github.com/codefresh-io/cli-v2/pkg/store" + "github.com/codefresh-io/cli-v2/pkg/templates" + "github.com/codefresh-io/cli-v2/pkg/util" + apu "github.com/codefresh-io/cli-v2/pkg/util/aputil" + "github.com/codefresh-io/cli-v2/pkg/util/helm" + "github.com/codefresh-io/cli-v2/pkg/util/kube" + "github.com/go-git/go-billy/v5/memfs" + + apcmd "github.com/argoproj-labs/argocd-autopilot/cmd/commands" + apfs "github.com/argoproj-labs/argocd-autopilot/pkg/fs" + apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git" + apkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube" + apstore "github.com/argoproj-labs/argocd-autopilot/pkg/store" + platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model" + "github.com/ghodss/yaml" + billyUtils "github.com/go-git/go-billy/v5/util" + apiextv1 "github.com/kubewarden/k8s-objects/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "github.com/spf13/cobra" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" +) + +type ( + MigrateOptions struct { + runtimeName string + cloneOpts *apgit.CloneOptions + helm helm.Helm + kubeContext string + kubeFactory apkube.Factory + } +) + +func NewMigrateCommand() *cobra.Command { + opts := &MigrateOptions{} + + cmd := &cobra.Command{ + Use: "migrate", + Short: "migrate a cli-runtime to the new helm-runtime", + Example: util.Doc(" helm migrate [RUNTIME_NAME]"), + Args: cobra.MaximumNArgs(1), + PreRunE: func(cmd *cobra.Command, args []string) error { + var err error + + ctx := cmd.Context() + err = cfConfig.RequireAuthentication(cmd, args) + if err != nil { + return err + } + + opts.runtimeName, err = ensureRuntimeName(ctx, args, filterOnlyClidRuntime) + if err != nil { + return err + } + + opts.kubeContext, err = getKubeContextName(cmd.Flag("context"), cmd.Flag("kubeconfig")) + if err != nil { + return err + } + + return nil + }, + RunE: func(cmd *cobra.Command, _ []string) error { + err := runHelmMigrate(cmd.Context(), opts) + if err != nil { + return fmt.Errorf("failed upgraring runtime %q: %w", opts.runtimeName, err) + } + + return nil + }, + } + + opts.cloneOpts = apu.AddRepoFlags(cmd, &apu.CloneFlagsOptions{ + CreateIfNotExist: false, + CloneForWrite: true, + Optional: false, + }) + opts.helm, _ = helm.AddFlags(cmd.Flags()) + opts.kubeFactory = apkube.AddFlags(cmd.Flags()) + + return cmd +} + +func runHelmMigrate(ctx context.Context, opts *MigrateOptions) error { + runtime, err := getCliRuntime(ctx, opts.runtimeName) + if err != nil { + return err + } + + log.G(ctx).Infof("Got runtime data %q", opts.runtimeName) + user, err := cfConfig.NewClient().V2().UsersV2().GetCurrent(ctx) + if err != nil { + return fmt.Errorf("failed getting current user: %w", err) + } + + log.G(ctx).Infof("Got user data for %q", user.Name) + srcCloneOpts := &apgit.CloneOptions{ + Provider: user.ActiveAccount.GitProvider.String(), + Repo: *runtime.Repo, + Auth: opts.cloneOpts.Auth, + FS: opts.cloneOpts.FS, + } + srcCloneOpts.Parse() + srcRepo, srcFs, err := srcCloneOpts.GetRepo(ctx) + if err != nil { + return fmt.Errorf("failed getting installation repo: %w", err) + } + + log.G(ctx).Infof("Cloned installation repo %q", *runtime.Repo) + destCloneOpts := &apgit.CloneOptions{ + Provider: user.ActiveAccount.GitProvider.String(), + Repo: *user.ActiveAccount.SharedConfigRepo, + Auth: opts.cloneOpts.Auth, + FS: apfs.Create(memfs.New()), + } + destCloneOpts.Parse() + destRepo, destFs, err := destCloneOpts.GetRepo(ctx) + if err != nil { + return fmt.Errorf("failed getting shared config repo: %w", err) + } + + log.G(ctx).Infof("Cloned internal-shared-config repo %q", *user.ActiveAccount.SharedConfigRepo) + err = moveGitSources(srcFs, destFs, opts.runtimeName) + if err != nil { + return fmt.Errorf("failed moving git sources: %w", err) + } + + log.G(ctx).Infof("moved all git-sources from installation repo to shared-config-repo") + err = moveArgoRollouts(ctx, srcFs, destFs, opts, *runtime.Metadata.Namespace) + if err != nil { + return fmt.Errorf("failed moving argo-rollouts: %w", err) + } + + err = createRbacInIsc(destFs, opts.runtimeName, *runtime.Metadata.Namespace) + if err != nil { + return fmt.Errorf("failed creating rbac: %w", err) + } + + log.G(ctx).Warnf("Created \"codefresh-config-reader\" Role and RoleBinding for default SA in namespace %q", *runtime.Metadata.Namespace) + sha, err := srcRepo.Persist(ctx, &apgit.PushOptions{ + CommitMsg: "moved resources to internal-shared-config repo", + }) + if err != nil { + return fmt.Errorf("failed pushing changes to installation repo: %w", err) + } + + log.G(ctx).Infof("Pushed changes to installation repo %q, sha: %s", *user.ActiveAccount.SharedConfigRepo, sha) + sha, err = destRepo.Persist(ctx, &apgit.PushOptions{ + CommitMsg: "moved resources from installation repo", + }) + if err != nil { + return fmt.Errorf("failed pushing changes to internal-shared-config repo: %w", err) + } + + log.G(ctx).Infof("Pushed changes to shared-config-repo %q, sha: %s", *runtime.Repo, sha) + log.G(ctx).Infof("Done migrating resources from %q to %q", *runtime.Repo, *user.ActiveAccount.SharedConfigRepo) + + err = removeFromCluster(ctx, *runtime.Metadata.Namespace, opts.kubeContext, srcCloneOpts, opts.kubeFactory) + if err != nil { + return fmt.Errorf("failed removing runtime from cluster: %w", err) + } + + err = cfConfig.NewClient().V2().Runtime().MigrateRuntime(ctx, opts.runtimeName) + if err != nil { + return fmt.Errorf("failed migrating runtime type in platform: %w", err) + } + + log.G(ctx).Infof("Finished migrating runtime %q", opts.runtimeName) + return nil +} + +func getCliRuntime(ctx context.Context, runtimeName string) (*platmodel.Runtime, error) { + runtime, err := getRuntime(ctx, runtimeName) + if err != nil { + return nil, fmt.Errorf("failed getting runtime: %w", err) + } + + if runtime.InstallationType != platmodel.InstallationTypeCli { + return nil, fmt.Errorf("runtime %q is not a cli-runtime", runtimeName) + } + + if runtime.Repo == nil { + return nil, fmt.Errorf("runtime %q does not have an installation repo", runtimeName) + } + + return runtime, nil +} + +func getAppsetGlobs(srcFs apfs.FS) (map[string]string, error) { + res := make(map[string]string) + projects, err := billyUtils.Glob(srcFs, "/projects/*.yaml") + if err != nil { + return nil, fmt.Errorf("failed getting projects: %w", err) + } + + for _, projectFile := range projects { + _, appSet, err := getProjectInfoFromFile(srcFs, projectFile) + if err != nil { + return nil, fmt.Errorf("failed getting project info from file %q: %w", projectFile, err) + } + + generators := appSet.Spec.Generators + for _, generator := range generators { + if generator.Git == nil { + continue + } + + for _, file := range generator.Git.Files { + if strings.HasSuffix(file.Path, "config_dir.json") { + res[appSet.Name] = file.Path + } + } + } + } + + if err != nil { + return nil, fmt.Errorf("failed getting globs from projects directory: %w", err) + } + + return res, nil +} + +func moveGitSources(srcFs, destFs apfs.FS, runtimeName string) error { + globs, err := getAppsetGlobs(srcFs) + if err != nil { + return err + } + + for clusterName, glob := range globs { + err = moveClusterGitSources(srcFs, destFs, glob, runtimeName, clusterName) + if err != nil { + return err + } + } + + return nil +} + +func moveClusterGitSources(srcFs, destFs apfs.FS, glob, runtimeName, clusterName string) error { + if clusterName == runtimeName { + clusterName = store.Get().InClusterName + } + + configs, err := billyUtils.Glob(srcFs, glob) + if err != nil { + return fmt.Errorf("failed getting git sources from %q: %w", glob, err) + } + + for _, configPath := range configs { + err = moveSingleGitSource(srcFs, destFs, configPath, runtimeName, clusterName) + if err != nil { + return fmt.Errorf("failed moving git-source %q: %w", configPath, err) + } + } + + return nil +} + +func moveSingleGitSource(srcFs, destFs apfs.FS, configPath, runtimeName, clusterName string) error { + config := &templates.GitSourceConfig{} + err := srcFs.ReadJson(configPath, config) + if err != nil { + return fmt.Errorf("failed reading config_dir.json: %w", err) + } + + if config.Labels[store.Get().LabelFieldCFType] != store.Get().CFGitSourceType { + return nil + } + + config.RuntimeName = runtimeName + for key, value := range config.Annotations { + if strings.Contains(key, "-") { + newKey := strings.ReplaceAll(key, "-", "_") + config.Annotations[newKey] = value + delete(config.Annotations, key) + } + } + + yaml, err := templates.RenderGitSource(config) + if err != nil { + return fmt.Errorf("failed rendering git source: %w", err) + } + + err = writeYamlInIsc(destFs, config.AppName, runtimeName, clusterName, yaml) + if err != nil { + return fmt.Errorf("failed writing git source: %w", err) + } + + err = srcFs.Remove(configPath) + if err != nil { + return fmt.Errorf("failed removing config_dir.json: %w", err) + } + + return nil +} + +func moveArgoRollouts(ctx context.Context, srcFs, destFs apfs.FS, opts *MigrateOptions, runtimeNamespace string) error { + rolloutsOverlaysPath := srcFs.Join("apps", "rollouts", "overlays") + rolloutsOverlays, err := srcFs.ReadDir(rolloutsOverlaysPath) + if err != nil { + return fmt.Errorf("failed reading rollouts overlays: %w", err) + } + + var clusterNames []string + for _, overlay := range rolloutsOverlays { + if overlay.IsDir() && overlay.Name() != opts.runtimeName { + clusterNames = append(clusterNames, overlay.Name()) + } + } + + for _, clusterName := range clusterNames { + err = moveClusterArgoRollouts(srcFs, destFs, opts, clusterName) + if err != nil { + return fmt.Errorf("failed moving argo-rollouts: %w", err) + } + + err = moveClusterRolloutReporter(srcFs, destFs, opts.runtimeName, runtimeNamespace, clusterName) + if err != nil { + return fmt.Errorf("failed moving rollout-reporter: %w", err) + } + + log.G(ctx).Infof("Moved argo-rollouts and rollout-reporter for %q", clusterName) + } + + return nil +} + +func moveClusterArgoRollouts(srcFs, destFs apfs.FS, opts *MigrateOptions, clusterName string) error { + err := createClusterArgoRollouts(destFs, opts, clusterName) + if err != nil { + return fmt.Errorf("failed creating argo-rollouts: %w", err) + } + + overlayPath := srcFs.Join("apps", "rollouts", "overlays", clusterName) + err = billyUtils.RemoveAll(srcFs, overlayPath) + if err != nil { + return fmt.Errorf("failed removing config_dir.json: %w", err) + } + + return nil +} + +func createClusterArgoRollouts(destFs apfs.FS, opts *MigrateOptions, clusterName string) error { + appName := addSuffix(clusterName, "-"+store.Get().RolloutResourceName, 63) + repoURL, targetRevision, err := opts.helm.GetDependency("argo-rollouts") + if err != nil { + return fmt.Errorf("failed getting argo-rollouts dependency: %w", err) + } + + yaml, err := templates.RenderArgoRollouts(&templates.ArgoRolloutsConfig{ + AppName: appName, + ClusterName: clusterName, + RepoURL: repoURL, + TargetVersion: targetRevision, + }) + if err != nil { + return fmt.Errorf("failed rendering argo-rollouts: %w", err) + } + + err = writeYamlInIsc(destFs, appName, opts.runtimeName, clusterName, yaml) + if err != nil { + return err + } + + return nil +} + +func moveClusterRolloutReporter(srcFs, destFs apfs.FS, runtimeName, runtimeNamespace, clusterName string) error { + err := createClusterRolloutReporter(destFs, runtimeName, runtimeNamespace, clusterName) + if err != nil { + return fmt.Errorf("failed creating rollout-reporter: %w", err) + } + + rolloutReporterPath := srcFs.Join("apps", "rollout-reporter", runtimeName, "resources") + esPath := srcFs.Join(rolloutReporterPath, fmt.Sprintf("%s-event-source.yaml", clusterName)) + err = srcFs.Remove(esPath) + if err != nil { + return fmt.Errorf("failed removing event-source: %w", err) + } + + sensorPath := srcFs.Join(rolloutReporterPath, fmt.Sprintf("%s-sensor.yaml", clusterName)) + err = srcFs.Remove(sensorPath) + if err != nil { + return fmt.Errorf("failed removing sensor: %w", err) + } + + return nil +} + +func createClusterRolloutReporter(destFs apfs.FS, runtimeName, runtimeNamespace, clusterName string) error { + name := addSuffix(clusterName, "-"+store.Get().RolloutReporterName, 63) + triggerUrl, err := url.JoinPath(cfConfig.GetCurrentContext().URL, store.Get().EventReportingEndpoint) + if err != nil { + return err + } + + yaml, err := templates.RenderRolloutReporter(&templates.RolloutReporterConfig{ + Name: name, + Namespace: runtimeNamespace, + ClusterName: clusterName, + EventEndpoint: triggerUrl, + }) + if err != nil { + return fmt.Errorf("failed rendering argo-rollouts: %w", err) + } + + err = writeYamlInIsc(destFs, name, runtimeName, clusterName, yaml) + if err != nil { + return fmt.Errorf("failed writing argo-rollouts: %w", err) + } + + return nil +} + +func createRbacInIsc(destFs apfs.FS, runtimeName, runtimeNamespace string) error { + yaml, err := templates.RenderRBAC(&templates.RbacConfig{ + Namespace: runtimeNamespace, + }) + if err != nil { + return fmt.Errorf("failed rendering rbac: %w", err) + } + + err = writeYamlInIsc(destFs, "codefresh-config-reader", runtimeName, store.Get().InClusterName, yaml) + if err != nil { + return fmt.Errorf("failed writing argo-rollouts: %w", err) + } + + return nil +} + +func writeYamlInIsc(destFs apfs.FS, fileName, runtimeName, clusterName string, data []byte) error { + relPath := destFs.Join(runtimeName, fileName+".yaml") + fullPAth := destFs.Join("resources", relPath) + err := billyUtils.WriteFile(destFs, fullPAth, data, 0666) + if err != nil { + return fmt.Errorf("failed writing %q resource: %w", fileName, err) + } + + return addPathToClusterApp(destFs, runtimeName, clusterName, relPath) +} + +func addPathToClusterApp(destFs apfs.FS, runtimeName, clusterName, path string) error { + filename := destFs.Join("runtimes", runtimeName, clusterName+".yaml") + app := &argocdv1alpha1.Application{} + err := destFs.ReadYamls(filename, app) + if err != nil { + return err + } + + addPathToInclude(app, path) + bytes, err := yaml.Marshal(app) + bytes = filterStatus(bytes) + fmt.Println(string(bytes)) + if err != nil { + return err + } + + return billyUtils.WriteFile(destFs, filename, bytes, 0666) +} + +func addPathToInclude(app *argocdv1alpha1.Application, path string) { + includeStr := app.Spec.Source.Directory.Include + includeArr := strings.Split(includeStr[1:len(includeStr)-1], ",") + includeSet := make(map[string]interface{}) + for _, include := range includeArr { + includeSet[include] = nil + } + + includeSet[path] = nil + includeArr = make([]string, 0, len(includeSet)) + for include := range includeSet { + includeArr = append(includeArr, include) + } + + app.Spec.Source.Directory.Include = fmt.Sprintf("{%s}", strings.Join(includeArr, ",")) +} + +func addSuffix(str, suffix string, length int) string { + if len(str)+len(suffix) < length { + return str + suffix + } + + return str[:length-len(suffix)] + suffix +} + +func removeFromCluster(ctx context.Context, runtimeNamespace, kubeContext string, cloneOptions *apgit.CloneOptions, kubeFactory apkube.Factory) error { + err := switchManagedByLabel(ctx, kubeFactory, runtimeNamespace) + if err != nil { + return fmt.Errorf("failed preserving codefresh token secret: %w", err) + } + + err = apcmd.RunRepoUninstall(ctx, &apcmd.RepoUninstallOptions{ + Namespace: runtimeNamespace, + KubeContextName: kubeContext, + Timeout: store.Get().WaitTimeout, + CloneOptions: cloneOptions, + KubeFactory: kubeFactory, + Force: true, + FastExit: false, + }) + if err != nil { + return fmt.Errorf("failed uninstalling runtime: %w", err) + } + + err = patchCrds(ctx, kubeFactory) + if err != nil { + return fmt.Errorf("failed updating argoproj CRDs: %w", err) + } + + return nil +} + +func switchManagedByLabel(ctx context.Context, kubeFactory apkube.Factory, namespace string) error { + secretsInterface := kube.GetClientSetOrDie(kubeFactory).CoreV1().Secrets(namespace) + secrets, err := secretsInterface.List(ctx, metav1.ListOptions{ + LabelSelector: fmt.Sprintf("%s=%s", apstore.Default.LabelKeyAppManagedBy, apstore.Default.LabelValueManagedBy), + }) + if err != nil { + return fmt.Errorf("failed getting secrets: %w", err) + } + + for _, secret := range secrets.Items { + _, err := secretsInterface.Patch( + ctx, + secret.Name, + types.StrategicMergePatchType, + []byte(getLabelPatch("codefresh")), + metav1.PatchOptions{}, + ) + if err != nil { + return fmt.Errorf("failed patching secret %q: %w", secret.Name, err) + } + } + + return nil +} + +func patchCrds(ctx context.Context, kubeFactory apkube.Factory) error { + gvr := schema.GroupVersionResource(apiextv1.SchemeGroupVersion.WithResource("customresourcedefinitions")) + crdInterface := kube.GetDynamicClientOrDie(kubeFactory).Resource(gvr) + crds, err := crdInterface.List(ctx, metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("failed listing crds: %w", err) + } + + for _, crd := range crds.Items { + if !strings.HasSuffix(crd.GetName(), "argoproj.io") { + continue + } + + _, err := crdInterface.Patch( + ctx, + crd.GetName(), + types.StrategicMergePatchType, + []byte(getLabelPatch("Helm")), + metav1.PatchOptions{}, + ) + if err != nil { + return fmt.Errorf("failed patching crd %q: %w", crd.GetName(), err) + } + + log.G(ctx).Debugf("Patched crd %q", crd.GetName()) + } + + return nil +} + +func getLabelPatch(value string) string { + return fmt.Sprintf(`{ "metadata": { "labels": { "%s": "%s" } } }`, apstore.Default.LabelKeyAppManagedBy, value) +} + +func filterStatus(manifest []byte) []byte { + lines := strings.Split(string(manifest), "\n") + var res []string + for _, line := range lines { + if strings.HasPrefix(line, "status:") { + break + } + + res = append(res, line) + } + + return []byte(strings.Join(res, "\n")) +} diff --git a/cmd/commands/root.go b/cmd/commands/root.go index ef09aa41a..18a2c6492 100644 --- a/cmd/commands/root.go +++ b/cmd/commands/root.go @@ -60,6 +60,7 @@ variables in advanced to simplify the use of those commands. cmd.AddCommand(NewPipelineCommand()) cmd.AddCommand(NewIntegrationCommand()) cmd.AddCommand(NewCompletionCommand()) + cmd.AddCommand(NewMigrateCommand()) cobra.OnInitialize(func() { postInitCommands(cmd.Commands()) }) diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index 496b2ce91..55d2f13c4 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -141,7 +141,7 @@ func runtimeUninstallCommandPreRunHandler(cmd *cobra.Command, args []string, opt handleCliStep(reporter.UninstallPhasePreCheckStart, "Starting pre checks", nil, true, false) - opts.RuntimeName, err = ensureRuntimeName(ctx, args, true) + opts.RuntimeName, err = ensureRuntimeName(ctx, args, nil) handleCliStep(reporter.UninstallStepPreCheckEnsureRuntimeName, "Ensuring runtime name", err, true, false) if err != nil { return err @@ -211,13 +211,17 @@ func runtimeUninstallCommandPreRunHandler(cmd *cobra.Command, args []string, opt return nil } +func filterNonHostedRuntime(rt *platmodel.Runtime) bool { + return rt.InstallationType != platmodel.InstallationTypeHosted +} + func runtimeUpgradeCommandPreRunHandler(cmd *cobra.Command, args []string, opts *RuntimeUpgradeOptions) error { var err error ctx := cmd.Context() handleCliStep(reporter.UpgradePhasePreCheckStart, "Starting pre checks", nil, true, false) - opts.RuntimeName, err = ensureRuntimeName(ctx, args, false) + opts.RuntimeName, err = ensureRuntimeName(ctx, args, filterNonHostedRuntime) handleCliStep(reporter.UpgradeStepPreCheckEnsureRuntimeName, "Ensuring runtime name", err, true, false) if err != nil { return err diff --git a/docs/commands/cli-v2.md b/docs/commands/cli-v2.md index f53542f50..17272a493 100644 --- a/docs/commands/cli-v2.md +++ b/docs/commands/cli-v2.md @@ -39,6 +39,7 @@ cli-v2 [flags] * [cli-v2 git-source](cli-v2_git-source.md) - Manage git-sources of Codefresh runtimes * [cli-v2 helm](cli-v2_helm.md) - Helm related commands * [cli-v2 integration](cli-v2_integration.md) - Manage integrations with git providers, container registries and more +* [cli-v2 migrate](cli-v2_migrate.md) - migrate a cli-runtime to the new helm-runtime * [cli-v2 pipeline](cli-v2_pipeline.md) - Manage pipelines of Codefresh runtimes * [cli-v2 runtime](cli-v2_runtime.md) - Manage Codefresh runtimes * [cli-v2 upgrade](cli-v2_upgrade.md) - Upgrades the cli diff --git a/docs/commands/cli-v2_migrate.md b/docs/commands/cli-v2_migrate.md new file mode 100644 index 000000000..ca76d4f1d --- /dev/null +++ b/docs/commands/cli-v2_migrate.md @@ -0,0 +1,42 @@ +## cli-v2 migrate + +migrate a cli-runtime to the new helm-runtime + +``` +cli-v2 migrate [flags] +``` + +### Examples + +``` +cli-v2 helm migrate [RUNTIME_NAME] +``` + +### Options + +``` + --context string The name of the kubeconfig context to use + --devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored + --git-server-crt string Git Server certificate file + -t, --git-token string Your git provider api token [GIT_TOKEN] + -u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub) + -h, --help help for migrate + --kubeconfig string Path to the kubeconfig file to use for CLI requests. + -n, --namespace string If present, the namespace scope for this CLI request + --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") + --version string specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used +``` + +### Options inherited from parent commands + +``` + --auth-context string Run the next command using a specific authentication context + --cfconfig string Custom path for authentication contexts config file (default "/home/user") + --insecure Disable certificate validation for TLS connections (e.g. to g.codefresh.io) + --insecure-ingress-host Disable certificate validation of ingress host (default: false) +``` + +### SEE ALSO + +* [cli-v2](cli-v2.md) - cli-v2 is used for installing and managing codefresh installations using gitops + diff --git a/docs/requirements.txt b/docs/requirements.txt index 7354216f3..390d498f0 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,3 @@ mkdocs-material markdown_include -pygments==2.7.4 \ No newline at end of file +pygments==2.15.0 \ No newline at end of file diff --git a/go.mod b/go.mod index aeb3c4b6e..7534c500e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/codefresh-io/cli-v2 -go 1.19 +go 1.21 require ( github.com/Masterminds/semver/v3 v3.2.0 @@ -9,15 +9,16 @@ require ( github.com/argoproj/argo-events v0.17.1-0.20220327045437-70eaafe9afec github.com/argoproj/argo-workflows/v3 v3.3.1 github.com/briandowns/spinner v1.18.1 - github.com/codefresh-io/go-sdk v0.57.0 + github.com/codefresh-io/go-sdk v0.58.0 github.com/fatih/color v1.13.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 - github.com/go-git/go-billy/v5 v5.3.1 + github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.4.2 github.com/gobuffalo/packr v1.30.1 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc + github.com/kubewarden/k8s-objects v1.26.0-kw4 github.com/manifoldco/promptui v0.8.0 github.com/openshift/api v3.9.0+incompatible github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 @@ -29,7 +30,7 @@ require ( github.com/spf13/viper v1.10.1 github.com/stretchr/testify v1.8.1 golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4 - golang.org/x/text v0.7.0 + golang.org/x/text v0.13.0 gopkg.in/segmentio/analytics-go.v3 v3.1.0 helm.sh/helm/v3 v3.11.2 k8s.io/api v0.26.3 @@ -74,7 +75,7 @@ require ( github.com/containerd/containerd v1.6.15 // indirect github.com/coreos/go-oidc v2.2.1+incompatible // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/cyphar/filepath-securejoin v0.2.3 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/docker/cli v20.10.21+incompatible // indirect @@ -199,7 +200,7 @@ require ( github.com/r3labs/diff v1.1.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/robfig/cron v1.2.0 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.0 // indirect github.com/rubenv/sql-migrate v1.3.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -233,12 +234,13 @@ require ( go.opentelemetry.io/otel v1.10.0 // indirect go.opentelemetry.io/otel/trace v1.10.0 // indirect go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect - golang.org/x/crypto v0.5.0 // indirect - golang.org/x/net v0.7.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/term v0.5.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect gomodules.xyz/envconfig v1.3.1-0.20190308184047-426f31af0d45 // indirect gomodules.xyz/notify v0.1.0 // indirect diff --git a/go.sum b/go.sum index 371540c05..5302abcbe 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,7 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/compute v1.7.0 h1:v/k9Eueb8aAJ0vZuxKMrgm6kPhCLZU9HxFU+AFDs9Uk= +cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= @@ -117,6 +118,7 @@ github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8= github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg= github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY= +github.com/Microsoft/hcsshim v0.9.6/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -234,6 +236,7 @@ github.com/briandowns/spinner v1.18.1 h1:yhQmQtM1zsqFsouh09Bk/jCjd50pC3EOGsh28gL github.com/briandowns/spinner v1.18.1/go.mod h1:mQak9GHqbspjC/5iUx3qMlIho8xBS/ppAL/hX5SmPJU= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= +github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= @@ -288,13 +291,14 @@ github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/codefresh-io/go-sdk v0.57.0 h1:+CYSyVRz1/Eip6cPF9MFlC0D94z7cNQA+IM5FQY8hXQ= -github.com/codefresh-io/go-sdk v0.57.0/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg= +github.com/codefresh-io/go-sdk v0.58.0 h1:vAcnA2NAVwqk+3MzaAIOyhYXeGKxgjXtx2tPUnhehbE= +github.com/codefresh-io/go-sdk v0.58.0/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM= github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA= +github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO4JTrUzo6IA= github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.3.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= @@ -334,9 +338,10 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -354,6 +359,7 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/digitalocean/godo v1.64.2/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= +github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2/go.mod h1:WHNsWjnIn2V1LYOrME7e8KxSeKunYHsxEm4am0BUtcI= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/cli v20.10.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.21+incompatible h1:qVkgyYUnOLQ98LtXBrwd/duVqPT2X4SHndOuGsfwyhU= @@ -373,6 +379,7 @@ github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNk github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= +github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= @@ -484,8 +491,9 @@ github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmn github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= @@ -746,6 +754,7 @@ github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1X github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE= github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA= github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k= +github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= @@ -870,6 +879,7 @@ github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39 github.com/hashicorp/go-hclog v0.16.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.1.0 h1:QsGcniKx5/LuX2eYoeL+Np3UKYPNaN7YKpTh29h8rbw= +github.com/hashicorp/go-hclog v1.1.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -1001,6 +1011,7 @@ github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0Lh github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/karrick/godirwalk v1.17.0 h1:b4kY7nqDdioR/6qnbHQyDvmA17u5G1cZ6J+CZXwSWoI= +github.com/karrick/godirwalk v1.17.0/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= @@ -1034,6 +1045,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ktrysmt/go-bitbucket v0.9.49 h1:VVfdYIw1SLmgD4xremGkyVY8oI84m9hSbZTK3FyBjxA= github.com/ktrysmt/go-bitbucket v0.9.49/go.mod h1:aB/IUpoFE65X84soIfgUPT53bzp/jfYoffLN2mg3bFc= +github.com/kubewarden/k8s-objects v1.26.0-kw4 h1:tg1QE7P9MnJWI4RxJLRzTAKvUxKFSLZTz/pRZHFqA1Y= +github.com/kubewarden/k8s-objects v1.26.0-kw4/go.mod h1:EMF+Hr26oDR4yQkWJAQpl0M0Ek5ioNXlCswjGZO0G2U= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= @@ -1072,6 +1085,7 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/malexdev/utfutil v0.0.0-20180510171754-00c8d4a8e7a8 h1:A6SLdFpRzUUF5v9F/7T1fu3DERmOCgTwwP6x54eyFfU= +github.com/malexdev/utfutil v0.0.0-20180510171754-00c8d4a8e7a8/go.mod h1:UtpLyb/EupVKXF/N0b4NRe1DNg+QYJsnsHQ038romhM= github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo= github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ= github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI= @@ -1169,6 +1183,7 @@ github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQ github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= +github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= @@ -1253,8 +1268,9 @@ github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9 github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= -github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -1301,6 +1317,7 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= +github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1401,8 +1418,9 @@ github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.4.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -1533,6 +1551,7 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -1699,6 +1718,7 @@ go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1743,8 +1763,9 @@ golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1806,6 +1827,8 @@ golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2 golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1881,8 +1904,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2050,8 +2074,9 @@ golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2059,8 +2084,9 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2072,8 +2098,9 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/pkg/config/config.go b/pkg/config/config.go index 675e8cd98..5a0eb6b03 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -128,12 +128,10 @@ func (c *ConfigImpl) RequireAuthentication(cmd *cobra.Command, args []string) er return fmt.Errorf(util.Doc("%s: command requires authentication, run ' config create-context'"), cmd.CommandPath()) } - c.validate() - return nil } -func (c *ConfigImpl) Load(cmd *cobra.Command, args []string) error { +func (c *ConfigImpl) Load(_ *cobra.Command, _ []string) error { viper.SetConfigType(configFileFormat) viper.SetConfigName(configFileName) viper.AddConfigPath(c.path) @@ -145,6 +143,7 @@ func (c *ConfigImpl) Load(cmd *cobra.Command, args []string) error { return nil } } + return err } diff --git a/pkg/store/store.go b/pkg/store/store.go index f8371db90..81b00d79c 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -49,115 +49,119 @@ type Version struct { } type Store struct { AddClusterJobName string + AnalysisRunResourceName string + AnnotationKeySyncWave string + AppProxyIngressName string + AppProxyIngressPath string + AppProxyServiceName string + ArgoCD string ArgoCDServerName string ArgoCDTokenKey string ArgoCDTokenSecret string ArgoWfIngressPath string ArgoWfServiceName string BinaryName string - Codefresh string CFComponentType string CFGitSourceType string + CFInternalGitSources []string + CFInternalReporters []string CFRuntimeDefType string CFRuntimeType string + CFStoreIVSecretKey string CFTokenSecret string CFTokenSecretKey string - CFStoreIVSecretKey string + CLIDownloadTemplate string + CLILatestVersionFileLink string + ClusterResourcesPath string + Codefresh string CodefreshCM string CodefreshSA string ComponentsReporterName string ComponentsReporterSA string ComponentsReporterURL string DefaultAPI string - EventBusName string - EventReportingEndpoint string - EventsReporterName string - GitSourceName string - InternalRouterServiceName string - InternalRouterServicePort int32 - InternalRouterIngressName string - InternalRouterInternalIngressName string - InternalRouterIngressFilePath string - WebhooksIngressPath string - AppProxyIngressName string - AppProxyIngressPath string - AppProxyServiceName string - DocsLink string - LabelKeyCFType string - LabelKeyCFInternal string - LabelSelectorSealedSecret string - LabelSelectorGitIntegrationSecret string - AnnotationKeySyncWave string - MarketplaceGitSourceName string - MarketplaceRepo string - MaxDefVersion *semver.Version - LastRuntimeVersionInCLI *semver.Version - RuntimeDefURL string - OldRuntimeDefURL string - Version Version - WaitTimeout time.Duration - WorkflowName string - WorkflowReporterName string - WorkflowTriggerServiceAccount string - DemoCalendarSensorObjectName string - DemoCalendarSensorFileName string + DefaultNamespace string + DefVersionToLastCLIVersion map[string]string + DemoCalendarDependencyName string + DemoCalendarEventName string DemoCalendarEventSourceFileName string DemoCalendarEventSourceObjectName string - DemoCalendarEventName string - DemoCalendarDependencyName string - DemoWorkflowTemplateFileName string - DemoWorkflowTemplateName string + DemoCalendarSensorFileName string + DemoCalendarSensorObjectName string + DemoGitDependencyName string + DemoGitEventName string DemoGitEventSourceFileName string DemoGitEventSourceObjectName string - WebhooksRootPath string - DemoGitEventSourceTargetPort string DemoGitEventSourceServicePort int32 + DemoGitEventSourceTargetPort string DemoGitSensorFileName string DemoGitSensorObjectName string - DemoGitEventName string DemoGitTriggerTemplateName string - DemoGitDependencyName string - GitTokenSecretObjectName string - GitTokenSecretKey string + DemoWorkflowTemplateFileName string + DemoWorkflowTemplateName string + DocsLink string + DownloadCliLink string + EventBusName string + EventReportingEndpoint string + EventsReporterName string GithubEventTypeHeader string GitlabEventTypeHeader string - ArgoCD string - Silent bool + GitSourceName string + GitTokenSecretKey string + GitTokenSecretObjectName string + GitTokensLink string + GsCreateFlow string + InClusterName string + InClusterServerURL string + InClusterPath string + IngressHost string InsecureIngressHost bool - SetDefaultResources bool - MinimumMemorySizeRequired string + InternalRouterIngressFilePath string + InternalRouterIngressName string + InternalRouterInternalIngressName string + InternalRouterServiceName string + InternalRouterServicePort int32 + IscRuntimesDir string + IsDownloadRuntimeLogs bool + KubeVersionConstrint *semver.Constraints + LabelFieldCFType string + LabelKeyCFInternal string + LabelKeyCFType string + LabelGitIntegrationTypeKey string + LabelGitIntegrationTypeValue string + LabelSelectorGitIntegrationSecret string + LabelSelectorSealedSecret string + LastRuntimeVersionInCLI *semver.Version + MarketplaceGitSourceName string + MarketplaceRepo string + MasterIngressName string + MaxDefVersion *semver.Version MinimumCpuRequired string MinimumLocalDiskSizeRequired string + MinimumMemorySizeRequired string + NetworkTesterGenerateName string + NetworkTesterImage string + NetworkTesterName string + OldRuntimeDefURL string ReplicaSetResourceName string - AnalysisRunResourceName string - WorkflowResourceName string RequirementsLink string - GitTokensLink string - DownloadCliLink string - CLIDownloadTemplate string - CLILatestVersionFileLink string RolloutReporterName string - RolloutResourceName string RolloutReporterServiceAccount string - DefaultNamespace string - NetworkTesterName string - NetworkTesterGenerateName string - NetworkTesterImage string + RolloutResourceName string + RuntimeDefURL string + SccName string + SetDefaultResources bool + Silent bool TCPConnectionTesterGenerateName string TCPConnectionTesterName string - KubeVersionConstrint *semver.Constraints - MasterIngressName string - ClusterResourcesPath string - InClusterPath string - SccName string - CFInternalGitSources []string - CFInternalReporters []string - GsCreateFlow string - InCluster string - IsDownloadRuntimeLogs bool - IngressHost string - IscRuntimesDir string - DefVersionToLastCLIVersion map[string]string + Version Version + WaitTimeout time.Duration + WebhooksIngressPath string + WebhooksRootPath string + WorkflowName string + WorkflowReporterName string + WorkflowResourceName string + WorkflowTriggerServiceAccount string } // Get returns the global store @@ -174,105 +178,109 @@ func (s *Store) IsCustomDefURL(orgRepo string) bool { func init() { s.AddClusterJobName = "csdp-add-cluster-job-" + s.AnalysisRunResourceName = "analysisruns" + s.AnnotationKeySyncWave = "argocd.argoproj.io/sync-wave" + s.AppProxyIngressName = "-cap-app-proxy" + s.AppProxyIngressPath = "/app-proxy" + s.AppProxyServiceName = "cap-app-proxy" + s.ArgoCD = "argo-cd" s.ArgoCDServerName = "argocd-server" s.ArgoCDTokenKey = "token" s.ArgoCDTokenSecret = "argocd-token" s.ArgoWfIngressPath = "/workflows" s.ArgoWfServiceName = "argo-server" s.BinaryName = binaryName - s.Codefresh = "codefresh" - s.GitSourceName = "default-git-source" s.CFComponentType = "component" s.CFGitSourceType = "git-source" + s.CFInternalGitSources = []string{s.MarketplaceGitSourceName} + s.CFInternalReporters = []string{s.EventsReporterName, s.WorkflowReporterName, s.RolloutReporterName} s.CFRuntimeDefType = "runtimeDef" s.CFRuntimeType = "runtime" + s.CFStoreIVSecretKey = "encryptionIV" s.CFTokenSecret = "codefresh-token" s.CFTokenSecretKey = "token" - s.CFStoreIVSecretKey = "encryptionIV" + s.CLIDownloadTemplate = "https://github.com/codefresh-io/cli-v2/releases/download/%s/cf-%s-%s.tar.gz" + s.CLILatestVersionFileLink = "https://github.com/codefresh-io/cli-v2/releases/latest/download/version.txt" + s.ClusterResourcesPath = "/bootstrap/cluster-resources.yaml" + s.Codefresh = "codefresh" s.CodefreshCM = "codefresh-cm" s.CodefreshSA = "codefresh-sa" s.ComponentsReporterName = "components-reporter" s.ComponentsReporterSA = "components-reporter-sa" s.DefaultAPI = "https://g.codefresh.io" + s.DefaultNamespace = "default" + s.DemoCalendarDependencyName = "calendar-dep" + s.DemoCalendarEventName = "example-with-interval" + s.DemoCalendarEventSourceFileName = "calendar.event-source.yaml" + s.DemoCalendarEventSourceObjectName = "calendar" + s.DemoCalendarSensorFileName = "calendar.sensor.yaml" + s.DemoCalendarSensorObjectName = "calendar" + s.DemoGitDependencyName = "push-commit" + s.DemoGitEventName = "push-commit" + s.DemoGitEventSourceFileName = "push-commit.event-source.yaml" + s.DemoGitEventSourceObjectName = "push-commit" + s.DemoGitEventSourceServicePort = 80 + s.DemoGitEventSourceTargetPort = "80" + s.DemoGitSensorFileName = "push-commit.sensor.yaml" + s.DemoGitSensorObjectName = "push-commit" + s.DemoGitTriggerTemplateName = "push-commit" + s.DemoWorkflowTemplateFileName = "echo-message.workflow-template.yaml" + s.DemoWorkflowTemplateName = "echo-message" + s.DocsLink = "https://codefresh.io/csdp-docs/" + s.DownloadCliLink = "https://codefresh.io/csdp-docs/docs/clients/csdp-cli/" s.EventBusName = "codefresh-eventbus" s.EventReportingEndpoint = "/2.0/api/events" s.EventsReporterName = "events-reporter" - s.WebhooksIngressPath = "/webhooks" + s.GithubEventTypeHeader = "X-GitHub-Event" + s.GitlabEventTypeHeader = "X-Gitlab-Event" + s.GitSourceName = "default-git-source" + s.GitTokenSecretKey = "git_token" + s.GitTokenSecretObjectName = "autopilot-secret" + s.GitTokensLink = "https://codefresh.io/csdp-docs/docs/reference/git-tokens/" + s.InClusterName = "in-cluster" + s.InClusterServerURL = "https://kubernetes.default.svc" + s.InClusterPath = "/bootstrap/cluster-resources/in-cluster" + s.InternalRouterIngressFilePath = "internal-router" s.InternalRouterIngressName = "-internal-router-ingress" s.InternalRouterInternalIngressName = "-internal-router-internal-ingress" - s.InternalRouterIngressFilePath = "internal-router" s.InternalRouterServiceName = "internal-router" s.InternalRouterServicePort = 80 - s.AppProxyIngressName = "-cap-app-proxy" - s.AppProxyIngressPath = "/app-proxy" - s.AppProxyServiceName = "cap-app-proxy" - s.DocsLink = "https://codefresh.io/csdp-docs/" - s.LabelKeyCFType = "codefresh.io/entity" + s.IscRuntimesDir = "runtimes" + s.KubeVersionConstrint, _ = semver.NewConstraint("1.21-0 - 1.28-0") + s.LabelFieldCFType = "codefresh_io_entity" s.LabelKeyCFInternal = "codefresh.io/internal" + s.LabelKeyCFType = "codefresh.io/entity" + s.LabelGitIntegrationTypeKey = "io.codefresh.integration-type" + s.LabelGitIntegrationTypeValue = "git" + s.LabelSelectorGitIntegrationSecret = fmt.Sprintf("%s=%s", s.LabelGitIntegrationTypeKey, s.LabelGitIntegrationTypeValue) s.LabelSelectorSealedSecret = "codefresh.io/sealing-key=true" - s.LabelSelectorGitIntegrationSecret = "io.codefresh.integration-type=git" - s.AnnotationKeySyncWave = "argocd.argoproj.io/sync-wave" - s.MaxDefVersion = semver.MustParse(maxDefVersion) s.LastRuntimeVersionInCLI = semver.MustParse(lastRuntimeVersionInCLI) - s.RuntimeDefURL = RuntimeDefURL - s.OldRuntimeDefURL = OldRuntimeDefURL s.MarketplaceGitSourceName = "marketplace-git-source" s.MarketplaceRepo = "https://github.com/codefresh-io/argo-hub.git" - s.WaitTimeout = 8 * time.Minute - s.WorkflowName = "workflow" - s.WorkflowReporterName = "workflow-reporter" - s.WorkflowTriggerServiceAccount = "argo" - s.DemoCalendarEventSourceFileName = "calendar.event-source.yaml" - s.DemoCalendarSensorObjectName = "calendar" - s.DemoCalendarSensorFileName = "calendar.sensor.yaml" - s.DemoCalendarEventSourceObjectName = "calendar" - s.DemoCalendarEventName = "example-with-interval" - s.DemoCalendarDependencyName = "calendar-dep" - s.DemoWorkflowTemplateFileName = "echo-message.workflow-template.yaml" - s.DemoWorkflowTemplateName = "echo-message" - s.DemoGitEventSourceFileName = "push-commit.event-source.yaml" - s.DemoGitEventSourceObjectName = "push-commit" - s.WebhooksRootPath = "/webhooks" - s.DemoGitEventSourceTargetPort = "80" - s.DemoGitEventSourceServicePort = 80 - s.DemoGitSensorFileName = "push-commit.sensor.yaml" - s.DemoGitSensorObjectName = "push-commit" - s.DemoGitEventName = "push-commit" - s.DemoGitTriggerTemplateName = "push-commit" - s.DemoGitDependencyName = "push-commit" - s.GitTokenSecretObjectName = "autopilot-secret" - s.GitTokenSecretKey = "git_token" - s.GithubEventTypeHeader = "X-GitHub-Event" - s.GitlabEventTypeHeader = "X-Gitlab-Event" - s.ArgoCD = "argo-cd" - s.RolloutResourceName = "rollouts" - s.ReplicaSetResourceName = "replicasets" - s.AnalysisRunResourceName = "analysisruns" - s.MinimumMemorySizeRequired = "5000" + s.MasterIngressName = "-master" + s.MaxDefVersion = semver.MustParse(maxDefVersion) s.MinimumCpuRequired = "2" - s.WorkflowResourceName = "workflows" - s.RolloutReporterName = "rollout-reporter" - s.RolloutReporterServiceAccount = "rollout-reporter-sa" - s.RequirementsLink = "https://codefresh.io/csdp-docs/docs/runtime/requirements/" - s.GitTokensLink = "https://codefresh.io/csdp-docs/docs/reference/git-tokens/" - s.DownloadCliLink = "https://codefresh.io/csdp-docs/docs/clients/csdp-cli/" - s.CLIDownloadTemplate = "https://github.com/codefresh-io/cli-v2/releases/download/%s/cf-%s-%s.tar.gz" - s.CLILatestVersionFileLink = "https://github.com/codefresh-io/cli-v2/releases/latest/download/version.txt" - s.DefaultNamespace = "default" - s.NetworkTesterName = "cf-network-tester" + s.MinimumMemorySizeRequired = "5000" s.NetworkTesterGenerateName = "cf-network-tester-" s.NetworkTesterImage = "quay.io/codefresh/cf-venona-network-tester:latest" + s.NetworkTesterName = "cf-network-tester" + s.OldRuntimeDefURL = OldRuntimeDefURL + s.ReplicaSetResourceName = "replicasets" + s.RequirementsLink = "https://codefresh.io/csdp-docs/docs/runtime/requirements/" + s.RolloutReporterName = "rollout-reporter" + s.RolloutReporterServiceAccount = "rollout-reporter-sa" + s.RolloutResourceName = "rollouts" + s.RuntimeDefURL = RuntimeDefURL + s.SccName = "cf-scc" s.TCPConnectionTesterGenerateName = "cf-tcp-connections-tester-" s.TCPConnectionTesterName = "cf-tcp-connections-tester" - s.KubeVersionConstrint, _ = semver.NewConstraint("1.21-0 - 1.26-0") - s.MasterIngressName = "-master" - s.ClusterResourcesPath = "/bootstrap/cluster-resources.yaml" - s.InClusterPath = "/bootstrap/cluster-resources/in-cluster" - s.SccName = "cf-scc" - s.CFInternalGitSources = []string{s.MarketplaceGitSourceName} - s.CFInternalReporters = []string{s.EventsReporterName, s.WorkflowReporterName, s.RolloutReporterName} - s.InCluster = "https://kubernetes.default.svc" - s.IscRuntimesDir = "runtimes" + s.WaitTimeout = 8 * time.Minute + s.WebhooksIngressPath = "/webhooks" + s.WebhooksRootPath = "/webhooks" + s.WorkflowName = "workflow" + s.WorkflowReporterName = "workflow-reporter" + s.WorkflowResourceName = "workflows" + s.WorkflowTriggerServiceAccount = "argo" s.DefVersionToLastCLIVersion = map[string]string{ "1.0.0": "0.0.237", "1.0.1": "0.0.510", diff --git a/pkg/templates/argo-rollouts.tmpl b/pkg/templates/argo-rollouts.tmpl new file mode 100644 index 000000000..0c27968b2 --- /dev/null +++ b/pkg/templates/argo-rollouts.tmpl @@ -0,0 +1,25 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: {{ .AppName }} + labels: + codefresh.io/entity: component + codefresh.io/internal: "false" + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + chart: argo-rollouts + repoURL: {{ .RepoURL }} + targetRevision: {{ .TargetVersion }} + helm: + releaseName: argo-rollouts + destination: + namespace: default + name: {{ .ClusterName }} + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true diff --git a/pkg/templates/git-source.tmpl b/pkg/templates/git-source.tmpl new file mode 100644 index 000000000..7bc0be3ef --- /dev/null +++ b/pkg/templates/git-source.tmpl @@ -0,0 +1,37 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + annotations: + argocd.argoproj.io/sync-wave: '{{ index .Annotations "argocd_argoproj_io_sync_wave" }}' + finalizers: + - resources-finalizer.argocd.argoproj.io + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: '{{ .AppName }}' + codefresh.io/entity: '{{ index .Labels "codefresh_io_entity" }}' + codefresh.io/internal: '{{ index .Labels "codefresh_io_internal" }}' + name: '{{ .RuntimeName }}-{{ .UserGivenName }}' + namespace: runtime +spec: + destination: + namespace: '{{ .DestNamespace }}' + server: '{{ .DestServer }}' + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: default + source: + path: '{{ .SrcPath }}' + repoURL: '{{ .SrcRepoURL }}' + targetRevision: '{{ .SrcTargetRevision }}' + directory: + exclude: '{{ .Exclude }}' + include: '{{ .Include }}' + recurse: true + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true diff --git a/pkg/templates/rbac.tmpl b/pkg/templates/rbac.tmpl new file mode 100644 index 000000000..dfd80c754 --- /dev/null +++ b/pkg/templates/rbac.tmpl @@ -0,0 +1,30 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: codefresh-config-reader + namespace: {{ .Namespace }} +rules: +- apiGroups: + - "" + resourceNames: + - codefresh-cm + - codefresh-token + resources: + - configmaps + - secrets + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: codefresh-config-reader + namespace: {{ .Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: codefresh-config-reader +subjects: +- kind: ServiceAccount + name: default + namespace: {{ .Namespace }} diff --git a/pkg/templates/rollout-reporter.tmpl b/pkg/templates/rollout-reporter.tmpl new file mode 100644 index 000000000..441ecdc3d --- /dev/null +++ b/pkg/templates/rollout-reporter.tmpl @@ -0,0 +1,178 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Name }}-sa + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Name }}-role +rules: +- apiGroups: + - argoproj.io + resources: + - analysisruns + - rollouts + verbs: + - list + - watch +- apiGroups: + - apps + resources: + - replicasets + verbs: + - list + - watch +- apiGroups: + - "" + resources: + - secrets + - configmaps + verbs: + - get + - list + - watch + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Name }}-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Name }}-role +subjects: +- kind: ServiceAccount + namespace: {{ .Namespace }} + name: {{ .Name }}-sa + +--- +apiVersion: argoproj.io/v1alpha1 +kind: EventSource +metadata: + name: {{ .Name }} + labels: + app.kubernetes.io/managed-by: cf +spec: + eventBusName: codefresh-eventbus + resource: + analysisruns: + cluster: {{ .ClusterName }} + group: argoproj.io + version: v1alpha1 + resource: analysisruns + eventTypes: + - ADD + - UPDATE + - DELETE + replicasets: + cluster: {{ .ClusterName }} + group: apps + version: v1 + resource: replicasets + eventTypes: + - ADD + - UPDATE + - DELETE + rollouts: + cluster: {{ .ClusterName }} + group: argoproj.io + version: v1alpha1 + resource: rollouts + eventTypes: + - ADD + - UPDATE + - DELETE + template: + serviceAccountName: {{ .Name }}-sa + +--- +apiVersion: argoproj.io/v1alpha1 +kind: Sensor +metadata: + name: {{ .Name }} + labels: + app.kubernetes.io/managed-by: cf +spec: + dependencies: + - name: analysisruns + eventSourceName: {{ .Name }} + eventName: analysisruns + - name: replicasets + eventSourceName: {{ .Name }} + eventName: replicasets + - name: rollouts + eventSourceName: {{ .Name }} + eventName: rollouts + eventBusName: codefresh-eventbus + template: + serviceAccountName: {{ .Name }}-sa + triggers: + - template: + name: rollouts + conditions: rollouts + http: + method: POST + url: {{ .EventEndpoint }} + headers: + Content-Type: application/json + secureHeaders: + - name: Authorization + valueFrom: + secretKeyRef: + key: token + name: codefresh-token + payload: + - dest: data.object + src: + dataKey: body + dependencyName: rollouts + retryStrategy: + duration: 0 + steps: 3 + - template: + name: replicasets + conditions: replicasets + http: + method: POST + url: {{ .EventEndpoint }} + headers: + Content-Type: application/json + secureHeaders: + - name: Authorization + valueFrom: + secretKeyRef: + key: token + name: codefresh-token + payload: + - dest: data.object + src: + dataKey: body + dependencyName: replicasets + retryStrategy: + duration: 0 + steps: 3 + - template: + name: analysisruns + conditions: analysisruns + http: + method: POST + url: {{ .EventEndpoint }} + headers: + Content-Type: application/json + secureHeaders: + - name: Authorization + valueFrom: + secretKeyRef: + key: token + name: codefresh-token + payload: + - dest: data.object + src: + dataKey: body + dependencyName: analysisruns + retryStrategy: + duration: 0 + steps: 3 diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go new file mode 100644 index 000000000..f0a365510 --- /dev/null +++ b/pkg/templates/templates.go @@ -0,0 +1,95 @@ +// Copyright 2023 The Codefresh Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package templates + +import ( + "bytes" + _ "embed" + "html/template" + + apapp "github.com/argoproj-labs/argocd-autopilot/pkg/application" +) + +type ( + ArgoRolloutsConfig struct { + AppName string + ClusterName string + RepoURL string + TargetVersion string + } + + GitSourceConfig struct { + apapp.Config + + Exclude string `json:"exclude"` + Include string `json:"include"` + RuntimeName string // not coming from json + } + + RbacConfig struct { + Namespace string + } + + RolloutReporterConfig struct { + Name string + Namespace string + ClusterName string + EventEndpoint string + } +) + +var ( + //go:embed argo-rollouts.tmpl + argoRolloutsTmplStr string + argoRolloutsTemplate = template.Must(template.New("argo-rollouts").Parse(argoRolloutsTmplStr)) + + //go:embed git-source.tmpl + gitSourceTmplStr string + gitSourceTemplate = template.Must(template.New("git-source").Parse(gitSourceTmplStr)) + + //go:embed rbac.tmpl + rbacTmplStr string + rbabTemplate = template.Must(template.New("git-source").Parse(rbacTmplStr)) + + //go:embed rollout-reporter.tmpl + rolloutReporterTmplStr string + rolloutReporterTemplate = template.Must(template.New("rollout-reporter").Parse(rolloutReporterTmplStr)) +) + +func RenderArgoRollouts(config *ArgoRolloutsConfig) ([]byte, error) { + return renderTemplate(argoRolloutsTemplate, config) +} + +func RenderGitSource(config *GitSourceConfig) ([]byte, error) { + return renderTemplate(gitSourceTemplate, config) +} + +func RenderRBAC(config *RbacConfig) ([]byte, error) { + return renderTemplate(rbabTemplate, config) +} + +func RenderRolloutReporter(config *RolloutReporterConfig) ([]byte, error) { + return renderTemplate(rolloutReporterTemplate, config) +} + +func renderTemplate(t *template.Template, data any) ([]byte, error) { + var b bytes.Buffer + err := t.Execute(&b, data) + if err != nil { + return nil, err + } + + return b.Bytes(), nil +} diff --git a/pkg/util/aputil/aputil.go b/pkg/util/aputil/aputil.go index 1506afc2f..374d1aeca 100644 --- a/pkg/util/aputil/aputil.go +++ b/pkg/util/aputil/aputil.go @@ -43,21 +43,21 @@ type CloneFlagsOptions struct { Progress io.Writer } -func AddCloneFlags(cmd *cobra.Command, o *CloneFlagsOptions) *apgit.CloneOptions { - opts := apgit.AddFlags(cmd, &apgit.AddFlagsOptions{ +func AddCloneFlags(cmd *cobra.Command, opts *CloneFlagsOptions) *apgit.CloneOptions { + co := apgit.AddFlags(cmd, &apgit.AddFlagsOptions{ FS: memfs.New(), - Prefix: o.Prefix, - CreateIfNotExist: o.CreateIfNotExist, - CloneForWrite: o.CloneForWrite, - Optional: o.Optional, + Prefix: opts.Prefix, + CreateIfNotExist: opts.CreateIfNotExist, + CloneForWrite: opts.CloneForWrite, + Optional: opts.Optional, }) - opts.Progress = o.Progress - if opts.Progress == nil { - opts.Progress = io.Discard + co.Progress = opts.Progress + if co.Progress == nil { + co.Progress = io.Discard } - return opts + return co } func PushWithMessage(ctx context.Context, r apgit.Repository, msg string) error { @@ -105,3 +105,11 @@ func ConfigureLoggerOrDie(cmd *cobra.Command) { util.Die(logger.Configure()) aplog.L = logger } + +func AddRepoFlags(cmd *cobra.Command, opts *CloneFlagsOptions) *apgit.CloneOptions { + co := AddCloneFlags(cmd, opts) + util.Die(cmd.PersistentFlags().MarkHidden(opts.Prefix + "repo")) + util.Die(cmd.PersistentFlags().MarkHidden(opts.Prefix + "upsert-branch")) + util.Die(cmd.PersistentFlags().SetAnnotation(opts.Prefix+"repo", cobra.BashCompOneRequiredFlag, []string{"false"})) + return co +} diff --git a/pkg/util/helm/helm.go b/pkg/util/helm/helm.go index 0fb0553d3..361e9a6f7 100644 --- a/pkg/util/helm/helm.go +++ b/pkg/util/helm/helm.go @@ -18,13 +18,13 @@ import ( "fmt" "github.com/codefresh-io/cli-v2/pkg/util" - "github.com/spf13/pflag" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/cli" + "helm.sh/helm/v3/pkg/registry" ) //go:generate mockgen -destination=./mocks/helm.go -package=helm -source=./helm.go Helm @@ -32,26 +32,35 @@ import ( type ( Helm interface { GetValues(valuesFile string, loadFromChart bool) (chartutil.Values, error) + GetDependency(name string) (string, string, error) } helmImpl struct { - devel bool - chartPathOpts *action.ChartPathOptions + chart string + devel bool + install *action.Install } ) -func AddFlags(flags *pflag.FlagSet) Helm { +func AddFlags(flags *pflag.FlagSet) (Helm, error) { + client, err := registry.NewClient() + if err != nil { + return nil, err + } + helm := &helmImpl{ - chartPathOpts: &action.ChartPathOptions{}, + install: action.NewInstall(&action.Configuration{ + RegistryClient: client, + }), } flags.BoolVar(&helm.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") - flags.StringVar(&helm.chartPathOpts.Version, "version", "", "specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used") - flags.StringVar(&helm.chartPathOpts.RepoURL, "repo", "https://chartmuseum.codefresh.io/gitops-runtime", "chart repository url where to locate the requested chart") + flags.StringVar(&helm.install.ChartPathOptions.Version, "version", "", "specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used") + flags.StringVar(&helm.chart, "chart", "oci://quay.io/codefresh/gitops-runtime", "chart oci url [oci://quay.io/codefresh/gitops-runtime]") - util.Die(flags.MarkHidden("repo")) + util.Die(flags.MarkHidden("chart")) - return helm + return helm, nil } func (h *helmImpl) GetValues(valuesFile string, loadFromChart bool) (chartutil.Values, error) { @@ -64,10 +73,6 @@ func (h *helmImpl) GetValues(valuesFile string, loadFromChart bool) (chartutil.V return values, nil } - if h.chartPathOpts.Version == "" && h.devel { - h.chartPathOpts.Version = ">0.0.0-0" - } - chart, err := h.loadHelmChart() if err != nil { return nil, err @@ -76,8 +81,28 @@ func (h *helmImpl) GetValues(valuesFile string, loadFromChart bool) (chartutil.V return chartutil.CoalesceValues(chart, values) } +func (h *helmImpl) GetDependency(name string) (string, string, error) { + chart, err := h.loadHelmChart() + if err != nil { + return "", "", err + } + + for _, dep := range chart.Metadata.Dependencies { + if dep.Name == name { + return dep.Repository, dep.Version, nil + } + } + + return "", "", fmt.Errorf("dependency %q not found", name) +} + func (h *helmImpl) loadHelmChart() (*chart.Chart, error) { - cp, err := h.chartPathOpts.LocateChart("gitops-runtime", cli.New()) + if h.install.ChartPathOptions.Version == "" && h.devel { + h.install.ChartPathOptions.Version = ">0.0.0-0" + } + + settings := cli.New() + cp, err := h.install.LocateChart(h.chart, settings) if err != nil { return nil, err } diff --git a/pkg/util/helm/mocks/helm.go b/pkg/util/helm/mocks/helm.go index 611873d30..2f1e6a8ae 100644 --- a/pkg/util/helm/mocks/helm.go +++ b/pkg/util/helm/mocks/helm.go @@ -48,6 +48,22 @@ func (m *MockHelm) EXPECT() *MockHelmMockRecorder { return m.recorder } +// GetDependency mocks base method. +func (m *MockHelm) GetDependency(name string) (string, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDependency", name) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetDependency indicates an expected call of GetDependency. +func (mr *MockHelmMockRecorder) GetDependency(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDependency", reflect.TypeOf((*MockHelm)(nil).GetDependency), name) +} + // GetValues mocks base method. func (m *MockHelm) GetValues(valuesFile string, loadFromChart bool) (chartutil.Values, error) { m.ctrl.T.Helper() diff --git a/pkg/util/kube/kube.go b/pkg/util/kube/kube.go index 98592b83b..732cd14ca 100644 --- a/pkg/util/kube/kube.go +++ b/pkg/util/kube/kube.go @@ -37,6 +37,7 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" ) @@ -690,3 +691,12 @@ func GetIngressClass(ctx context.Context, kubeFactory apkube.Factory, name strin cs := GetClientSetOrDie(kubeFactory) return cs.NetworkingV1().IngressClasses().Get(ctx, name, metav1.GetOptions{}) } + +func GetDynamicClientOrDie(kubeFactory apkube.Factory) dynamic.Interface { + restConfig, err := kubeFactory.ToRESTConfig() + if err != nil { + panic(err) + } + + return dynamic.NewForConfigOrDie(restConfig) +} diff --git a/pkg/util/openshift/util.go b/pkg/util/openshift/util.go index 9296b4c76..805d258a7 100644 --- a/pkg/util/openshift/util.go +++ b/pkg/util/openshift/util.go @@ -99,7 +99,7 @@ func createScc(ctx context.Context, opts *OpenshiftOptions) error { Priority: &sccPriority, } - clusterResourcesDir := fs.Join(apstore.Default.BootsrtrapDir, apstore.Default.ClusterResourcesDir, "in-cluster") + clusterResourcesDir := fs.Join(apstore.Default.BootsrtrapDir, apstore.Default.ClusterResourcesDir, store.Get().InClusterName) if err = fs.WriteYamls(fs.Join(clusterResourcesDir, "scc.yaml"), scc); err != nil { return err diff --git a/pkg/util/routing/gatewayapi.go b/pkg/util/routing/gatewayapi.go index e59717cd1..ad2ebd1dd 100644 --- a/pkg/util/routing/gatewayapi.go +++ b/pkg/util/routing/gatewayapi.go @@ -19,12 +19,12 @@ import ( "fmt" "github.com/codefresh-io/cli-v2/pkg/log" + "github.com/codefresh-io/cli-v2/pkg/util/kube" httproute "github.com/codefresh-io/cli-v2/pkg/util/routing/types" apkkube "github.com/argoproj-labs/argocd-autopilot/pkg/kube" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic" ) type ( @@ -115,7 +115,7 @@ var SupportedGatewayControllers = []gatewayControllerType{GatewayControllerConto func ValidateGatewayController(ctx context.Context, kubeFactory apkkube.Factory, gatewayName, gatewayNamespace string) (RoutingController, error) { // Get Gateway - cs := getClientsetOrDie(kubeFactory) + cs := kube.GetDynamicClientOrDie(kubeFactory) gatewayResourceId := schema.GroupVersionResource{ Group: "gateway.networking.k8s.io", Version: "v1beta1", @@ -149,36 +149,3 @@ func ValidateGatewayController(ctx context.Context, kubeFactory apkkube.Factory, return nil, fmt.Errorf("Gateway controller %s is not supported", gatewayController) } - -//func routePathsToHTTPRouteRules(routePaths []RoutePath) []HTTPRouteRule { -// var httpRouteRules []HTTPRouteRule -// for _, path := range routePaths { -// var ingressPathType httproute.PathMatchType -// switch pathType := path.pathType; pathType { -// case ExactPath: -// ingressPathType = httproute.PathMatchExact -// case PrefixPath: -// ingressPathType = httproute.PathMatchPathPrefix -// case RegexPath: -// ingressPathType = httproute.PathMatchRegularExpression -// } -// -// httpRouteRules = append(httpRouteRules, HTTPRouteRule{ -// ServiceName: path.serviceName, -// ServicePort: int32(path.servicePort), -// Path: path.path, -// PathType: ingressPathType, -// }) -// } -// -// return httpRouteRules -//} - -func getClientsetOrDie(kubeFactory apkkube.Factory) dynamic.Interface { - restConfig, err := kubeFactory.ToRESTConfig() - if err != nil { - panic(err) - } - - return dynamic.NewForConfigOrDie(restConfig) -}