Skip to content

Commit

Permalink
🌱 make hack scripts runnable via curl
Browse files Browse the repository at this point in the history
Signed-off-by: David Zager <dzager@redhat.com>
  • Loading branch information
djzager committed Jul 5, 2024
1 parent 011a031 commit de23941
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 45 deletions.
20 changes: 18 additions & 2 deletions .github/actions/install-konveyor/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,24 @@ inputs:
runs:
using: "composite"
steps:
# TODO(djzager): Need to figure out overriding operator image
# or maybe just installing manager via kustomize.
- name: Install kubectl
shell: bash
run: |
if command -v kubectl >/dev/null 2>&1; then
echo "kubectl is already installed...yay"
exit 0
fi
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- name: Install operator-sdk
shell: bash
run: |
if command -v operator-sdk >/dev/null 2>&1; then
echo "operator-sdk is already installed...yay"
exit 0
fi
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.35.0/operator-sdk_linux_amd64
sudo install -o root -g root -m 0755 operator-sdk_linux_amd64 /usr/local/bin/operator-sdk
- name: Install Konveyor
env:
OPERATOR_BUNDLE_IMAGE: ${{ inputs.bundle_image }}
Expand Down
29 changes: 5 additions & 24 deletions hack/install-konveyor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,19 @@ set -e
set -x
set -o pipefail

# Figure out where we are being run from.
# This relies on script being run from:
# - ${PROJECT_ROOT}/hack/install-tackle.sh
# - ${PROJECT_ROOT}/bin/install-tackle.sh
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
__repo="$(basename "${__root}")"
__bin_dir="${__root}/bin"
__os="$(uname -s | tr '[:upper:]' '[:lower:]')"
__arch="$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')"

# Update PATH for execution of this script
PATH="${__bin_dir}:${PATH}"

NAMESPACE="${NAMESPACE:-konveyor-tackle}"
OPERATOR_BUNDLE_IMAGE="${OPERATOR_BUNDLE_IMAGE:-quay.io/konveyor/tackle2-operator-bundle:latest}"
TACKLE_CR="${TACKLE_CR:-}"
TIMEOUT="${TIMEOUT:-10m}"

if ! command -v kubectl >/dev/null 2>&1; then
kubectl_bin="${__bin_dir}/kubectl"
mkdir -p "${__bin_dir}"
curl -Lo "${kubectl_bin}" "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${__os}/${__arch}/kubectl"
chmod +x "${kubectl_bin}"
echo "Please install kubectl. See https://kubernetes.io/docs/tasks/tools/"
exit 1
fi

if ! command -v operator-sdk >/dev/null 2>&1; then
operator_sdk_bin="${__bin_dir}/operator-sdk"
mkdir -p "${__bin_dir}"

version=$(curl --silent "https://api.github.com/repos/operator-framework/operator-sdk/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -Lo "${operator_sdk_bin}" "https://github.com/operator-framework/operator-sdk/releases/download/${version}/operator-sdk_${__os}_${__arch}"
chmod +x "${operator_sdk_bin}"
echo "Please install operator-sdk. See https://sdk.operatorframework.io/docs/installation/"
exit 1
fi

debug() {
Expand Down Expand Up @@ -108,5 +88,6 @@ EOF
deployments.apps
}

kubectl get customresourcedefinitions.apiextensions.k8s.io clusterserviceversions.operators.coreos.com || operator-sdk olm install
kubectl get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io || run_bundle
install_tackle
19 changes: 0 additions & 19 deletions hack/start-minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@
set -e
set -x

# Figure out where we are being run from.
# This relies on script being run from:
# - ${PROJECT_ROOT}/hack/install-tackle.sh
# - ${PROJECT_ROOT}/bin/install-tackle.sh
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
__repo="$(basename "${__root}")"
__bin_dir="${__root}/bin"
__os="$(uname -s | tr '[:upper:]' '[:lower:]')"
__arch="$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')"

# Update PATH for execution of this script
export PATH="${__bin_dir}:${PATH}"

# Inputs via environment variables
MINIKUBE_DRIVER="${MINIKUBE_DRIVER:-}"
MINIKUBE_CONTAINER_RUNTIME="${MINIKUBE_CONTAINER_RUNTIME:-}"
MINIKUBE_KUBERNETES_VERSION="${MINIKUBE_KUBERNETES_VERSION:-}"
MINIKUBE_CPUS="${MINIKUBE_CPUS:-}"
MINIKUBE_MEMORY="${MINIKUBE_MEMORY:-}"
MINIKUBE_CNI="${MINIKUBE_CNI:-}"
OLM="${OLM:-true}"

# Check pre-reqs
# May want to leave this for the user to install
Expand Down Expand Up @@ -53,7 +38,3 @@ fi

# Enable ingress
minikube addons enable ingress

if [ "${OLM}" = "true" ]; then
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.26.0/install.sh | bash -s v0.26.0
fi

0 comments on commit de23941

Please sign in to comment.