Skip to content

Commit a0160c3

Browse files
authored
Add cilium-cli (#4702)
1 parent 9311ca9 commit a0160c3

File tree

13 files changed

+298
-3
lines changed

13 files changed

+298
-3
lines changed

.github/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ workflows/%.yml: .ALWAYS
3232
if [[ $$enabled != "false" ]]; then \
3333
echo updating $@; \
3434
sed 's/%PACKAGE_NAME%/$*/g' package-template.yml | sed 's/%PACKAGE_JSON_NAME%/$(subst .,_,$*)/g' > $@; \
35+
@git ls-files --error-unmatch $@ &> /dev/null || git add $@; \
3536
else \
3637
echo DELETING workflow $@ because package is disabled; \
37-
rm -f $@; \
38+
git rm -f --ignore-unmatch $@; \
3839
fi
3940

4041
.PHONY : workflows .ALWAYS

.github/auto-label.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ vendor/cfssljson:
6565
vendor/chamber:
6666
- any: ["vendor/chamber/**"]
6767
all: ["!bin/**", "!tasks/**"]
68+
vendor/cilium-cli:
69+
- any: ["vendor/cilium-cli/**"]
70+
all: ["!bin/**", "!tasks/**"]
6871
vendor/cli53:
6972
- any: ["vendor/cli53/**"]
7073
all: ["!bin/**", "!tasks/**"]

.github/workflows/auto-update-packages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- cfssl
3535
- cfssljson
3636
- chamber
37+
- cilium-cli
3738
- cli53
3839
- cloud-nuke
3940
- cloudflared

.github/workflows/cilium-cli.yml

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
#
2+
# This workflow was created automatically from the `package-template.yml` by running `make -C .github workflows`
3+
# DO NOT EDIT THIS WORKFLOW, changes will be lost on the next update.
4+
#
5+
6+
name: "cilium-cli"
7+
concurrency:
8+
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }} (${{ inputs.package_version_override || 'LATEST' }}_r${{ inputs.release_number_override || '0' }})
9+
cancel-in-progress: true
10+
on:
11+
push:
12+
branches:
13+
- main
14+
15+
paths:
16+
- apk/**
17+
- deb/**
18+
- rpm/**
19+
- tasks/**
20+
- vendor/cilium-cli/**
21+
- .github/workflows/cilium-cli.yml
22+
23+
24+
pull_request:
25+
types: [opened, synchronize, reopened]
26+
paths:
27+
- apk/**
28+
- deb/**
29+
- rpm/**
30+
- tasks/**
31+
- vendor/cilium-cli/**
32+
- .github/workflows/cilium-cli.yml
33+
34+
#bridgecrew:skip=BC_REPO_GITHUB_ACTION_7:The whole point of the workflow dispatch is to feed in a version
35+
workflow_dispatch:
36+
inputs:
37+
package_version_override:
38+
description: 'Version of cilium-cli package to build. Defaults to vendor/cilium-cli/VERSION.'
39+
required: false
40+
type: string
41+
release_number_override:
42+
description: 'Zero-based release number of cilium-cli package to publish. Defaults to 0 (zero) when version is specified, ignored if not.'
43+
required: false
44+
type: string
45+
46+
env:
47+
cilium-cli_VERSION: ${{ inputs.package_version_override }}
48+
cilium-cli_RELEASE: ${{ inputs.release_number_override }}
49+
50+
jobs:
51+
# Mergify cannot distinguish between 2 jobs with the same name run from different workflows,
52+
# so each job must have a unique name for the rules to work properly.
53+
# See https://github.com/Mergifyio/mergify/discussions/5082
54+
# and https://github.com/Mergifyio/mergify/issues/5083
55+
matrix-cilium-cli:
56+
if: github.event_name != 'schedule'
57+
runs-on: ubuntu-latest
58+
outputs:
59+
package-enabled: ${{ steps.info.outputs.package_enabled }}
60+
package-matrix: ${{steps.info.outputs.package_matrix}}
61+
arch-matrix: ${{steps.info.outputs.arch_matrix}}
62+
apk-enabled: ${{ steps.info.outputs.package_enabled == 'true' && steps.info.outputs.apk_package_enabled == 'true' }}
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Export package build matrix
67+
shell: bash
68+
id: info
69+
env:
70+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
71+
run: |
72+
echo setting ouputs
73+
make -C vendor/cilium-cli info/github
74+
echo
75+
echo outputs set
76+
77+
78+
# Build for alpine linux
79+
# Kept separate because it is old and slightly different than the other package builds
80+
alpine-cilium-cli:
81+
needs: matrix-cilium-cli
82+
if: github.event_name != 'schedule' && needs.matrix-cilium-cli.outputs.apk-enabled != 'false'
83+
runs-on: ubuntu-latest
84+
strategy:
85+
matrix:
86+
# These versions must be strings. E.g. Otherwise `3.10` -> `3.1`
87+
alpine:
88+
# Now that we are just building 1 binary for all distributions, we do not
89+
# need to track which distribution we are building on.
90+
- 'alpine'
91+
env:
92+
APK_KEY_RSA: "${{ secrets.APK_KEY_RSA }}"
93+
APK_PACKAGES_PATH: ${{github.workspace}}/artifacts/${{matrix.alpine}}
94+
PACKAGER: ops@cloudposse.com
95+
PACKAGER_PRIVKEY: /dev/shm/ops@cloudposse.com.rsa
96+
PACKAGER_PUBKEY: ${{github.workspace}}/artifacts/ops@cloudposse.com.rsa.pub
97+
98+
container:
99+
image: cloudposse/packages-apkbuild:${{matrix.alpine}}
100+
credentials:
101+
username: ${{ secrets.DOCKERHUB_USERNAME }}
102+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
103+
104+
steps:
105+
# Checkout the packages repo so we can build the packages as a monorepo
106+
- name: "Checkout source code at current commit"
107+
uses: actions/checkout@v4
108+
109+
# Export the apk keys as files from secrets
110+
- name: "Export keys"
111+
run: "make -C .github/ export"
112+
113+
# Build the alpine packages for the matrix version of alpine
114+
- name: "Build alpine packages"
115+
run: "make -C vendor/${{github.workflow}} apk"
116+
117+
# Verify the packages were built or error
118+
- name: "List packages"
119+
run: 'find ${APK_PACKAGES_PATH} -type f -name \*.apk | xargs --no-run-if-empty ls -l | grep .'
120+
121+
# Export the artifact filename including path
122+
# Path must be relative to workdir for Cloudsmith action to be able to find it
123+
- name: "Set output path to artifact"
124+
id: artifact
125+
shell: bash
126+
run: |
127+
artifact=$(find artifacts/${{matrix.alpine}} -type f -name \*.apk)
128+
echo "path=$artifact" | tee -a $GITHUB_OUTPUT
129+
echo creating '"pip"' cache directory for Cloudsmith
130+
mkdir -p $HOME/.cache/pip && chmod -R 777 $HOME/.cache || echo Ignoring error creating '"pip"' cache directory
131+
132+
133+
# Determine which package organization we should use (e.g. dev or prod)
134+
- name: "Determine package repo"
135+
shell: bash
136+
id: repo
137+
run: |
138+
if [[ ${GITHUB_REF} == 'refs/heads/main' ]]; then
139+
echo "org=${{github.repository_owner}}" | tee -a $GITHUB_OUTPUT
140+
else
141+
echo "org=${{github.repository_owner}}-dev" | tee -a $GITHUB_OUTPUT
142+
fi
143+
env:
144+
GITHUB_REF: ${{ github.ref }}
145+
146+
# Publish the artifacts
147+
- name: "Push artifact to package repository"
148+
uses: cloudsmith-io/action@v0.5.4
149+
with:
150+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
151+
command: 'push'
152+
format: 'alpine'
153+
owner: '${{steps.repo.outputs.org}}' # Your Cloudsmith account name or org name (namespace)
154+
repo: 'packages' # Your Cloudsmith Repository name (slug)
155+
distro: 'alpine' # Your Distribution (i.e debian, ubuntu, alpine)
156+
release: 'any-version' # Use "any-version" if your package is compatible with more than one version of alpine linux
157+
republish: 'true' # Needed if version is not changing
158+
file: '${{steps.artifact.outputs.path}}' # Package filename (including path)
159+
no-wait-for-sync: 'true' # Skip the waiting for package synchronisation (i.e. upload only)
160+
161+
# Build packages with fpm package manager
162+
package-cilium-cli:
163+
needs: matrix-cilium-cli
164+
# Should not be needed, but without these conditions, this job would fail with an error if the matrix is []
165+
# and would run with package-type empty if matrix is ["apk"]
166+
if: >
167+
github.event_name != 'schedule' && needs.matrix-cilium-cli.outputs.package-enabled != 'false'
168+
&& needs.matrix-cilium-cli.outputs.package-matrix != '[]' && needs.matrix-cilium-cli.outputs.package-matrix != '["apk"]'
169+
170+
strategy:
171+
matrix:
172+
package-type: ${{ fromJSON(needs.matrix-cilium-cli.outputs.package-matrix) }}
173+
arch: ${{ fromJSON(needs.matrix-cilium-cli.outputs.arch-matrix) }}
174+
exclude:
175+
- package-type: 'apk'
176+
include:
177+
# Default value for runs-on. Original matrix values will not be overridden, but added ones (like runs-on) can be.
178+
# See https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
179+
- runs-on: "self-hosted-arm64-large"
180+
# By including `arch: amd64` here, we override the `runs-on` value when the matrix `arch` is `amd64`.
181+
# This also forces the matrix to include `arch: amd64` even if it is not in the original matrix.
182+
# This is why we do not default for amd64 and then override for arm64. (Because it would force arm64 to be included, and some tools are not available for arm64.)
183+
- arch: amd64
184+
runs-on: "ubuntu-latest"
185+
runs-on: ${{ matrix.runs-on }}
186+
env:
187+
# We are in a bit of a bind here because of how GitHub actions work as of 2020-11-19
188+
# Although the "workspace" is mounted to the container, it is not mounted
189+
# at `/github/workspace` or ${{github.workspace}}, although through some
190+
# mechanism, an environment variable whose value starts with ${{github.workspace}}
191+
# will have ${{github.workspace}} replaced with the correct mount point.
192+
#
193+
# We need an absolute path for the package build system, since every build happens
194+
# in a different directory, but because the mount point changes, we also
195+
# need a path relative to the initial working directory to communicate between
196+
# the package building container and the cloudsmith action.
197+
PACKAGES_PATH: ${{github.workspace}}/artifacts/${{matrix.package-type}}/any-version
198+
PACKAGE_RELPATH: artifacts/${{matrix.package-type}}/any-version
199+
200+
# Unfortunately, there is no reasonable way to configure the docker image tag based on the package-type
201+
container:
202+
image: cloudposse/packages-${{matrix.package-type}}build:latest
203+
credentials:
204+
username: ${{ secrets.DOCKERHUB_USERNAME }}
205+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
206+
207+
steps:
208+
# Checkout the packages repo so we can build the packages as a monorepo
209+
- name: "Checkout source code at current commit"
210+
uses: actions/checkout@v4
211+
212+
# Build the packages for the matrix version
213+
- name: "Build ${{matrix.package-type}} packages"
214+
shell: bash
215+
run: |
216+
echo Current directory is $(pwd)
217+
[[ $PACKAGES_PATH =~ ^$(pwd) ]] || { echo Package dir \"$PACKAGES_PATH\" not beneath workdir \"$(pwd)\" >&2; exit 1; }
218+
make -C vendor/${{github.workflow}} ${{matrix.package-type}}
219+
220+
# Export the artifact filename including path
221+
- name: "Set output path to artifact"
222+
id: artifact
223+
shell: bash
224+
run: |
225+
[[ -n $PACKAGE_RELPATH ]] || { echo Error: PACKAGE_RELPATH is not set >&2; exit 1; }
226+
packages=($(find ${PACKAGE_RELPATH} -type f -name \*.${{matrix.package-type}}))
227+
echo List packages found:
228+
printf "%s\n" "${packages[@]}" | xargs --no-run-if-empty ls -l
229+
echo Error if not exactly 1 package found
230+
(( ${#packages[@]} == 1 )) || { echo "Error: other than 1 package found (${#packages[@]})" >&2; exit 1; }
231+
232+
echo "setting output"
233+
echo "path=$packages" | tee -a $GITHUB_OUTPUT
234+
235+
echo creating '"pip"' cache directory for Cloudsmith
236+
mkdir -p $HOME/.cache/pip && chmod -R 777 $HOME/.cache || echo Ignoring error creating '"pip"' cache directory
237+
238+
# Determine which package organization we should use (e.g. dev or prod)
239+
- name: "Determine package repo"
240+
shell: bash
241+
id: repo
242+
run: |
243+
if [[ ${GITHUB_REF} == 'refs/heads/main' ]]; then
244+
echo "org=${{github.repository_owner}}" | tee -a $GITHUB_OUTPUT
245+
else
246+
echo "org=${{github.repository_owner}}-dev" | tee -a $GITHUB_OUTPUT
247+
fi
248+
env:
249+
GITHUB_REF: ${{ github.ref }}
250+
251+
# Publish the artifacts
252+
- name: "Push artifact to package repository"
253+
uses: cloudsmith-io/action@v0.5.4
254+
with:
255+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
256+
command: 'push'
257+
format: '${{matrix.package-type}}'
258+
owner: '${{steps.repo.outputs.org}}' # Your Cloudsmith account name or org name (namespace)
259+
repo: 'packages' # Your Cloudsmith Repository name (slug)
260+
distro: 'any-distro' # Use "any-distro" since our package is compatible with more than more distribution
261+
release: 'any-version' # Use "any-version" since our package is compatible with more than more version
262+
republish: 'true' # Needed if version is not changing
263+
file: '${{steps.artifact.outputs.path}}' # Package filename (including path)
264+
no-wait-for-sync: 'true' # Skip the waiting for package synchronisation (i.e. upload only)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ Here are some solutions to several common problems that may occur when adding a
342342
[![cfssl](https://github.com/cloudposse/packages/actions/workflows/cfssl.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acfssl)* | 1.6.5 | Cloudflare's PKI and TLS toolkit
343343
[![cfssljson](https://github.com/cloudposse/packages/actions/workflows/cfssljson.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acfssljson)* | 1.6.5 | Cloudflare's PKI and TLS toolkit json parser
344344
[![chamber](https://github.com/cloudposse/packages/actions/workflows/chamber.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Achamber) | 2.14.1 | CLI for managing secrets
345+
[![cilium-cli](https://github.com/cloudposse/packages/actions/workflows/cilium-cli.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acilium-cli) | 0.16.7 | CLI to install, manage & troubleshoot Kubernetes clusters running Cilium
345346
[![cli53](https://github.com/cloudposse/packages/actions/workflows/cli53.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acli53) | 0.8.22 | Command line tool for Amazon Route 53
346347
[![cloud-nuke](https://github.com/cloudposse/packages/actions/workflows/cloud-nuke.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acloud-nuke) | 0.35.0 | Tool for wiping an aws account DANGER absolutely do not use in production
347348
[![cloudflared](https://github.com/cloudposse/packages/actions/workflows/cloudflared.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acloudflared) | 2024.5.0 | Argo Tunnel client

docs/badges.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
[![cfssl](https://github.com/cloudposse/packages/actions/workflows/cfssl.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acfssl)* | 1.6.5 | Cloudflare's PKI and TLS toolkit
1616
[![cfssljson](https://github.com/cloudposse/packages/actions/workflows/cfssljson.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acfssljson)* | 1.6.5 | Cloudflare's PKI and TLS toolkit json parser
1717
[![chamber](https://github.com/cloudposse/packages/actions/workflows/chamber.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Achamber) | 2.14.1 | CLI for managing secrets
18+
[![cilium-cli](https://github.com/cloudposse/packages/actions/workflows/cilium-cli.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acilium-cli) | 0.16.7 | CLI to install, manage & troubleshoot Kubernetes clusters running Cilium
1819
[![cli53](https://github.com/cloudposse/packages/actions/workflows/cli53.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acli53) | 0.8.22 | Command line tool for Amazon Route 53
1920
[![cloud-nuke](https://github.com/cloudposse/packages/actions/workflows/cloud-nuke.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acloud-nuke) | 0.35.0 | Tool for wiping an aws account DANGER absolutely do not use in production
2021
[![cloudflared](https://github.com/cloudposse/packages/actions/workflows/cloudflared.yml/badge.svg?branch=main)](https://github.com/cloudposse/packages/actions?query=workflow%3Acloudflared) | 2024.5.0 | Argo Tunnel client

docs/targets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ aws-vault 7.2.0 A vault for securely storing and accessing
2020
cfssl* 1.6.5 Cloudflare's PKI and TLS toolkit
2121
cfssljson* 1.6.5 Cloudflare's PKI and TLS toolkit json parser
2222
chamber 2.14.1 CLI for managing secrets
23+
cilium-cli 0.16.7 CLI to install, manage & troubleshoot Kubernetes clusters running Cilium
2324
cli53 0.8.22 Command line tool for Amazon Route 53
2425
cloud-nuke 0.35.0 Tool for wiping an aws account DANGER absolutely do not use in production
2526
cloudflared 2024.5.0 Argo Tunnel client

tasks/Makefile.package

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ $(LOCAL_BIN)/vert:
124124

125125
DESCRIPTION:
126126
@# Use `tr -d '\"$'` to help guard against malicious input
127-
@github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "index" .description | tr -d '\"$$' | tee DESCRIPTION
127+
@github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "index" .description | tr -d '\"$$' | tee $@
128+
git add $@
128129

129130
# In order to support static configuration of version, the VERSION file should be
130131
# considered up-to-date unless explicitly updated via the "update" target
131132
# VERSION:
132133

133134
LICENSE:
134-
@github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "license" .license.spdx_id | tr '[:lower:]' '[:upper:]' | tee LICENSE
135+
@github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "license" .license.spdx_id | tr '[:lower:]' '[:upper:]' | tee $@
136+
git add $@
135137

136138
RELEASE: VERSION LICENSE DESCRIPTION
137139
@if [ ! -f RELEASE ]; then \
@@ -149,6 +151,7 @@ RELEASE: VERSION LICENSE DESCRIPTION
149151

150152
init: AUTO_UPDATE_ENABLED=true
151153
init: LICENSE DESCRIPTION $(PACKAGE_VERSION_TARGET) RELEASE
154+
@git ls-files --error-unmatch "VERSION" &> /dev/null || git add VERSION
152155

153156
update: $(PACKAGE_VERSION_TARGET) RELEASE
154157

vendor/cilium-cli/DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLI to install, manage & troubleshoot Kubernetes clusters running Cilium

vendor/cilium-cli/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APACHE-2.0

vendor/cilium-cli/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Package details
3+
export VENDOR := cilium
4+
export PACKAGE_EXE := cilium
5+
export PACKAGE_HOMEPAGE_URL := https://cilium.io/
6+
# https://github.com/cilium/cilium-cli/releases/download/v0.16.7/cilium-linux-amd64.tar.gz
7+
export DOWNLOAD_URL ?= $(PACKAGE_REPO_URL)/releases/download/v$(PACKAGE_VERSION)/$(PACKAGE_EXE)-$(OS)-$(ARCH).tar.gz
8+
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary
9+
10+
include ../../tasks/Makefile.vendor_includes
11+
12+
install:
13+
$(call download_tarball)
14+
15+
test:
16+
$(PACKAGE_EXE) version --client && $(PACKAGE_EXE) version --client | grep -q -F $(PACKAGE_VERSION)

vendor/cilium-cli/RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

vendor/cilium-cli/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.16.7

0 commit comments

Comments
 (0)