Skip to content

Commit

Permalink
fix(cli-tools): fix github-releases install at agent-startup (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppat committed Sep 3, 2024
1 parent 92869d7 commit aaa9162
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
label_title: "Homelab Workspace"
label_description: "Homelab workspace image"
source_git_ref: ${{ (github.event_name == 'pull_request') && format('refs/heads/{0}', github.head_ref) || format('refs/tags/{0}', needs.create-release.outputs.released_version) }}
timeout_minutes: 120
timeout_minutes: 180
secrets:
private_registry_username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
private_registry_token: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
label_title: "Homelab Workspace"
label_description: "Homelab workspace image"
source_git_ref: ${{ (github.event_name == 'pull_request') && format('refs/heads/{0}', github.head_ref) || github.ref }}
timeout_minutes: 120
timeout_minutes: 180
secrets:
private_registry_username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
private_registry_token: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
Expand Down
10 changes: 10 additions & 0 deletions images/homelab-workspace/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,16 @@ RUN --mount=type=tmpfs,target=/tmp \
install -o root -g root -m 0755 /tmp/krew-linux_${TARGETARCH} /usr/local/sbin/kubectl-krew && \
upx /usr/local/sbin/kubectl-krew

# kustomize
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize extractVersion=^kustomize/(?<version>.*)$
ARG KUSTOMIZE_VERSION="5.2.1"
RUN --mount=type=tmpfs,target=/tmp \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/var/tmp \
wget --progress=dot:giga -c "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz" -O - | tar -xzv -C /tmp && \
install -o root -g root -m 0755 /tmp/kustomize /usr/local/sbin/kustomize && \
upx /usr/local/sbin/kustomize

# minio-cli
RUN --mount=type=tmpfs,target=/tmp \
--mount=type=tmpfs,target=/var/log \
Expand Down
2 changes: 1 addition & 1 deletion images/homelab-workspace/coder/init-background.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ main() {
install_npm_packages /opt/fnm/npm-packages.json 2>&1 | sed -E 's|^(.*)| \1|g'
echo "--------------------------------------------------------------------------------------"
echo "Installing packages from github-releases..."
/opt/coder/bin/install-from-github-release.sh /packages/github-releases.yaml $HOME/.local/bin
/opt/coder/bin/install-from-github-release.sh /opt/packages-github-releases.yaml $HOME/.local/bin
echo "--------------------------------------------------------------------------------------"
echo "Maintaining krew plugins..."
$(dirname ${0})/init-krew-plugins.sh 2>&1 | sed -E 's|^(.*)| \1|g'
Expand Down
5 changes: 5 additions & 0 deletions images/homelab-workspace/coder/install-from-github-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ install_release() {
local package_name="$1"
local release_yaml="$2"

if [[ -f $INSTALL_DIR/$package_name ]]; then
echo "Already exists... skipping."
return
fi

# read package configuration from yaml
local repo="$(yq -e '.[] | select(.name == "'$package_name'") | .repo' $release_yaml)"
local tag="$(yq -e '.[] | select(.name == "'$package_name'") | .tag' $release_yaml)"
Expand Down
48 changes: 35 additions & 13 deletions images/homelab-workspace/etc/bash_completion.defaults
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
# kubectl
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
if command -v kubectl > /dev/null; then
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
fi

# helm
source <(helm completion bash)
if command -v helm > /dev/null; then
source <(helm completion bash)
fi

# kustomize
source <(kustomize completion bash)
if command -v kustomize > /dev/null; then
source <(kustomize completion bash)
fi

# terraform
complete -C /opt/tfenv/versions/$(ls /opt/tfenv/versions | sort -rn | head -1)/terraform terraform
if find /opt/tfenv/versions/ -name terraform -type f -executable > /dev/null; then
complete -C /opt/tfenv/versions/$(ls /opt/tfenv/versions | sort -rn | head -1)/terraform terraform
fi

# yq
source <(yq shell-completion bash)
if command -v yq > /dev/null; then
source <(yq shell-completion bash)
fi

# poetry
source <(poetry completions bash)
if command -v poetry > /dev/null; then
source <(poetry completions bash)
fi

# pip
source <(pip completion --bash)
if command -v pip > /dev/null; then
source <(pip completion --bash)
fi

# flux
source <(flux completion bash)
if command -v flux > /dev/null; then
source <(flux completion bash)
fi

# gh
source <(gh completion -s bash)
if command -v gh > /dev/null; then
source <(gh completion -s bash)
fi

# kind
source <(kind completion bash)
if command -v kind > /dev/null; then
source <(kind completion bash)
fi

# mc
complete -C /usr/local/sbin/mc mc
if [[ -f /usr/local/sbin/mc ]]; then
complete -C /usr/local/sbin/mc mc
fi
5 changes: 0 additions & 5 deletions images/homelab-workspace/packages/github-releases-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@
# renovate: datasource=github-releases depName=yannh/kubeconform
tag: "v0.6.7"
asset_regex: "kubeconform-linux-amd64.tar.gz"
- name: kustomize
repo: https://github.com/kubernetes-sigs/kustomize
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize extractVersion=^kustomize/(?<version>.*)$
tag: "v5.2.1"
asset_regex: ".*_linux_amd64.tar.gz"
- name: shellcheck
repo: https://github.com/koalaman/shellcheck
# renovate: datasource=github-releases depName=koalaman/shellcheck
Expand Down
5 changes: 0 additions & 5 deletions images/homelab-workspace/packages/github-releases-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@
# renovate: datasource=github-releases depName=yannh/kubeconform
tag: "v0.6.7"
asset_regex: "kubeconform-linux-arm64.tar.gz"
- name: kustomize
repo: https://github.com/kubernetes-sigs/kustomize
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize extractVersion=^kustomize/(?<version>.*)$
tag: "v5.4.3"
asset_regex: ".*_linux_arm64.tar.gz"
- name: shellcheck
repo: https://github.com/koalaman/shellcheck
# renovate: datasource=github-releases depName=koalaman/shellcheck
Expand Down

0 comments on commit aaa9162

Please sign in to comment.