diff --git a/Makefile b/Makefile index 4cfda7eda..f51fa3c1c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.0.569 +VERSION=v0.1.0 OUT_DIR=dist YEAR?=$(shell date +"%Y") @@ -7,11 +7,12 @@ CLI_NAME?=cf IMAGE_REPOSITORY?=quay.io IMAGE_NAMESPACE?=codefresh -RUNTIME_DEF_URL="https://github.com/codefresh-io/cli-v2/releases/latest/download/runtime.yaml" +RUNTIME_DEF_URL="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml" ADD_CLUSTER_DEF_URL="https://github.com/codefresh-io/csdp-official/add-cluster/kustomize" FALLBACK_ADD_CLUSTER_DEF_URL="https://github.com/codefresh-io/cli-v2/manifests/add-cluster/kustomize" -DEV_RUNTIME_DEF_URL="manifests/runtime.yaml" +# when developing, point this to your local clone of csdp-official +DEV_RUNTIME_DEF_URL="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml" DEV_ADD_CLUSTER_DEF_URL="https://github.com/codefresh-io/csdp-official/add-cluster/kustomize" # specify dev branch using ?ref= here if you want to test a change CLI_SRCS := $(shell find . -name '*.go') diff --git a/cmd/commands/git-source.go b/cmd/commands/git-source.go index 8ed01f258..970a6f273 100644 --- a/cmd/commands/git-source.go +++ b/cmd/commands/git-source.go @@ -27,7 +27,6 @@ import ( "github.com/codefresh-io/cli-v2/pkg/store" "github.com/codefresh-io/cli-v2/pkg/util" apu "github.com/codefresh-io/cli-v2/pkg/util/aputil" - eventsutil "github.com/codefresh-io/cli-v2/pkg/util/events" routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing" wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow" @@ -1161,10 +1160,6 @@ func createDemoGitlabSensor() *sensorsv1alpha1.Sensor { func createDemoEventSource(name string) *eventsourcev1alpha1.EventSource { tpl := &eventsourcev1alpha1.Template{Container: &corev1.Container{}} - if store.Get().SetDefaultResources { - eventsutil.SetDefaultResourceRequirements(tpl.Container) - } - return &eventsourcev1alpha1.EventSource{ TypeMeta: metav1.TypeMeta{ Kind: eventsourcereg.Kind, @@ -1186,10 +1181,6 @@ func createDemoSensor(name string, triggers []sensorsv1alpha1.Trigger, dependenc ServiceAccountName: store.Get().WorkflowTriggerServiceAccount, } - if store.Get().SetDefaultResources { - eventsutil.SetDefaultResourceRequirements(tpl.Container) - } - return &sensorsv1alpha1.Sensor{ TypeMeta: metav1.TypeMeta{ Kind: sensorreg.Kind, diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index a9ff12121..5821a3d09 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -768,7 +768,6 @@ func deleteRuntimeFromPlatform(ctx context.Context, opts *RuntimeUninstallOption func NewRuntimeUpgradeCommand() *cobra.Command { var ( - versionStr string finalParameters map[string]string opts = &RuntimeUpgradeOptions{ featuresToInstall: make([]runtime.InstallFeature, 0), @@ -813,8 +812,12 @@ func NewRuntimeUpgradeCommand() *cobra.Command { "Repository URL": opts.CloneOpts.Repo, } - if versionStr != "" { - finalParameters["Version"] = versionStr + if opts.versionStr != "" { + finalParameters["Version"] = opts.versionStr + } + + if opts.runtimeDef == "" { + opts.runtimeDef = runtime.GetRuntimeDefURL(opts.versionStr) } err = validateVersionIfExists(opts.versionStr) @@ -844,15 +847,15 @@ func NewRuntimeUpgradeCommand() *cobra.Command { }, } - cmd.Flags().StringVar(&opts.versionStr, "version", "", "The runtime version to upgrade to, defaults to latest") + cmd.Flags().StringVar(&opts.versionStr, "version", "", "The runtime version to upgrade to, defaults to stable") cmd.Flags().StringVar(&opts.SuggestedSharedConfigRepo, "shared-config-repo", "", "URL to the shared configurations repo. (default: or the existing one for this account)") cmd.Flags().BoolVar(&opts.DisableTelemetry, "disable-telemetry", false, "If true, will disable analytics reporting for the upgrade process") cmd.Flags().BoolVar(&store.Get().SetDefaultResources, "set-default-resources", false, "If true, will set default requests and limits on all of the runtime components") - cmd.Flags().StringVar(&opts.runtimeDef, "runtime-def", store.RuntimeDefURL, "Install runtime from a specific manifest") + cmd.Flags().StringVar(&opts.runtimeDef, "runtime-def", "", "Install runtime from a specific manifest") cmd.Flags().BoolVar(&opts.SkipIngress, "skip-ingress", false, "Skips the creation of ingress resources") opts.CloneOpts = apu.AddCloneFlags(cmd, &apu.CloneFlagsOptions{CloneForWrite: true}) - util.Die(cmd.Flags().MarkHidden("runtime-def")) + util.Die(cmd.Flags().MarkHidden("set-default-resources")) cmd.MarkFlagsMutuallyExclusive("version", "runtime-def") return cmd @@ -870,7 +873,7 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error { return fmt.Errorf("failed to download runtime definition: %w", err) } - if newRt.Spec.DefVersion.GreaterThan(store.Get().MaxDefVersion) { + if newRt.Spec.DefVersion != nil && newRt.Spec.DefVersion.GreaterThan(store.Get().MaxDefVersion) { err = fmt.Errorf("please upgrade your cli version before upgrading to %s", newRt.Spec.Version) } handleCliStep(reporter.UpgradeStepRunPreCheckEnsureCliVersion, "Checking CLI version", err, true, false) @@ -878,6 +881,11 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error { return err } + err = runtime.CheckRuntimeVersionCompatible(newRt.Spec.RequiredCLIVersion) + if err != nil { + return err + } + log.G(ctx).Info("Cloning installation repository") r, fs, err := opts.CloneOpts.GetRepo(ctx) handleCliStep(reporter.UpgradeStepGetRepo, "Getting repository", err, true, false) diff --git a/cmd/commands/runtime_install.go b/cmd/commands/runtime_install.go index fbe07815b..adc2926e5 100644 --- a/cmd/commands/runtime_install.go +++ b/cmd/commands/runtime_install.go @@ -222,6 +222,10 @@ func NewRuntimeInstallCommand() *cobra.Command { return util.DecorateErrorWithDocsLink(fmt.Errorf("pre installation error: %w", err), store.Get().RequirementsLink) } + if installationOpts.runtimeDef == "" { + installationOpts.runtimeDef = runtime.GetRuntimeDefURL(installationOpts.versionStr) + } + finalParameters = map[string]string{ "Codefresh context": cfConfig.CurrentContext, "Kube context": installationOpts.kubeContext, @@ -253,7 +257,7 @@ func NewRuntimeInstallCommand() *cobra.Command { cmd.Flags().StringVar(&installationOpts.GatewayNamespace, "gateway-namespace", "", "The namespace of the gateway") cmd.Flags().StringVar(&installationOpts.GitIntegrationRegistrationOpts.Token, "personal-git-token", "", "The Personal git token for your user") cmd.Flags().StringVar(&installationOpts.GitIntegrationRegistrationOpts.Username, "personal-git-user", "", "The Personal git user that match the token, required for bitbucket cloud") - cmd.Flags().StringVar(&installationOpts.versionStr, "version", "", "The runtime version to install (default: latest)") + cmd.Flags().StringVar(&installationOpts.versionStr, "version", "", "The runtime version to install (default: stable)") cmd.Flags().StringVar(&installationOpts.SuggestedSharedConfigRepo, "shared-config-repo", "", "URL to the shared configurations repo. (default: or the existing one for this account)") cmd.Flags().BoolVar(&installationOpts.InstallDemoResources, "demo-resources", true, "Installs demo resources (default: true)") cmd.Flags().BoolVar(&installationOpts.SkipClusterChecks, "skip-cluster-checks", false, "Skips the cluster's checks") @@ -268,7 +272,7 @@ func NewRuntimeInstallCommand() *cobra.Command { cmd.Flags().StringToStringVar(&installationOpts.NamespaceLabels, "namespace-labels", nil, "Optional labels that will be set on the namespace resource. (e.g. \"key1=value1,key2=value2\"") cmd.Flags().StringToStringVar(&installationOpts.InternalIngressAnnotation, "internal-ingress-annotation", nil, "Add annotations to the internal ingress") cmd.Flags().StringToStringVar(&installationOpts.ExternalIngressAnnotation, "external-ingress-annotation", nil, "Add annotations to the external ingress") - cmd.Flags().StringVar(&installationOpts.runtimeDef, "runtime-def", store.RuntimeDefURL, "Install runtime from a specific manifest") + cmd.Flags().StringVar(&installationOpts.runtimeDef, "runtime-def", "", "Install runtime from a specific manifest") cmd.Flags().StringVar(&accessMode, "access-mode", string(platmodel.AccessModeIngress), "The access mode to the cluster, one of: ingress|tunnel") cmd.Flags().StringVar(&installationOpts.TunnelRegisterHost, "tunnel-register-host", "register-tunnels.cf-cd.com", "The host name for registering a new tunnel") cmd.Flags().StringVar(&installationOpts.TunnelDomain, "tunnel-domain", "tunnels.cf-cd.com", "The base domain for the tunnels") @@ -293,6 +297,7 @@ func NewRuntimeInstallCommand() *cobra.Command { util.Die(cmd.Flags().MarkHidden("tunnel-domain")) util.Die(cmd.Flags().MarkHidden("ips-allow-list")) util.Die(cmd.Flags().MarkHidden("runtime-def")) + util.Die(cmd.Flags().MarkHidden("set-default-resources")) cmd.MarkFlagsMutuallyExclusive("runtime-def", "version") cmd.MarkFlagsMutuallyExclusive("runtime-def", "set-default-resources") @@ -1141,8 +1146,15 @@ func preInstallationChecks(ctx context.Context, opts *RuntimeInstallOptions) (*r return nil, fmt.Errorf("failed to download runtime definition: %w", err) } - if rt.Spec.DefVersion.GreaterThan(store.Get().MaxDefVersion) { - err = fmt.Errorf("your cli version is out of date. please upgrade to the latest version before installing") + if rt.Spec.DefVersion != nil { + if rt.Spec.DefVersion.GreaterThan(store.Get().MaxDefVersion) { + err = fmt.Errorf("your cli version is out of date. please upgrade to the latest version before installing") + } else if rt.Spec.DefVersion.LessThan(store.Get().MaxDefVersion) { + val := store.Get().DefVersionToLastCLIVersion[rt.Spec.DefVersion.String()] + err = fmt.Errorf("to install this version, please downgrade your cli to version %s", val) + } + } else { + err = runtime.CheckRuntimeVersionCompatible(rt.Spec.RequiredCLIVersion) } handleCliStep(reporter.InstallStepRunPreCheckEnsureCliVersion, "Checking CLI version", err, true, false) @@ -2115,7 +2127,7 @@ func (opts *RuntimeInstallOptions) shouldInstallIngress() bool { } func (opts *RuntimeInstallOptions) IsCustomInstall() bool { - return opts.runtimeDef != store.RuntimeDefURL + return opts.runtimeDef != store.RuntimeDefURL && opts.runtimeDef != store.OldRuntimeDefURL } func getRuntimeDef(runtimeDef, versionStr string) string { @@ -2135,6 +2147,9 @@ func getRuntimeDef(runtimeDef, versionStr string) string { return runtimeDef } - // specific version means the runtimeDef is the default value in cli-v2 repo - return strings.Replace(runtimeDef, "/releases/latest/download", "/releases/download/v"+version.String(), 1) + // specific version means the runtimeDef is the default value in cli-v2/csdp-official repo + if strings.Contains(runtimeDef, "cli-v2") { + return strings.Replace(runtimeDef, "/releases/latest/download", "/releases/download/v"+version.String(), 1) + } + return runtimeDef + "?ref=v" + version.String() } diff --git a/docs/commands/cli-v2_runtime_install.md b/docs/commands/cli-v2_runtime_install.md index ae64f2369..1d855b5f1 100644 --- a/docs/commands/cli-v2_runtime_install.md +++ b/docs/commands/cli-v2_runtime_install.md @@ -51,12 +51,11 @@ cli-v2 runtime install [runtime_name] [flags] --provider string The git provider, one of: azure|bitbucket|bitbucket-server|gitea|github|gitlab --provider-api-url string Git provider API url --repo string Repository URL [GIT_REPO] - --set-default-resources If true, will set default requests and limits on all of the runtime components --shared-config-repo string URL to the shared configurations repo. (default: or the existing one for this account) --skip-cluster-checks Skips the cluster's checks --skip-ingress Skips the creation of ingress resources -b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist - --version string The runtime version to install (default: latest) + --version string The runtime version to install (default: stable) --wait-timeout duration How long to wait for the runtime components to be ready (default 8m0s) ``` diff --git a/docs/commands/cli-v2_runtime_upgrade.md b/docs/commands/cli-v2_runtime_upgrade.md index af3278b41..a17422d8c 100644 --- a/docs/commands/cli-v2_runtime_upgrade.md +++ b/docs/commands/cli-v2_runtime_upgrade.md @@ -33,11 +33,10 @@ cli-v2 runtime upgrade [RUNTIME_NAME] [flags] -u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub) -h, --help help for upgrade --repo string Repository URL [GIT_REPO] - --set-default-resources If true, will set default requests and limits on all of the runtime components --shared-config-repo string URL to the shared configurations repo. (default: or the existing one for this account) --skip-ingress Skips the creation of ingress resources -b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist - --version string The runtime version to upgrade to, defaults to latest + --version string The runtime version to upgrade to, defaults to stable ``` ### Options inherited from parent commands diff --git a/docs/releases/release_notes.md b/docs/releases/release_notes.md index 48b971144..8b2ad31de 100644 --- a/docs/releases/release_notes.md +++ b/docs/releases/release_notes.md @@ -23,7 +23,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.569/cf-linux-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.0/cf-linux-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-linux-amd64 /usr/local/bin/cf @@ -36,7 +36,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.569/cf-darwin-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.0/cf-darwin-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-darwin-amd64 /usr/local/bin/cf diff --git a/hack/build.sh b/hack/build.sh index d8137f18e..c63b65fcd 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -16,6 +16,5 @@ go build -ldflags=" \ -X 'github.com/codefresh-io/cli-v2/pkg/store.RuntimeDefURL=${RUNTIME_DEF_URL}' \ -X 'github.com/codefresh-io/cli-v2/pkg/store.AddClusterDefURL=${ADD_CLUSTER_DEF_URL}' \ -X 'github.com/codefresh-io/cli-v2/pkg/store.FallbackAddClusterDefURL=${FALLBACK_ADD_CLUSTER_DEF_URL}' \ - -X 'github.com/codefresh-io/cli-v2/pkg/store.SegmentWriteKey=${SEGMENT_WRITE_KEY}' \ - -X 'github.com/codefresh-io/cli-v2/pkg/store.devMode=${DEV_MODE}'" \ + -X 'github.com/codefresh-io/cli-v2/pkg/store.SegmentWriteKey=${SEGMENT_WRITE_KEY}'" \ -v -o ${OUT_FILE} ${MAIN} diff --git a/hack/get-manifests-location.sh b/hack/get-manifests-location.sh new file mode 100755 index 000000000..53d4a5137 --- /dev/null +++ b/hack/get-manifests-location.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +REPO="https://github.com/codefresh-io/csdp-official" +BRANCH="$1" + +DEFAULT_MANIFESTS_LOCATION="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml" +CUSTOM_MANIFESTS_LOCATION="https://github.com/codefresh-io/csdp-official/csdp/hybrid/basic/runtime.yaml?ref=$BRANCH" + +git ls-remote --heads ${REPO} ${BRANCH} | grep ${BRANCH} >/dev/null + +if [ "$?" == "1" ]; then + # No matching branch was found in csdp-official + echo "$DEFAULT_MANIFESTS_LOCATION" + exit 0 +fi + +echo "$CUSTOM_MANIFESTS_LOCATION" diff --git a/manifests/default-resources/app-proxy/kustomization.yaml b/manifests/default-resources/app-proxy/kustomization.yaml deleted file mode 100644 index 2668f4ae2..000000000 --- a/manifests/default-resources/app-proxy/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../app-proxy diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-application-controller.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-application-controller.jsonpatch.yaml deleted file mode 100644 index 2a2895fb7..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-application-controller.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 3.5 - memory: 4Gi - requests: - cpu: 500m - memory: 500Mi diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-applicationset-controller.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-applicationset-controller.jsonpatch.yaml deleted file mode 100644 index 21dddb5a9..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-applicationset-controller.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 300m - memory: 200Mi - requests: - cpu: 150m - memory: 100Mi diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-dex-server.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-dex-server.jsonpatch.yaml deleted file mode 100644 index 33fe4a437..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-dex-server.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 150Mi - requests: - cpu: 50m - memory: 50Mi diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-redis.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-redis.jsonpatch.yaml deleted file mode 100644 index c7069c0b6..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-redis.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 256Mi - requests: - cpu: 50m - memory: 100Mi diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-repo-server.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-repo-server.jsonpatch.yaml deleted file mode 100644 index 800d7bc83..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-repo-server.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 200m - memory: 1.2Gi - requests: - cpu: 50m - memory: 500Mi diff --git a/manifests/default-resources/argo-cd/argocd-resources.argocd-server.jsonpatch.yaml b/manifests/default-resources/argo-cd/argocd-resources.argocd-server.jsonpatch.yaml deleted file mode 100644 index 5856def8e..000000000 --- a/manifests/default-resources/argo-cd/argocd-resources.argocd-server.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 500m - memory: 300Mi - requests: - cpu: 100m - memory: 150Mi diff --git a/manifests/default-resources/argo-cd/kustomization.yaml b/manifests/default-resources/argo-cd/kustomization.yaml deleted file mode 100644 index 488fabf77..000000000 --- a/manifests/default-resources/argo-cd/kustomization.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../argo-cd - -patches: - - path: argocd-resources.argocd-application-controller.jsonpatch.yaml - target: - name: argocd-application-controller - kind: StatefulSet - group: apps - version: v1 - - path: argocd-resources.argocd-applicationset-controller.jsonpatch.yaml - target: - name: argocd-applicationset-controller - kind: Deployment - group: apps - version: v1 - - path: argocd-resources.argocd-dex-server.jsonpatch.yaml - target: - name: argocd-dex-server - kind: Deployment - group: apps - version: v1 - - path: argocd-resources.argocd-redis.jsonpatch.yaml - target: - name: argocd-redis - kind: Deployment - group: apps - version: v1 - - path: argocd-resources.argocd-repo-server.jsonpatch.yaml - target: - name: argocd-repo-server - kind: Deployment - group: apps - version: v1 - - path: argocd-resources.argocd-server.jsonpatch.yaml - target: - name: argocd-server - kind: Deployment - group: apps - version: v1 diff --git a/manifests/default-resources/argo-events/eventbus-controller.jsonpatch.yaml b/manifests/default-resources/argo-events/eventbus-controller.jsonpatch.yaml deleted file mode 100644 index 75007db51..000000000 --- a/manifests/default-resources/argo-events/eventbus-controller.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 200Mi - requests: - cpu: 20m - memory: 100Mi diff --git a/manifests/default-resources/argo-events/eventbus.jsonpatch.yaml b/manifests/default-resources/argo-events/eventbus.jsonpatch.yaml deleted file mode 100644 index eb8b5c338..000000000 --- a/manifests/default-resources/argo-events/eventbus.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/nats/native/containerTemplate/resources - value: - limits: - cpu: 500m - memory: 8Gi - requests: - cpu: 200m - memory: 500Mi diff --git a/manifests/default-resources/argo-events/events-webhook.jsonpatch.yaml b/manifests/default-resources/argo-events/events-webhook.jsonpatch.yaml deleted file mode 100644 index b64289e14..000000000 --- a/manifests/default-resources/argo-events/events-webhook.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 200Mi - requests: - cpu: 20m - memory: 50Mi diff --git a/manifests/default-resources/argo-events/eventsource-controller.jsonpatch.yaml b/manifests/default-resources/argo-events/eventsource-controller.jsonpatch.yaml deleted file mode 100644 index b64289e14..000000000 --- a/manifests/default-resources/argo-events/eventsource-controller.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 200Mi - requests: - cpu: 20m - memory: 50Mi diff --git a/manifests/default-resources/argo-events/kustomization.yaml b/manifests/default-resources/argo-events/kustomization.yaml deleted file mode 100644 index 8ef5b0160..000000000 --- a/manifests/default-resources/argo-events/kustomization.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../argo-events -patches: - - path: eventbus.jsonpatch.yaml - target: - name: codefresh-eventbus - kind: EventBus - group: argoproj.io - version: v1alpha1 - - path: eventbus-controller.jsonpatch.yaml - target: - name: eventbus-controller - kind: Deployment - group: apps - version: v1 - - path: sensor-controller.jsonpatch.yaml - target: - name: sensor-controller - kind: Deployment - group: apps - version: v1 - - path: eventsource-controller.jsonpatch.yaml - target: - name: eventsource-controller - kind: Deployment - group: apps - version: v1 - - path: events-webhook.jsonpatch.yaml - target: - name: events-webhook - kind: Deployment - group: apps - version: v1 diff --git a/manifests/default-resources/argo-events/sensor-controller.jsonpatch.yaml b/manifests/default-resources/argo-events/sensor-controller.jsonpatch.yaml deleted file mode 100644 index b64289e14..000000000 --- a/manifests/default-resources/argo-events/sensor-controller.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 100m - memory: 200Mi - requests: - cpu: 20m - memory: 50Mi diff --git a/manifests/default-resources/argo-rollouts/argo-rollouts.jsonpatch.yaml b/manifests/default-resources/argo-rollouts/argo-rollouts.jsonpatch.yaml deleted file mode 100644 index 5856def8e..000000000 --- a/manifests/default-resources/argo-rollouts/argo-rollouts.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 500m - memory: 300Mi - requests: - cpu: 100m - memory: 150Mi diff --git a/manifests/default-resources/argo-rollouts/kustomization.yaml b/manifests/default-resources/argo-rollouts/kustomization.yaml deleted file mode 100644 index 7a72f7787..000000000 --- a/manifests/default-resources/argo-rollouts/kustomization.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../argo-rollouts -patches: - - path: argo-rollouts.jsonpatch.yaml - target: - name: argo-rollouts - kind: Deployment - group: apps - version: v1 diff --git a/manifests/default-resources/argo-workflows/argo-server.jsonpatch.yaml b/manifests/default-resources/argo-workflows/argo-server.jsonpatch.yaml deleted file mode 100644 index b87b8d1f9..000000000 --- a/manifests/default-resources/argo-workflows/argo-server.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 300m - memory: 1.5Gi - requests: - cpu: 100m - memory: 500Mi diff --git a/manifests/default-resources/argo-workflows/argo-workflows.jsonpatch.yaml b/manifests/default-resources/argo-workflows/argo-workflows.jsonpatch.yaml deleted file mode 100644 index b87b8d1f9..000000000 --- a/manifests/default-resources/argo-workflows/argo-workflows.jsonpatch.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 300m - memory: 1.5Gi - requests: - cpu: 100m - memory: 500Mi diff --git a/manifests/default-resources/argo-workflows/kustomization.yaml b/manifests/default-resources/argo-workflows/kustomization.yaml deleted file mode 100644 index e3dea8e64..000000000 --- a/manifests/default-resources/argo-workflows/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../argo-workflows -patches: - - path: argo-workflows.jsonpatch.yaml - target: - name: workflow-controller - kind: Deployment - group: apps - version: v1 - - path: argo-server.jsonpatch.yaml - target: - name: argo-server - kind: Deployment - group: apps - version: v1 diff --git a/manifests/default-resources/internal-router/kustomization.yaml b/manifests/default-resources/internal-router/kustomization.yaml deleted file mode 100644 index 0bb63ad38..000000000 --- a/manifests/default-resources/internal-router/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../internal-router diff --git a/manifests/default-resources/sealed-secrets/kustomization.yaml b/manifests/default-resources/sealed-secrets/kustomization.yaml deleted file mode 100644 index 861dbf39e..000000000 --- a/manifests/default-resources/sealed-secrets/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -bases: - - ../../sealed-secrets diff --git a/manifests/runtime.yaml b/manifests/runtime.yaml index 6f33c419e..798bf01c4 100644 --- a/manifests/runtime.yaml +++ b/manifests/runtime.yaml @@ -4,7 +4,7 @@ metadata: name: "{{ name }}" namespace: "{{ namespace }}" spec: - defVersion: 2.1.1 + defVersion: 2.1.2 version: 0.0.569 bootstrapSpecifier: github.com/codefresh-io/cli-v2.git/manifests/argo-cd components: diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 2bf285031..2924655e6 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -63,6 +63,7 @@ type ( RuntimeSpec struct { DefVersion *semver.Version `json:"defVersion"` + RequiredCLIVersion string `json:"requiredCLIVersion"` Version *semver.Version `json:"version"` BootstrapSpecifier string `json:"bootstrapSpecifier"` Components []AppDef `json:"components"` @@ -136,15 +137,6 @@ func Download(runtimeDef, name string, featuresToInstall []InstallFeature) (*Run runtime.Name = name runtime.Namespace = name - if store.Get().DevMode { - devVersion, err := runtime.Spec.Version.SetPrerelease("dev") - if err != nil { - return nil, fmt.Errorf("failed making dev prerelease version: %w", err) - } - - runtime.Spec.Version = &devVersion - } - filteredComponets := make([]AppDef, 0) for i := range runtime.Spec.Components { component := runtime.Spec.Components[i] @@ -154,10 +146,6 @@ func Download(runtimeDef, name string, featuresToInstall []InstallFeature) (*Run if component.Type == "kustomize" { url := component.URL - if store.Get().SetDefaultResources { - url = strings.Replace(url, "manifests/", "manifests/default-resources/", 1) - } - component.URL = runtime.Spec.fullURL(url) } @@ -312,18 +300,10 @@ func (a *RuntimeSpec) component(name string) *AppDef { func (r *RuntimeSpec) FullSpecifier() string { url := r.BootstrapSpecifier - if store.Get().SetDefaultResources { - url = strings.Replace(url, "manifests/", "manifests/default-resources/", 1) - } - return buildFullURL(url, r.Version.String()) } func (r *RuntimeSpec) fullURL(url string) string { - if store.Get().SetDefaultResources { - url = strings.Replace(url, "manifests/", "manifests/default-resources/", 1) - } - return buildFullURL(url, r.Version.String()) } @@ -495,23 +475,47 @@ func updateKustomization(fs apfs.FS, directory, fromURL, toURL string) error { } func buildFullURL(urlString, ref string) string { - if store.Get().DevMode { - return urlString - } + urlObj, _ := url.Parse(urlString) + v := urlObj.Query() + currRef := v.Get("ref") - host, orgRepo, _, _, _, suffix, _ := apaputil.ParseGitUrl(urlString) - repoUrl := host + orgRepo + suffix - if repoUrl != store.Get().DefaultRuntimeDefRepoURL() { + _, orgRepo, _, _, _, _, _ := apaputil.ParseGitUrl(urlString) + if store.Get().IsCustomDefURL(orgRepo) { // if the url is not from codefresh-io/cli-v2 - don't change it return urlString } - urlObj, _ := url.Parse(urlString) - v := urlObj.Query() - if v.Get("ref") == "" { - v.Add("ref", "v"+ref) + if currRef == "" { + if strings.Contains(urlString, "cli-v2") { + ref = "v" + ref + } + v.Add("ref", ref) urlObj.RawQuery = v.Encode() } return urlObj.String() } + +func GetRuntimeDefURL(versionStr string) string { + runtimeDefURL := store.Get().RuntimeDefURL + if versionStr == "" { + return runtimeDefURL + } + + version := semver.MustParse(versionStr) + if version.Compare(store.Get().LastRuntimeVersionInCLI) <= 0 { + runtimeDefURL = store.Get().RuntimeDefURL + } + + return runtimeDefURL +} + +func CheckRuntimeVersionCompatible(requiredCLIVersion string) error { + // The error is ignored, because it is expected for older runtime to not have the requiredCLIVersion field + requiredCLIVersionConstraint, _ := semver.NewConstraint(requiredCLIVersion) + if requiredCLIVersionConstraint != nil && !requiredCLIVersionConstraint.Check(store.Get().Version.Version) { + return fmt.Errorf("to install this version, please install cli version %s", requiredCLIVersionConstraint.String()) + } + + return nil +} diff --git a/pkg/store/store.go b/pkg/store/store.go index 9779d0d0f..9e118101b 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -26,16 +26,18 @@ import ( var s Store var ( - binaryName = "cli-v2" - version = "v99.99.99" - buildDate = "" - gitCommit = "" - SegmentWriteKey = "" - maxDefVersion = "2.1.1" - RuntimeDefURL = "manifests/runtime.yaml" + binaryName = "cli-v2" + version = "v99.99.99" + buildDate = "" + gitCommit = "" + SegmentWriteKey = "" + // please do not touch this field it is deprecated, it's only here to allow to install runtimes with version < 0.0.569 + maxDefVersion = "2.1.2" + RuntimeDefURL = "https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml" + OldRuntimeDefURL = "https://github.com/codefresh-io/cli-v2/releases/latest/download/runtime.yaml" AddClusterDefURL = "https://github.com/codefresh-io/csdp-official/add-cluster/kustomize" FallbackAddClusterDefURL = "https://github.com/codefresh-io/cli-v2/manifests/add-cluster/kustomize" - devMode = "true" + lastRuntimeVersionInCLI = "v0.0.569" ) type Version struct { @@ -89,7 +91,9 @@ type Store struct { MarketplaceGitSourceName string MarketplaceRepo string MaxDefVersion *semver.Version + LastRuntimeVersionInCLI *semver.Version RuntimeDefURL string + OldRuntimeDefURL string Version Version WaitTimeout time.Duration WorkflowName string @@ -150,7 +154,7 @@ type Store struct { IsDownloadRuntimeLogs bool IngressHost string IscRuntimesDir string - DevMode bool + DefVersionToLastCLIVersion map[string]string } // Get returns the global store @@ -158,9 +162,11 @@ func Get() *Store { return &s } -func (s *Store) DefaultRuntimeDefRepoURL() string { - host, orgRepo, _, _, _, suffix, _ := apaputil.ParseGitUrl(s.RuntimeDefURL) - return host + orgRepo + suffix +func (s *Store) IsCustomDefURL(orgRepo string) bool { + _, runtimeDefOrgRepo, _, _, _, _, _ := apaputil.ParseGitUrl(s.RuntimeDefURL) + _, oldRuntimeDefOrgRepo, _, _, _, _, _ := apaputil.ParseGitUrl(s.OldRuntimeDefURL) + + return orgRepo != runtimeDefOrgRepo && orgRepo != oldRuntimeDefOrgRepo } func init() { @@ -203,7 +209,9 @@ func init() { s.LabelSelectorSealedSecret = "codefresh.io/sealing-key=true" 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 @@ -258,7 +266,13 @@ func init() { s.CFInternalReporters = []string{s.EventsReporterName, s.WorkflowReporterName, s.RolloutReporterName} s.InCluster = "https://kubernetes.default.svc" s.IscRuntimesDir = "runtimes" - s.DevMode = devMode == "true" + s.DefVersionToLastCLIVersion = map[string]string{ + "1.0.0": "0.0.237", + "1.0.1": "0.0.510", + "2.0.0": "0.0.541", + "2.1.0": "0.0.548", + "2.1.1": "0.0.569", + } initVersion() } diff --git a/pkg/util/events/util.go b/pkg/util/events/util.go index 743bd5dbd..ca0a2c943 100644 --- a/pkg/util/events/util.go +++ b/pkg/util/events/util.go @@ -111,10 +111,6 @@ func CreateEventSource(opts *CreateEventSourceOptions) *eventsourcev1alpha1.Even tpl := &eventsourcev1alpha1.Template{Container: &v1.Container{}} - if store.Get().SetDefaultResources { - SetDefaultResourceRequirements(tpl.Container) - } - if opts.ServiceAccountName != "" { tpl.ServiceAccountName = opts.ServiceAccountName } @@ -205,10 +201,6 @@ func CreateSensor(opts *CreateSensorOptions) *sensorsv1alpha1.Sensor { tpl := &sensorsv1alpha1.Template{Container: &v1.Container{}} - if store.Get().SetDefaultResources { - SetDefaultResourceRequirements(tpl.Container) - } - return &sensorsv1alpha1.Sensor{ TypeMeta: metav1.TypeMeta{ Kind: sensorreg.Kind,