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

✨ Add Cloud Platform feature #10

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions features/src/cloud-platform/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- markdownlint-disable MD003 -->
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.0.1] - 2024-01-30

### Added

- Initial release of feature
13 changes: 13 additions & 0 deletions features/src/cloud-platform/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"id": "cloud-platform",
"version": "0.0.1",
"name": "Cloud Platform",
"description": "Installs the Cloud Platform CLI",
"options": {
"cloudPlatformCliVersion": {
"type": "string",
"description": "Version of the Cloud Platform CLI to install",
"default": "latest"
}
}
}
32 changes: 32 additions & 0 deletions features/src/cloud-platform/install-cloud-platform-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
# file not accessible until being built
source /usr/local/bin/devcontainer-utils

get_system_architecture

GITHUB_REPOSITORY="ministryofjustice/cloud-platform-cli"
VERSION=${CLOUDPLATFORMCLIVERSION:-"latest"}

if [[ "${VERSION}" == "latest" ]]; then
get_github_latest_tag "${GITHUB_REPOSITORY}"
VERSION="${GITHUB_LATEST_TAG}"
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}"
else
# shellcheck disable=SC2034
VERSION_STRIP_V="${VERSION#v}"
fi

curl --fail-with-body --location "https://github.com/${GITHUB_REPOSITORY}/releases/download/${VERSION}/cloud-platform-cli_${VERSION}_linux_${ARCHITECTURE}.tar.gz" \
--output "cloud-platform-cli_${VERSION}_linux_${ARCHITECTURE}.tar.gz"

tar --gzip --extract --file "cloud-platform-cli_${VERSION}_linux_${ARCHITECTURE}.tar.gz"

install --owner=vscode --group=vscode --mode=775 cloud-platform /usr/local/bin/cloud-platform

install --owner=vscode --group=vscode --mode=775 completions/cloud-platform.zsh /usr/local/share/zsh/site-functions/_cloud-platform

rm --recursive --force LICENSE README.md completions "cloud-platform-cli_${VERSION}_linux_${ARCHITECTURE}.tar.gz"
8 changes: 8 additions & 0 deletions features/src/cloud-platform/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# shellcheck source=/dev/null
# file not accessible until being built
source /usr/local/bin/devcontainer-utils

logger "info" "Installing Cloud Platform CLI (version: ${CLOUDPLATFORMCLIVERSION})"
bash "$(dirname "${0}")"/install-cloud-platform-cli.sh
12 changes: 12 additions & 0 deletions features/test/cloud-platform/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
# file only accessible when using devcontainer CLI
source dev-container-features-test-lib

check "cloud-platform version" cloud-platform version
check "cloud-platform completions existence" stat /usr/local/share/zsh/site-functions/_cloud-platform

reportResults
Loading