Skip to content

Commit

Permalink
Revert "Remove unused manifests (codefresh-io#638)"
Browse files Browse the repository at this point in the history
This reverts commit a9c1e99.
  • Loading branch information
danielm-codefresh committed Nov 13, 2022
1 parent 1cf136a commit f9dd29e
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.5
VERSION=v0.1.4

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand All @@ -9,6 +9,7 @@ IMAGE_NAMESPACE?=codefresh

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"

# 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"
Expand Down Expand Up @@ -105,6 +106,7 @@ $(OUT_DIR)/$(CLI_NAME)-%: $(CLI_SRCS)
GIT_COMMIT=$(GIT_COMMIT) \
RUNTIME_DEF_URL=$(RUNTIME_DEF_URL) \
ADD_CLUSTER_DEF_URL=$(ADD_CLUSTER_DEF_URL) \
FALLBACK_ADD_CLUSTER_DEF_URL=$(FALLBACK_ADD_CLUSTER_DEF_URL) \
SEGMENT_WRITE_KEY=$(SEGMENT_WRITE_KEY) \
DEV_MODE=$(DEV_MODE) \
OUT_FILE=$(OUT_DIR)/$(CLI_NAME)-$* \
Expand Down
94 changes: 94 additions & 0 deletions build/add-cluster-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: '1.0'
mode: parallel

stages:
- Prepare
- Test
- Release

steps:
main_clone:
stage: Prepare
title: clone repository
type: git-clone
git: cf_github
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
revision: ${{CF_BRANCH}}

prepare_env_vars:
stage: Prepare
title: prepare-env
image: codefresh/semver:latest
working_directory: manifests/add-cluster
commands:
- cf_export CHART_VERSION=$(yq ".version" helm/Chart.yaml | tr -d '"')
- cf_export IMAGE_VERSION=$(yq ".appVersion" helm/Chart.yaml | tr -d '"')
when:
steps:
- name: main_clone
on:
- success

compare_versions:
stage: Test
title: Compare versions
image: codefresh/semver:latest
commands:
- hack/compare-versions.sh
when:
steps:
- name: prepare_env_vars
on:
- success

build_image:
stage: Release
type: build
title: build and push add-cluster image
working_directory: manifests/add-cluster
image_name: codefresh/csdp-add-cluster
tag: ${{IMAGE_VERSION}}
tags:
- latest
- ${{IMAGE_VERSION}}
registry: ${{REGISTRY_INTEGRATION_QUAY}}
buildkit: true
when:
steps:
- name: compare_versions
on:
- success
branch:
only: ["main"]

build_dev_image:
stage: Release
type: build
title: build and push add-cluster dev image
working_directory: manifests/add-cluster
image_name: codefresh/csdp-add-cluster
tag: ${{CF_BRANCH}}
registry: ${{REGISTRY_INTEGRATION_QUAY}}
buildkit: true
when:
steps:
- name: compare_versions
on:
- success
branch:
ignore: ["main"]

publish_chart:
stage: Release
title: publish helm chart
image: quay.io/codefresh/golang-ci-helper:latest # change it
working_directory: manifests/add-cluster
environment:
- CHART_VERSION=${{CHART_VERSION}}
commands:
- echo "inside publish helm chart ${CHART_VERSION}"
when:
steps:
- name: build_image
on:
- success
18 changes: 14 additions & 4 deletions cmd/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type (
)

var (
minAddClusterSupportedVersion = semver.MustParse("0.0.283")
minAddClusterSupportedVersion = semver.MustParse("0.0.283")
minAddClusterLabelsSupportedVersion = semver.MustParse("0.0.462")

serviceAccountGVK = resid.Gvk{
Expand Down Expand Up @@ -384,7 +384,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding annotations: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("annotations="+annotationsStr))
k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("annotations=" + annotationsStr))
}

if len(opts.labels) > 0 {
Expand All @@ -393,7 +393,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding labels: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("labels="+labelsStr))
k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("labels=" + labelsStr))
}

if opts.tag != "" {
Expand All @@ -410,7 +410,17 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp

manifests, err := kustutil.BuildKustomization(k)
if err != nil {
return nil, "", fmt.Errorf("failed to build kustomization: %w", err)
// go to fallback add-cluster manifests
// remove this once all manifests has been moved official-csdp repo.
// once we are sure no one will be looking for those manifests in cli-v2 we can remove this.
fallbackResourceUrl := fmt.Sprintf("%s?ref=v%s", store.FallbackAddClusterDefURL, version)
k.Resources[0] = fallbackResourceUrl
log.G().Warnf("Failed to get \"add-cluster\" manifests from %s, using fallback of %s", resourceUrl, fallbackResourceUrl)

manifests, err = kustutil.BuildKustomization(k)
if err != nil {
return nil, "", fmt.Errorf("failed to build kustomization: %w", err)
}
}

return manifests, nameSuffix, nil
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.5/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.4/cf-linux-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-linux-amd64 /usr/local/bin/cf
Expand All @@ -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.1.5/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.4/cf-darwin-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
19 changes: 19 additions & 0 deletions hack/compare-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# used by the add-cluster-script.yaml
# compares the helm chart version with the kustomization image version to make sure they are identical

BASE_DIRECTORY="manifests/add-cluster"
HELM_CHART="${BASE_DIRECTORY}/helm/Chart.yaml"
KUSTOMIZATION_YAML="${BASE_DIRECTORY}/kustomize/kustomization.yaml"

HELM_VERSION=$(yq ".appVersion" ${HELM_CHART} | tr -d '"')
KUST_VERSION=$(yq '.images | select(.[].name == "quay.io/codefresh/csdp-add-cluster") | .[0].newTag' ${KUSTOMIZATION_YAML} | tr -d '"')
if ! semver-cli equal ${HELM_VERSION} ${KUST_VERSION}; then
echo "mismatched versions:"
echo "helm/Chart.yaml appVersion = ${HELM_VERSION}"
echo "kustomize/kustomization.yaml newTag = ${KUST_VERSION}"
exit 1
fi

echo "helm and kustomize versions match: ${HELM_VERSION}"
8 changes: 8 additions & 0 deletions manifests/add-cluster/kustomize/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/codefresh-io/csdp-official/add-cluster/kustomize
# This file is here for users with runtime version > 0.0.417 but with clis < 0.0.417
# That will try to look for the add-cluster manifests in this location instead of
# csdp-official repo. We should remove this when we think clis < 0.0.417 are no longer
# in use.
1 change: 0 additions & 1 deletion manifests/runtime.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This file should not be changed. The sole purpose of it staying here is backward compatibility
apiVersion: codefresh.io/v1alpha1
kind: Runtime
metadata:
Expand Down
11 changes: 6 additions & 5 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ var (
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"
lastRuntimeVersionInCLI = "v0.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"
lastRuntimeVersionInCLI = "v0.0.569"
)

type Version struct {
Expand Down

0 comments on commit f9dd29e

Please sign in to comment.