-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 379e22e
Showing
11 changed files
with
328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"*/devcontainer-feature.json" | ||
], | ||
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json" | ||
} | ||
] | ||
}, | ||
"extensions": [ | ||
"mads-hartmann.bash-ide-vscode" | ||
] | ||
} | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
}, | ||
"remoteUser": "node", | ||
"updateContentCommand": "npm install -g @devcontainers/cli" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: "Release dev container features & Generate Documentation" | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Publish Features" | ||
uses: devcontainers/action@v1 | ||
with: | ||
publish-features: "true" | ||
base-path-to-features: "./src" | ||
generate-docs: "true" | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create PR for Documentation | ||
id: push_image_info | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -e | ||
echo "Start." | ||
# Configure git and Push updates | ||
git config --global user.email [email protected] | ||
git config --global user.name github-actions | ||
git config pull.rebase false | ||
branch=automated-documentation-update-$GITHUB_RUN_ID | ||
git checkout -b $branch | ||
message='Automated documentation update' | ||
# Add / update and commit | ||
git add */**/README.md | ||
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true | ||
# Push | ||
if [ "$NO_UPDATES" != "true" ] ; then | ||
git push origin "$branch" | ||
gh pr create --title "$message" --body "$message" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: "CI - Test Features" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-autogenerated: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
features: | ||
- buf-cli | ||
- dart | ||
baseImage: | ||
- debian:latest | ||
- ubuntu:latest | ||
- mcr.microsoft.com/devcontainers/base:ubuntu | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Install latest devcontainer CLI" | ||
run: npm install -g @devcontainers/cli | ||
|
||
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" | ||
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . | ||
|
||
test-scenarios: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
features: | ||
- buf-cli | ||
- dart | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Install latest devcontainer CLI" | ||
run: npm install -g @devcontainers/cli | ||
|
||
- name: "Generating tests for '${{ matrix.features }}' scenarios" | ||
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated . | ||
|
||
test-global: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Install latest devcontainer CLI" | ||
run: npm install -g @devcontainers/cli | ||
|
||
- name: "Testing global scenarios" | ||
run: devcontainer features test --global-scenarios-only . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: "Validate devcontainer-feature.json files" | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Validate devcontainer-feature.json files" | ||
uses: devcontainers/action@v1 | ||
with: | ||
validate-only: "true" | ||
base-path-to-features: "./src" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Microsoft Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# A Dev Container Features Collection | ||
|
||
This repository is based on the | ||
[the `devcontainers/features` repository](https://github.com/devcontainers/features). | ||
|
||
## Contents | ||
|
||
### [`clusterctl`](src/clusterctl/README.md) | ||
Install the `clusterctl` CLI for the Cluster API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
# `clusterctl` CLI | ||
|
||
The clusterctl CLI tool handles the lifecycle of a Cluster API management cluster. | ||
|
||
## Example Usage | ||
|
||
```json | ||
"features": { | ||
"ghcr.io/zeiss/devcontainer-features/clusterctl:1": {} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
| Options Id | Description | Type | Default Value | | ||
|-----|-----|-----|-----| | ||
| version | Choose your version | string | v1.8.3 | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "clusterctl CLI", | ||
"id": "clusterctl", | ||
"version": "1.0.1", | ||
"description": "The clusterctl CLI tool handles the lifecycle of a Cluster API management cluster.", | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"v1.8.3" | ||
], | ||
"default": "v1.8.3", | ||
"description": "Select or enter clusterctl version to install." | ||
} | ||
}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "Activating feature 'clusterctl'" | ||
|
||
# Default version | ||
VERSION=${VERSION:-"latest"} | ||
|
||
# Defailt install path | ||
BIN=${BIN:-/usr/local/bin} | ||
|
||
echo "Installing clusterctl version $VERSION" | ||
|
||
# Clean up | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
echo "Step 1, check if user is root" | ||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
echo "Step 2, check if architecture is supported" | ||
architecture="$(uname -m)" | ||
if [ "${architecture}" != "amd64" ] && [ "${architecture}" != "x86_64" ] && [ "${architecture}" != "arm64" ] && [ "${architecture}" != "aarch64" ]; then | ||
echo "(!) Architecture $architecture unsupported" | ||
exit 1 | ||
fi | ||
|
||
apt_get_update() | ||
{ | ||
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
echo "Running apt-get update..." | ||
apt-get update -y | ||
fi | ||
} | ||
|
||
# Checks if packages are installed and installs them if not | ||
check_packages() { | ||
if ! dpkg -s "$@" > /dev/null 2>&1; then | ||
apt_get_update | ||
apt-get -y install --no-install-recommends "$@" | ||
fi | ||
} | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install dependencies | ||
check_packages ca-certificates curl unzip | ||
|
||
# Install clusterctl | ||
|
||
|
||
curl -sSL "https://github.com/kubernetes-sigs/cluster-api/releases/download/${VERSION}/clusterctl-linux-${architecture}" -o "${BIN}/clusterctl" | ||
chmod +x "${BIN}/clusterctl" | ||
|
||
# Clean up | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Clean up | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as root to be able to installe dependencies, changing to sudo when installing.' | ||
fi | ||
|
||
apt_get_update() { | ||
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
echo "Running apt-get update..." | ||
if [ "$(id -u)" -ne 0 ]; then | ||
sudo apt-get update -y | ||
else | ||
apt-get update -y | ||
fi | ||
fi | ||
} | ||
|
||
check_packages() { | ||
if ! dpkg -s "$@" >/dev/null 2>&1; then | ||
apt_get_update | ||
if [ "$(id -u)" -ne 0 ]; then | ||
sudo apt-get -y install --no-install-recommends "$@" | ||
else | ||
apt-get -y install --no-install-recommends "$@" | ||
fi | ||
fi | ||
} | ||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
check_packages ca-certificates curl unzip | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
# The 'check' command comes from the dev-container-features-test-lib. | ||
check "version" clusterctl --version | ||
|
||
# Report results | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |