Skip to content

Commit 73acb4f

Browse files
authored
Revert "Avoid e2e test changing tracked files (#1329)" (#1365)
This reverts commit 3128a79.
1 parent 50d1ba7 commit 73acb4f

File tree

5 files changed

+39
-72
lines changed

5 files changed

+39
-72
lines changed

.github/actions/gen-install-scripts/entrypoint.sh

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,7 @@
22

33
set -xeou pipefail
44

5-
subdir=${1:-}
6-
75
target_dir="deploy"
8-
bundle_dir="bundle"
9-
config_dir="config"
10-
11-
function cleanup() {
12-
# Restore original bundle.Dockerfile as needed
13-
cp bundle.Dockerfile "${bundle_dir}/bundle.Dockerfile"
14-
mv bundle.Dockerfile.backup bundle.Dockerfile
15-
}
16-
17-
if [ "${subdir}" != "" ]; then
18-
target_dir+="/${subdir}"
19-
bundle_dir+="/${subdir}"
20-
config_dir+="/${subdir}"
21-
mkdir -p "${target_dir}" "${bundle_dir}"
22-
cp -R config/release "${config_dir}"
23-
cp -R bundle/manifests bundle/metadata "${bundle_dir}/manifests"
24-
cp bundle.Dockerfile bundle.Dockerfile.backup
25-
trap cleanup EXIT
26-
fi
27-
286
clusterwide_dir="${target_dir}/clusterwide"
297
namespaced_dir="${target_dir}/namespaced"
308
crds_dir="${target_dir}/crds"
@@ -36,59 +14,59 @@ mkdir -p "${crds_dir}"
3614
mkdir -p "${openshift}"
3715

3816
# Generate configuration and save it to `all-in-one`
39-
controller-gen crd:crdVersions=v1,ignoreUnexportedFields=true rbac:roleName=manager-role webhook paths="./pkg/api/..." output:crd:artifacts:config="${config_dir}/crd/bases"
40-
cd "${config_dir}/manager" && kustomize edit set image controller="${INPUT_IMAGE_URL}"
17+
controller-gen crd:crdVersions=v1,ignoreUnexportedFields=true rbac:roleName=manager-role webhook paths="./pkg/api/..." output:crd:artifacts:config=config/crd/bases
18+
cd config/manager && kustomize edit set image controller="${INPUT_IMAGE_URL}"
4119
cd -
42-
./scripts/split_roles_yaml.sh "${subdir}"
20+
./scripts/split_roles_yaml.sh
4321

4422
which kustomize
4523
kustomize version
4624

4725
# all-in-one
48-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/release/${INPUT_ENV}/allinone" > "${target_dir}/all-in-one.yaml"
26+
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/allinone" > "${target_dir}/all-in-one.yaml"
4927
echo "Created all-in-one config"
5028

5129
# clusterwide
52-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/release/${INPUT_ENV}/clusterwide" > "${clusterwide_dir}/clusterwide-config.yaml"
53-
kustomize build "${config_dir}/crd" > "${clusterwide_dir}/crds.yaml"
30+
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/clusterwide" > "${clusterwide_dir}/clusterwide-config.yaml"
31+
kustomize build "config/crd" > "${clusterwide_dir}/crds.yaml"
5432
echo "Created clusterwide config"
5533

5634
# base-openshift-namespace-scoped
57-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/release/${INPUT_ENV}/openshift" > "${openshift}/openshift.yaml"
58-
kustomize build "${config_dir}/crd" > "${openshift}/crds.yaml"
35+
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/openshift" > "${openshift}/openshift.yaml"
36+
kustomize build "config/crd" > "${openshift}/crds.yaml"
5937
echo "Created openshift namespaced config"
6038

6139
# namespaced
62-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/release/${INPUT_ENV}/namespaced" > "${namespaced_dir}/namespaced-config.yaml"
63-
kustomize build "${config_dir}/crd" > "${namespaced_dir}/crds.yaml"
40+
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/namespaced" > "${namespaced_dir}/namespaced-config.yaml"
41+
kustomize build "config/crd" > "${namespaced_dir}/crds.yaml"
6442
echo "Created namespaced config"
6543

6644
# crds
67-
cp "${config_dir}/crd/bases"/* "${crds_dir}"
45+
cp config/crd/bases/* "${crds_dir}"
6846

6947
# CSV bundle
7048
operator-sdk generate kustomize manifests -q --apis-dir=pkg/api
7149
# get the current version so we could put it into the "replaces:"
72-
current_version=$(yq e '.metadata.name' "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml")
50+
current_version="$(yq e '.metadata.name' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml)"
7351

7452
# We pass the version only for non-dev deployments (it's ok to have "0.0.0" for dev)
7553
channel="stable"
7654
if [[ "${INPUT_ENV}" == "dev" ]]; then
7755
echo "build dev purpose"
78-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/manifests" |
79-
operator-sdk generate bundle -q --overwrite --default-channel="${channel}" --channels="${channel}" --output-dir "${bundle_dir}"
56+
kustomize build --load-restrictor LoadRestrictionsNone config/manifests |
57+
operator-sdk generate bundle -q --overwrite --default-channel="${channel}" --channels="${channel}"
8058
else
8159
echo "build release version"
8260
echo "${INPUT_IMAGE_URL}"
83-
kustomize build --load-restrictor LoadRestrictionsNone "${config_dir}/manifests" |
84-
operator-sdk generate bundle -q --overwrite --version "${INPUT_VERSION}" --default-channel="${channel}" --channels="${channel}" --output-dir "${bundle_dir}"
61+
kustomize build --load-restrictor LoadRestrictionsNone config/manifests |
62+
operator-sdk generate bundle -q --overwrite --version "${INPUT_VERSION}" --default-channel="${channel}" --channels="${channel}"
8563
# add replaces
86-
awk '!/replaces:/' "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml" > tmp && mv tmp "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml"
87-
echo " replaces: $current_version" >> "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml"
64+
awk '!/replaces:/' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
65+
echo " replaces: $current_version" >> bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
8866
# Add WATCH_NAMESPACE env parameter
89-
value="metadata.annotations['olm.targetNamespaces']" yq e -i '.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[2] |= {"name": "WATCH_NAMESPACE", "valueFrom": {"fieldRef": {"fieldPath": env(value)}}}' "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml"
90-
# Add containerImage to "${bundle_dir}/manifests/" csv. containerImage - The full location (registry, repository, name and tag) of the operator image
91-
yq e -i ".metadata.annotations.containerImage=\"${INPUT_IMAGE_URL}\"" "${bundle_dir}/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml"
67+
value="metadata.annotations['olm.targetNamespaces']" yq e -i '.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[2] |= {"name": "WATCH_NAMESPACE", "valueFrom": {"fieldRef": {"fieldPath": env(value)}}}' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
68+
# Add containerImage to bundle/manifests/ csv. containerImage - The full location (registry, repository, name and tag) of the operator image
69+
yq e -i ".metadata.annotations.containerImage=\"${INPUT_IMAGE_URL}\"" bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
9270
fi
9371

9472
# add additional LABELs to bundle.Docker file

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ node_modules
4141
tmp/
4242

4343
# ready to work samples
44-
deploy
45-
46-
# e2e work files
47-
config/e2e
48-
bundle/e2e
44+
deploy/
4945

5046
# ignore tool binaries
5147
tools/clean/clean

scripts/e2e_local.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ export INPUT_IMAGE_URL="${image}"
2222
export INPUT_ENV=dev
2323

2424
if [[ "${build}" == "true" ]]; then
25-
./.github/actions/gen-install-scripts/entrypoint.sh e2e
26-
awk '{gsub(/cloud.mongodb.com/, "cloud-qa.mongodb.com", $0); print}' bundle/e2e/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/e2e/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
25+
./.github/actions/gen-install-scripts/entrypoint.sh
26+
awk '{gsub(/cloud.mongodb.com/, "cloud-qa.mongodb.com", $0); print}' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
2727

2828
docker build -t "${image}" .
2929
docker push "${image}"
3030

3131
#bundles
32-
docker build -f bundle/e2e/bundle.Dockerfile -t "${bundle_image}" .
32+
docker build -f bundle.Dockerfile -t "${bundle_image}" .
3333
docker push "${bundle_image}"
3434
fi
3535

36-
kubectl apply -f deploy/e2e/crds
36+
kubectl apply -f deploy/crds
3737

3838
export MCLI_OPS_MANAGER_URL="https://cloud-qa.mongodb.com/"
3939
export MCLI_PUBLIC_API_KEY="${public_key}"

scripts/split_roles_yaml.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22

33
set -eou pipefail
44

5-
subdir=${1:-}
6-
7-
config_dir="config"
8-
if [ "${subdir}" != "" ]; then
9-
config_dir+="/${subdir}"
10-
fi
11-
125
# This is the script that allows to avoid the restrictions from the controller-gen tool that puts both Role and ClusterRole
136
# to the same role.yaml file (and kustomize doesn't provide an easy way to use only a single resource from file as a base)
14-
# So we simply split the '"${config_dir}rbac/roles.yaml' file into two new files
15-
if [[ -f "${config_dir}/rbac/role.yaml" ]]; then
16-
awk '/---/{f="xx0"int(++i);} {if(NF!=0)print > f};' "${config_dir}/rbac/role.yaml"
17-
# csplit "${config_dir}/rbac/role.yaml" '/---/' '{*}' &> /dev/null - infinite repetition '{*}' is not working on BSD/OSx
18-
mv xx01 "${config_dir}/rbac/clusterwide/role.yaml"
19-
mv xx02 "${config_dir}/rbac/namespaced/role.yaml"
20-
rm "${config_dir}/rbac/role.yaml"
7+
# So we simply split the 'config/rbac/roles.yaml' file into two new files
8+
if [[ -f config/rbac/role.yaml ]]; then
9+
awk '/---/{f="xx0"int(++i);} {if(NF!=0)print > f};' config/rbac/role.yaml
10+
# csplit config/rbac/role.yaml '/---/' '{*}' &> /dev/null - infinite repetition '{*}' is not working on BSD/OSx
11+
mv xx01 config/rbac/clusterwide/role.yaml
12+
mv xx02 config/rbac/namespaced/role.yaml
13+
rm config/rbac/role.yaml
2114
fi

test/helper/e2e/config/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package config
33
const (
44

55
// Kubernetes configuration samples for users in deploy directory
6-
DefaultDeployConfig = "../../deploy/e2e/" // Released generated files
7-
DefaultClusterWideCRDConfig = "../../deploy/e2e/clusterwide/crds.yaml"
8-
DefaultClusterWideOperatorConfig = "../../deploy/e2e/clusterwide/clusterwide-config.yaml"
9-
DefaultNamespacedCRDConfig = "../../deploy/e2e/namespaced/crds.yaml"
10-
DefaultNamespacedOperatorConfig = "../../deploy/e2e/namespaced/namespaced-config.yaml"
6+
DefaultDeployConfig = "../../deploy/" // Released generated files
7+
DefaultClusterWideCRDConfig = "../../deploy/clusterwide/crds.yaml"
8+
DefaultClusterWideOperatorConfig = "../../deploy/clusterwide/clusterwide-config.yaml"
9+
DefaultNamespacedCRDConfig = "../../deploy/namespaced/crds.yaml"
10+
DefaultNamespacedOperatorConfig = "../../deploy/namespaced/namespaced-config.yaml"
1111

1212
// Default names/path for tests coordinates
1313
DataGenFolder = "data/gen" // for generated configs
@@ -41,5 +41,5 @@ const (
4141
AzureRegionEU = "northeurope"
4242

4343
// GCP
44-
FileNameSAGCP = "../../output/gcp_service_account.json"
44+
FileNameSAGCP = "gcp_service_account.json"
4545
)

0 commit comments

Comments
 (0)