Skip to content

Commit

Permalink
Move inline bash code to seperate files to prevent copy/paste errors
Browse files Browse the repository at this point in the history
Signed-off-by: ezgidemirel <[email protected]>
  • Loading branch information
ezgidemirel committed May 17, 2023
1 parent 13368e2 commit b265566
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 93 deletions.
14 changes: 14 additions & 0 deletions docs/sp-migration/find-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

function getsmallerproviders(){
provider="${1}"
version="${2}"
smaller=$(grep -irn ${provider}.upbound.io/v1beta1 ${CONF_PATH} | awk '{print $3}'| cut -d '.' -f 1 | sort | uniq)

for s in ${smaller[@]}; do if [ $s != "azure" ]; then echo "- provider: xpkg.upbound.io/upbound-release-candidates/provider-$provider-$s";echo " version: \"$version\""; fi; done
}

providers=( "aws:v0.36.0" "gcp:v0.33.0" "azure:v0.34.0" )

for pp in ${providers[@]}; do getsmallerproviders "${pp%%:*}" "${pp##*:}"; done
42 changes: 42 additions & 0 deletions docs/sp-migration/generate-manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -e

version_aws=v0.37.0
version_azure=v0.34.0
version_gcp=v0.34.0

rm -f "sp-manual.yaml" && touch "sp-manual.yaml"
rm -f "sp-family-manual.yaml" && touch "sp-family-manual.yaml"
kubectl get managed --no-headers -o jsonpath='{range .items[*]}{.apiVersion}{"\n"}{end}' | grep -E '(aws|gcp|azure).upbound.io' | sort | uniq | while read -r line
do
service=$(echo "${line}" | cut -d. -f1)
provider=$(echo "${line}" | cut -d. -f2)
if [ "${provider}" = "upbound" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
provider="azure"
fi
eval version=\$"version_${provider}"

for sp in config ${service}; do
filename="sp-manual.yaml"
providername="${provider}-${sp}"

if [ "${sp}" = "config" ] || [ "${sp}" = "azure" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
providername="family-$provider"
filename="sp-family-manual.yaml"
fi
if ! cat "${filename}" | grep provider-${providername}:${version} > /dev/null; then
echo "apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-release-candidates-provider-${providername}
spec:
package: xpkg.upbound.io/upbound-release-candidates/provider-${providername}:${version}
revisionActivationPolicy: Manual" >> "${filename}"
echo "---" >> "${filename}"
fi
done
done
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,8 @@ kubectl patch $(kubectl get managed -o name) -p '{"spec":{"deletionPolicy":"Orph
3. Generate smaller provider manifests

```bash
version_aws=v0.37.0
version_azure=v0.34.0
version_gcp=v0.34.0

rm -f "sp-manual.yaml" && touch "sp-manual.yaml"
rm -f "sp-family-manual.yaml" && touch "sp-family-manual.yaml"
kubectl get managed --no-headers -o jsonpath='{range .items[*]}{.apiVersion}{"\n"}{end}' | grep -E '(aws|gcp|azure).upbound.io' | sort | uniq | while read -r line
do
service=$(echo "${line}" | cut -d. -f1)
provider=$(echo "${line}" | cut -d. -f2)
if [ "${provider}" = "upbound" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
provider="azure"
fi
eval version=\$"version_${provider}"

for sp in config ${service}; do
filename="sp-manual.yaml"
providername="${provider}-${sp}"

if [ "${sp}" = "config" ] || [ "${sp}" = "azure" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
providername="family-$provider"
filename="sp-family-manual.yaml"
fi
if ! cat "${filename}" | grep provider-${providername}:${version} > /dev/null; then
echo "apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-release-candidates-provider-${providername}
spec:
package: xpkg.upbound.io/upbound-release-candidates/provider-${providername}:${version}
revisionActivationPolicy: Manual" >> "${filename}"
echo "---" >> "${filename}"
fi
done
done
export KUBECONFIG=<path of the Kubeconfig file>
./generate-manifests.sh
```

4. Install family providers with `revisionActivationPolicy: Manual`:
Expand Down Expand Up @@ -131,22 +94,11 @@ kubectl get managed
kubectl get provider.pkg
```

10. Find new dependencies and add them to `dependsOn`:
10. Find new dependencies and add them to `dependsOn` field in the `crossplane.yaml` file:

```bash
providers=( "aws:v0.37.0" "gcp:v0.34.0" "azure:v0.34.0" )

for pp in ${providers[@]}; do
provider="${pp%%:*}"
version="${pp##*:}"
smaller=$(grep -irn ${provider}.upbound.io/v1beta1 ${CONF_PATH} | awk '{print $3}'| cut -d '.' -f 1 | sort | uniq)

for s in ${smaller[@]}; do
if [ $s != "azure" ]; then
echo "- provider: xpkg.upbound.io/upbound-release-candidates/provider-$provider-$s";echo " version: \">=$version\"";
fi
done
done
export CONF_PATH=<root path of the configuration files>
./find-dependencies.sh
```

12. Build/push/update the configuration to the new version
Expand Down
42 changes: 2 additions & 40 deletions docs/sp-migration-mr.md → docs/sp-migration/sp-migration-mr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,12 @@ kubectl patch $(kubectl get managed -o name) -p '{"spec":{"deletionPolicy":"Orph
3. Generate smaller provider manifests

```bash
version_aws=v0.37.0
version_azure=v0.34.0
version_gcp=v0.34.0

rm -f "sp-manual.yaml" && touch "sp-manual.yaml"
rm -f "sp-family-manual.yaml" && touch "sp-family-manual.yaml"
kubectl get managed --no-headers -o jsonpath='{range .items[*]}{.apiVersion}{"\n"}{end}' | grep -E '(aws|gcp|azure).upbound.io' | sort | uniq | while read -r line
do
service=$(echo "${line}" | cut -d. -f1)
provider=$(echo "${line}" | cut -d. -f2)
if [ "${provider}" = "upbound" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
provider="azure"
fi
eval version=\$"version_${provider}"

for sp in config ${service}; do
filename="sp-manual.yaml"
providername="${provider}-${sp}"

if [ "${sp}" = "config" ] || [ "${sp}" = "azure" ]; then
# azure.upbound.io is an exception where apiVersion does not contain the service name
# we have those resources in the family package
providername="family-$provider"
filename="sp-family-manual.yaml"
fi
if ! cat "${filename}" | grep provider-${providername}:${version} > /dev/null; then
echo "apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-release-candidates-provider-${providername}
spec:
package: xpkg.upbound.io/upbound-release-candidates/provider-${providername}:${version}
revisionActivationPolicy: Manual" >> "${filename}"
echo "---" >> "${filename}"
fi
done
done
export KUBECONFIG=<path of the Kubeconfig file>
./generate-manifests.sh
```

4. Install family providers with `revisionActivationPolicy: Manual`:


Verify that `sp-family-manual.yaml` files are generated with the correct content

```bash
Expand Down
File renamed without changes.

0 comments on commit b265566

Please sign in to comment.