Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release PR #145

Merged
merged 48 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c635cb2
Merge pull request #102 from dodevops/main
dploeger Nov 15, 2023
90f5cf0
feat: Adding azure relogin feature
timdeluxe Dec 6, 2023
12f9af0
feat: Support krew
dploeger Dec 7, 2023
6d090e9
docs: Automatic docs update
Dec 7, 2023
97218e3
Merge pull request #104 from dodevops/feature/dpr/krew
dploeger Dec 8, 2023
77b7e8a
Merge pull request #103 from dodevops/feature/te/azure-relogin
timdeluxe Dec 9, 2023
271e8d3
feat: Optimized test runner to work more smoothly
dploeger Dec 11, 2023
876a83c
fix: Removed bitwarden because of very unstable implementation
dploeger Dec 18, 2023
fa30818
fix: Fixed krew installation messing up the path variable
dploeger Dec 18, 2023
979dcdf
fix: Updated goss to work with optimized testrunner
dploeger Dec 18, 2023
4686af2
fix: Moved integration skip to the bash version of the feature test
dploeger Dec 18, 2023
dbbfa9b
feat: Supports azure arm64 image
dploeger Dec 19, 2023
e69fa5f
feat: Support ARM environment variable instead of special AZ variables
dploeger Dec 19, 2023
72662a1
docs: Automatic docs update
Dec 19, 2023
fef840a
docs: added note about timeframe for deprecation
dploeger Dec 21, 2023
8a7dc42
fix: Fixed azure flavourinit
dploeger Dec 27, 2023
8bf0200
fix: Fixed azure relogin script escaping
dploeger Dec 29, 2023
40701ff
chore: Added CODEOWNERS and updated dependencies
dploeger Dec 29, 2023
02155ce
chore: Further updates
dploeger Dec 29, 2023
1b70bfa
feat: Support for k9s
dploeger Dec 29, 2023
d314dce
docs: Automatic docs update
Dec 29, 2023
11cdb35
chore: Corrected CODEOWNERS file
dploeger Dec 29, 2023
ed01003
chore: Added dependabot configuration
dploeger Dec 29, 2023
e770f46
chore: Modified dependabot to only use security updates
dploeger Dec 29, 2023
09506e3
chore: Only run cloud tests when not originating from a fork
dploeger Jan 3, 2024
532aa8d
chore(deps): bump tj-actions/changed-files in /.github/workflows
dependabot[bot] Jan 3, 2024
49df0b9
fix: Put a sleep in the RunCommand implementation
dploeger Jan 5, 2024
fb52d2a
chore: Disabling AWS tests for pricing reasons
dploeger Mar 4, 2024
1b8ec9d
fix: Correct TENANTID variable after deprecation
dploeger Mar 11, 2024
cbabee6
feat: Add missing annotations to multi arch images
dploeger Apr 10, 2024
ceb9a18
chore(deps-dev): bump vite from 4.4.9 to 4.5.2 in /ccc-client
dependabot[bot] Jan 20, 2024
5af3b64
fix: Fixing README template section about building README.md
timdeluxe Jun 13, 2024
380fb7c
docs: Automatic docs update
Jun 13, 2024
251dad5
feat: Adding sops feature
timdeluxe Jun 13, 2024
c355007
Merge pull request #143 from dodevops/feature/te/sops
timdeluxe Jun 21, 2024
9c84998
feat: Optimized documentation and feature utils
dploeger Apr 17, 2024
782c4fa
docs: Automatic docs update
Apr 17, 2024
6423833
fix: Fixed test runner not ignoring .-directories
dploeger Apr 17, 2024
2ea77f6
fix: Fixed test runner not ignoring .-directories
dploeger Apr 17, 2024
ac7b3e4
fix: Remove template from doc generation
dploeger Apr 18, 2024
224fadb
fix: Some PR fixes
dploeger Apr 18, 2024
e573a1d
fix: Some PR fixes
dploeger Apr 18, 2024
4fb0418
docs: Automatic docs update
Apr 18, 2024
25c0841
docs: Fixed generated readme
dploeger Jun 26, 2024
c4aba15
feat: Include cmctl
dploeger Jun 27, 2024
bc91cd5
docs: Automatic docs update
Jun 27, 2024
61efb42
Merge pull request #144 from dodevops/bugfix/te/doc-mkdoc-fix
timdeluxe Jun 27, 2024
1325127
Merge branch 'refs/heads/main' into develop
dploeger Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Following features and tools are supported:
* 🐟 Fish Shell
* 📷 AzCopy
* 🪪 Certificates
* 📨 cmctl
* ⚙️ Direnv
* ⛵️ Helm
* 🛠 JQ
Expand All @@ -30,6 +31,7 @@ Following features and tools are supported:
* 📦 Packages
* 📦 Packer
* 👟 Run
* 🔑 sops
* 📜 Stern
* 🌏 Terraform
* 🐗 Terragrunt
Expand All @@ -53,6 +55,7 @@ Following features and tools are supported:
* [Fish Shell](#_fish)
* [AzCopy](#azcopy)
* [Certificates](#certificates)
* [cmctl](#cmctl)
* [Direnv](#direnv)
* [Helm](#helm)
* [JQ](#jq)
Expand All @@ -64,6 +67,7 @@ Following features and tools are supported:
* [Packages](#packages)
* [Packer](#packer)
* [Run](#run)
* [sops](#sops)
* [Stern](#stern)
* [Terraform](#terraform)
* [Terragrunt](#terragrunt)
Expand Down Expand Up @@ -393,6 +397,17 @@ Adds specified trusted certificate authorities into the container
(optional). Defaults to `/certificates`. If something different than the default is used, the volume-target needs to be adapted to
the same directory

### <a id="cmctl"></a> cmctl

Installs the cert-manager Command Line Tool

#### Configuration

* USE_cmctl: Enable this feature
* DEBUG_cmctl: Debug this feature
* Environment CMCTL_VERSION: Version of cmctl to install (optional)
Defaults to `latest`

### <a id="direnv"></a> Direnv

Installs [Direnv](https://direnv.net/)
Expand Down Expand Up @@ -540,6 +555,17 @@ Runs commands inside the shell when entering the cloud control container
* DEBUG_run: Debug this feature
* Environment RUN_COMMANDS: Valid shell commands to run

### <a id="sops"></a> sops

Installs [sops](https://github.com/getsops/sops)

#### Configuration

* USE_sops: Enable this feature
* DEBUG_sops: Debug this feature
* Environment SOPS_VERSION (required): Valid sops version (e.g. 3.8.1)
* Environment specific for the key you use, see [sops documentation](https://github.com/getsops/sops?tab=readme-ov-file#22encrypting-using-age)

### <a id="stern"></a> Stern

Installs [stern](https://github.com/stern/stern), a multi pod and container log tailing for Kubernetes
Expand Down Expand Up @@ -630,14 +656,24 @@ Installs the [YAML parser and processor yq](https://github.com/mikefarah/yq)

## Development

*CloudControl* supports a decoupled development of features and flavours. If you're missing something, just fork this
repository, create a subfolder for your new feature under "features" and add these files:
*CloudControl* supports a decoupled development of features and flavours.

### Features

If you're missing a feature, just fork this repository, copy the feature template from features/.template into a
new subfolder, check out the comments in the example files, and modify them to your needs.

These files make up a feature:

* `feature.yaml`: A descriptor for your feature with a title, a description and configuration notes
* `install.sh`: A shell script that is run by CloudControlCenter and should install everything you need
for your new feature
* `motd.sh`: (optional) If you want to show some information to the users upon login, put them here.

And optional, but recommended [integration tests](integration-testing) in a `.goss` folder.

### Flavours

If you need another flavour (aka cloud provider), add a new subdirectory under "flavour" and add a flavour.yaml describing
your flavour the same way as a feature. For the rest of the files, please check out existing flavours for details. Please,
include a sample configuration for your flavour to make it easier for other people to work with it.
Expand Down Expand Up @@ -775,7 +811,7 @@ you can inspect the failing container as well.

To rebuild this documentation, first compile the documentation maker:

docker run --rm -e GOOS=[os, e.g. darwin, linux, windows] -e GOARCH=[architecture, e.g. arm64, amd64] -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.19-alpine go run cmd/doc/mkdoc
docker run --rm -e GOOS=[os, e.g. darwin, linux, windows] -e GOARCH=[architecture, e.g. arm64, amd64] -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.19-alpine go build cmd/doc/mkdoc.go

Then run it to rebuild README.md based on README.md.gotmpl:

Expand Down
16 changes: 13 additions & 3 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,24 @@ environment variable in the docker-compose file. Then you can debug with the run

## Development

*CloudControl* supports a decoupled development of features and flavours. If you're missing something, just fork this
repository, create a subfolder for your new feature under "features" and add these files:
*CloudControl* supports a decoupled development of features and flavours.

### Features

If you're missing a feature, just fork this repository, copy the feature template from features/.template into a
new subfolder, check out the comments in the example files, and modify them to your needs.

These files make up a feature:

* `feature.yaml`: A descriptor for your feature with a title, a description and configuration notes
* `install.sh`: A shell script that is run by CloudControlCenter and should install everything you need
for your new feature
* `motd.sh`: (optional) If you want to show some information to the users upon login, put them here.

And optional, but recommended [integration tests](integration-testing) in a `.goss` folder.

### Flavours

If you need another flavour (aka cloud provider), add a new subdirectory under "flavour" and add a flavour.yaml describing
your flavour the same way as a feature. For the rest of the files, please check out existing flavours for details. Please,
include a sample configuration for your flavour to make it easier for other people to work with it.
Expand Down Expand Up @@ -428,7 +438,7 @@ you can inspect the failing container as well.

To rebuild this documentation, first compile the documentation maker:

docker run --rm -e GOOS=[os, e.g. darwin, linux, windows] -e GOARCH=[architecture, e.g. arm64, amd64] -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.19-alpine go run cmd/doc/mkdoc
docker run --rm -e GOOS=[os, e.g. darwin, linux, windows] -e GOARCH=[architecture, e.g. arm64, amd64] -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.19-alpine go build cmd/doc/mkdoc.go

Then run it to rebuild README.md based on README.md.gotmpl:

Expand Down
46 changes: 43 additions & 3 deletions assets/feature-installer-utils.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# Execute a command and if it fails, return its output and exit
# Set some informative variables

# The flavour we're running on
FLAVOUR="$(cat /home/cloudcontrol/flavour)"
export FLAVOUR

# The path to install software binaries to
export BINPATH="/home/cloudcontrol/bin"

export TEMPDIR=""

# Prepare feature installation. Will create a temporary directory and change to it
function prepare {
TEMPDIR=$(mktemp -d)
cd "${TEMPDIR}" || exit
}

# Cleanup the previously generated temporary directory
function cleanup {
cd - &>/dev/null || exit
rm -rf "${TEMPDIR}"
}

# Usage: execHandle MESSAGE COMMAND...
#
# Output MESSAGE and then execute COMMAND. If it fails, return its output and exit
function execHandle {
TITLE=$1
shift
Expand Down Expand Up @@ -38,6 +63,7 @@ function waitForMfaCode {
echo "[VALID_CODE] Valid code entered. Thank you."
}

# Get the hardware platform we're on and translate it to the usual platform names used in most software
function getPlatform {
if [ "$(uname -m)" == 'aarch64' ]
then
Expand All @@ -50,18 +76,32 @@ function getPlatform {
fi
}

# Usage: checkAndCleanVersion VERSION
#
# Includes checks for version numbers and removes the "v" prefix from it to have a homogeneous version scheme
# throughout CloudControl.
function checkAndCleanVersion {
VERSION=$1
if [ "${VERSION:0:1}" == "v" ]
then
echo "[DEPRECATION WARNING] Versions with a \"v\" prefix are deprecated and will be removed in CloudControl 4.0. Please only use versions without the \"v\" prefix. (Got \"${VERSION}\")" >&2
echo "[DEPRECATION WARNING] Versions with a \"v\" prefix are deprecated and will be removed in CloudControl 6.0.0 Please only use versions without the \"v\" prefix. (Got \"${VERSION}\")" >&2
echo "${VERSION/#v/}"
else
echo "${VERSION}"
fi
}

# Usage: download URL FILENAME
#
# Downloads the given URL into the provided FILENAME
function download {
URL=$1
FILENAME=$2
execHandle "Downloading ${FILENAME} from ${URL}" curl -f -s -L "${URL}" -o "${FILENAME}"
}

# Usage: downloadFromGithub USER REPO VERSION PACKAGE_PREFIX PACKAGE_SUFFIX TARGET
#
# Downloads a release package from github using the common architecture names
# The package will be downloaded from github.com/USER/REPO/releases/VERSION/download/PACKAGE to the given TARGET file
# where PACKAGE consists of PACKAGE_PREFIXARCHITECTURE.PACKAGE_SUFFIX.
Expand All @@ -77,4 +117,4 @@ function downloadFromGithub {
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
PACKAGE="${PACKAGE_PREFIX}${ARCH}.${PACKAGE_SUFFIX}"
execHandle "Downloading ${USER}/${REPO}@${VERSION}" curl -f -s -L "https://github.com/${USER}/${REPO}/releases/${VERSION}/download/${PACKAGE}" --output "${TARGET}"
}
}
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

# CloudControl build script
# Usage:
#
Expand Down Expand Up @@ -27,8 +29,8 @@ for FLAVOUR in ${FLAVOURS}
do
cat build/Dockerfile.prefix > Dockerfile
cat "flavour/${FLAVOUR}/Dockerfile.flavour" >> Dockerfile
cat build/Dockerfile.suffix.mo | docker run --rm -i -e FLAVOUR=${FLAVOUR} -e BUILD_DATE=$(date -Iseconds) metal3d/mo >> Dockerfile
docker build --pull . -t "ghcr.io/dodevops/cloudcontrol-${FLAVOUR}:${TAG}"
cat build/Dockerfile.suffix.mo | docker run --rm -i -e FLAVOUR=${FLAVOUR} -e BUILD_DATE=$(date -Iseconds) ghcr.io/tests-always-included/mo:3.0.5 >> Dockerfile
docker build --pull . --no-cache -t "ghcr.io/dodevops/cloudcontrol-${FLAVOUR}:${TAG}"
done

if [ -e Dockerfile.sav ] ; then
Expand Down
3 changes: 3 additions & 0 deletions cmd/doc/mkdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func fetchDocData(basePath string, filenamePattern string) (map[string]internal.
return docDatas, err
} else {
for _, dir := range subDirs {
if filepath.Base(dir) == ".template" {
continue
}
if _, err := os.Stat(filepath.Join(dir, filenamePattern)); err == nil {
if yamlFile, err := os.ReadFile(filepath.Join(dir, filenamePattern)); err != nil {
return docDatas, err
Expand Down
8 changes: 5 additions & 3 deletions cmd/tests/test-features.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func getFeatures(flavour string) []lib.Feature {
funk.FilterString(
featuresGlob,
func(value string) bool {
if correctPathRegexp.Match([]byte(filepath.Dir(value))) {
if correctPathRegexp.Match([]byte(filepath.Base(value))) {
if yamlFile, err := os.ReadFile(filepath.Join(value, "feature.yaml")); err != nil {
return false
} else {
Expand Down Expand Up @@ -225,8 +225,10 @@ func main() {
os.Exit(1)
}

features := getFeatures(*flavour)

for _, includeFeature := range *includeFeatures {
if !funk.Contains(getFeatures(*flavour), func(feature lib.Feature) bool {
if !funk.Contains(features, func(feature lib.Feature) bool {
return feature.Name == includeFeature
}) {
logrus.Errorf("%s is not a known feature", includeFeature)
Expand All @@ -236,7 +238,7 @@ func main() {
}

for _, excludeFeature := range *excludeFeatures {
if !funk.Contains(getFeatures(*flavour), func(feature lib.Feature) bool {
if !funk.Contains(features, func(feature lib.Feature) bool {
return feature.Name == excludeFeature
}) {
logrus.Errorf("%s is not a known feature", excludeFeature)
Expand Down
18 changes: 18 additions & 0 deletions feature/.template/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This is the metadata manifest for a feature. Configure it for the feature to be included in CloudControl
# In your new feature, please remove all descriptive comments from the template.

# Please use an emoji character as a meaningful logo for your feature
icon: "🫥"

# Set the title for this feature
title: "Template"

# Set the description of the feature in Markdown. Be sure to include links to websites of the software the feature
# installs or configures
description: "Does some awesome stuff"

# Use the configuration key to list additional configuration options that you're providing in your feature
configuration:
#- |
# Environment EXAMPLE_ENVIRONMENT: This environment variable is used in the feature to do xyz (optional)
# Defaults to `abc`
2 changes: 2 additions & 0 deletions feature/.template/goss/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Setup required environment for test
export EXAMPLE_ENVIRONMENT=something
5 changes: 5 additions & 0 deletions feature/.template/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
command:
test:
# Run ls / after installing the feature and if that returns successfully, the test is successful
exec: "ls /"
exit-status: 0
27 changes: 27 additions & 0 deletions feature/.template/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# The installer script for your feature, which is called in the init phase of CloudControl

# Include the feature installer utils which include helpers for the installation of your feature
# See /assets/feature-installer-utils.sh

. /feature-installer-utils.sh

# Prepare a workspace for installing the feature
prepare

if [ "X${FLAVOUR}X" == "XsimpleX" ]
then
# Do specific things for the simple flavour
download "https://example.com/my-tool-for-simple.tar.gz" tool.tar.gz
elif [[ "X${FLAVOR}X" =~ X(azure|gcloud)X ]]
then
# Do specific things for other flavours
download "https://example.com/my-tool-for-others.tar.gz" tool.tar.gz
fi

# Do other things
execHandle "Extracting tool" tar xzf tool.tar.gz
execHandle "Making tool executable" chmod +x tool
execHandle "Copying tool to ${BINPATH}" cp tool "${BINPATH}"

# Cleanup what we did
cleanup
7 changes: 7 additions & 0 deletions feature/cmctl/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
icon: "📨"
title: "cmctl"
description: "Installs the cert-manager Command Line Tool"
configuration:
- |
Environment CMCTL_VERSION: Version of cmctl to install (optional)
Defaults to `latest`
6 changes: 6 additions & 0 deletions feature/cmctl/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
cmctl:
exec: "/home/cloudcontrol/bin/cmctl version --client"
stdout:
- "Client Version"
exit-status: 0
9 changes: 9 additions & 0 deletions feature/cmctl/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
. /feature-installer-utils.sh

# Prepare a workspace for installing the feature
prepare

download "https://github.com/cert-manager/cmctl/releases/${CMCTL_VERSION:-latest}/download/cmctl_linux_$(getPlatform)" cmctl
execHandle "Making cmctl executable" chmod +x cmctl
execHandle "Copying tool to ${BINPATH}" cp cmctl "${BINPATH}"
cleanup
6 changes: 6 additions & 0 deletions feature/sops/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
icon: "🔑"
title: "sops"
description: "Installs [sops](https://github.com/getsops/sops)"
configuration:
- "Environment SOPS_VERSION (required): Valid sops version (e.g. 3.8.1)"
- "Environment specific for the key you use, see [sops documentation](https://github.com/getsops/sops?tab=readme-ov-file#22encrypting-using-age)"
1 change: 1 addition & 0 deletions feature/sops/goss/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOPS_VERSION=3.8.1
6 changes: 6 additions & 0 deletions feature/sops/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
sops:
exec: "/home/cloudcontrol/bin/sops --version"
exit-status: 0
stdout:
- "sops"
Loading
Loading