forked from kompiro/asdf-docker-compose-v1
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate asdf-docker-compose-v1 plugin from template.
- Loading branch information
Hiroki Kondo
committed
Sep 7, 2021
0 parents
commit aa1c8c3
Showing
18 changed files
with
387 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,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,27 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "" | ||
labels: bug | ||
assignees: "" | ||
--- | ||
|
||
**Describe the bug** | ||
|
||
<!-- A clear and concise description of what the bug is. --> | ||
|
||
**Steps to reproduce** | ||
|
||
<!-- Steps to reproduce the behavior: --> | ||
|
||
**Expected behavior** | ||
|
||
<!-- A clear and concise description of what you expected to happen. --> | ||
|
||
**Screenshots** | ||
|
||
<!-- If applicable, add screenshots to help explain your problem. --> | ||
|
||
**Additional context** | ||
|
||
<!-- Add any other context about the problem here. --> |
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,23 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "" | ||
labels: enhancement | ||
assignees: "" | ||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
|
||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> | ||
|
||
**Describe the solution you'd like** | ||
|
||
<!-- A clear and concise description of what you want to happen. --> | ||
|
||
**Describe alternatives you've considered** | ||
|
||
<!-- A clear and concise description of any alternative solutions or features you've considered. --> | ||
|
||
**Additional context** | ||
|
||
<!-- Add any other context or screenshots about the feature request here. --> |
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,34 @@ | ||
<!--- Provide a general summary of your changes in the Title above --> | ||
|
||
## Description | ||
|
||
<!--- Describe your changes in detail --> | ||
|
||
## Motivation and Context | ||
|
||
<!--- Why is this change required? What problem does it solve? --> | ||
<!--- If it fixes an open issue, please link to the issue here. --> | ||
|
||
## Types of changes | ||
|
||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> | ||
|
||
- [ ] Bug fix (non-breaking change which fixes an issue) | ||
- [ ] New feature (non-breaking change which adds functionality) | ||
- [ ] Breaking change (fix or feature that would cause existing functionality to change) | ||
|
||
## Usage examples | ||
|
||
<!--- Provide examples of intended usage --> | ||
|
||
## How Has This Been Tested? | ||
|
||
<!--- Please describe in detail how you tested your changes. --> | ||
|
||
## Checklist: | ||
|
||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. --> | ||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> | ||
|
||
- [ ] I have updated the documentation accordingly. | ||
- [ ] I have added tests to cover my changes. |
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,22 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
plugin_test: | ||
name: asdf plugin test | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: asdf_plugin_test | ||
uses: asdf-vm/actions/plugin-test@v1 | ||
with: | ||
command: docker-compose version |
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,36 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install asdf dependencies | ||
uses: asdf-vm/actions/install@v1 | ||
|
||
- name: Run ShellCheck | ||
run: scripts/shellcheck.bash | ||
|
||
shellfmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install asdf dependencies | ||
uses: asdf-vm/actions/install@v1 | ||
|
||
- name: List file to shfmt | ||
run: shfmt -f . | ||
|
||
- name: Run shfmt | ||
run: scripts/shfmt.bash | ||
|
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,14 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GoogleCloudPlatform/release-please-action@v2 | ||
with: | ||
release-type: simple |
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,2 @@ | ||
shellcheck 0.7.2 | ||
shfmt 3.3.0 |
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,23 @@ | ||
TODO: INSERT YOUR NAME COPYRIGHT YEAR | ||
|
||
MIT License | ||
|
||
Copyright (c) [year] [fullname] | ||
|
||
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,60 @@ | ||
<div align="center"> | ||
|
||
# asdf-docker-compose-v1 [![Build](https://github.com/kompiro/asdf-docker-compose-v1/actions/workflows/build.yml/badge.svg)](https://github.com/kompiro/asdf-docker-compose-v1/actions/workflows/build.yml) [![Lint](https://github.com/kompiro/asdf-docker-compose-v1/actions/workflows/lint.yml/badge.svg)](https://github.com/kompiro/asdf-docker-compose-v1/actions/workflows/lint.yml) | ||
|
||
|
||
[docker-compose-v1](https://github.com/kompiro/docker-compose-v1) plugin for the [asdf version manager](https://asdf-vm.com). | ||
|
||
</div> | ||
|
||
# Contents | ||
|
||
- [Dependencies](#dependencies) | ||
- [Install](#install) | ||
- [Why?](#why) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
# Dependencies | ||
|
||
- `bash`, `curl`, `tar`: generic POSIX utilities. | ||
- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x. | ||
|
||
# Install | ||
|
||
Plugin: | ||
|
||
```shell | ||
asdf plugin add docker-compose-v1 | ||
# or | ||
asdf plugin add docker-compose-v1 https://github.com/kompiro/asdf-docker-compose-v1.git | ||
``` | ||
|
||
docker-compose-v1: | ||
|
||
```shell | ||
# Show all installable versions | ||
asdf list-all docker-compose-v1 | ||
|
||
# Install specific version | ||
asdf install docker-compose-v1 latest | ||
|
||
# Set a version globally (on your ~/.tool-versions file) | ||
asdf global docker-compose-v1 latest | ||
|
||
# Now docker-compose-v1 commands are available | ||
docker-compose version | ||
``` | ||
|
||
Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to | ||
install & manage versions. | ||
|
||
# Contributing | ||
|
||
Contributions of any kind welcome! See the [contributing guide](contributing.md). | ||
|
||
[Thanks goes to these contributors](https://github.com/kompiro/asdf-docker-compose-v1/graphs/contributors)! | ||
|
||
# License | ||
|
||
See [LICENSE](LICENSE) © [Hiroki Kondo](https://github.com/kompiro/) |
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,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
current_script_path=${BASH_SOURCE[0]} | ||
plugin_dir=$(dirname "$(dirname "$current_script_path")") | ||
|
||
# shellcheck source=../lib/utils.bash | ||
source "${plugin_dir}/lib/utils.bash" | ||
|
||
mkdir -p "$ASDF_DOWNLOAD_PATH" | ||
|
||
# TODO: Adapt this to proper extension and adapt extracting strategy. | ||
release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz" | ||
|
||
# Download tar.gz file to the download directory | ||
download_release "$ASDF_INSTALL_VERSION" "$release_file" | ||
|
||
# Extract contents of tar.gz file into the download directory | ||
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file" | ||
|
||
# Remove the tar.gz file since we don't need to keep it | ||
rm "$release_file" |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
current_script_path=${BASH_SOURCE[0]} | ||
plugin_dir=$(dirname "$(dirname "$current_script_path")") | ||
|
||
# shellcheck source=../lib/utils.bash | ||
source "${plugin_dir}/lib/utils.bash" | ||
|
||
install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
current_script_path=${BASH_SOURCE[0]} | ||
plugin_dir=$(dirname "$(dirname "$current_script_path")") | ||
|
||
# shellcheck source=../lib/utils.bash | ||
source "${plugin_dir}/lib/utils.bash" | ||
|
||
list_all_versions | sort_versions | xargs echo |
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,12 @@ | ||
# Contributing | ||
|
||
Testing Locally: | ||
|
||
```shell | ||
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*] | ||
|
||
# | ||
asdf plugin test docker-compose-v1 https://github.com/kompiro/asdf-docker-compose-v1.git "docker-compose version" | ||
``` | ||
|
||
Tests are automatically run in GitHub Actions on push and PR. |
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,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for docker-compose-v1. | ||
GH_REPO="https://github.com/docker/compose" | ||
TOOL_NAME="docker-compose-v1" | ||
TOOL_TEST="docker-compose version" | ||
|
||
fail() { | ||
echo -e "asdf-$TOOL_NAME: $*" | ||
exit 1 | ||
} | ||
|
||
curl_opts=(-fsSL) | ||
|
||
# NOTE: You might want to remove this if docker-compose-v1 is not hosted on GitHub releases. | ||
if [ -n "${GITHUB_API_TOKEN:-}" ]; then | ||
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") | ||
fi | ||
|
||
sort_versions() { | ||
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | | ||
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' | ||
} | ||
|
||
list_github_tags() { | ||
git ls-remote --tags --refs "$GH_REPO" | | ||
grep -o 'refs/tags/.*' | cut -d/ -f3- | | ||
sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags | ||
} | ||
|
||
list_all_versions() { | ||
# TODO: Adapt this. By default we simply list the tag names from GitHub releases. | ||
# Change this function if docker-compose-v1 has other means of determining installable versions. | ||
list_github_tags | ||
} | ||
|
||
download_release() { | ||
local version filename url | ||
version="$1" | ||
filename="$2" | ||
|
||
# TODO: Adapt the release URL convention for docker-compose-v1 | ||
url="$GH_REPO/archive/v${version}.tar.gz" | ||
|
||
echo "* Downloading $TOOL_NAME release $version..." | ||
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" | ||
} | ||
|
||
install_version() { | ||
local install_type="$1" | ||
local version="$2" | ||
local install_path="$3" | ||
|
||
if [ "$install_type" != "version" ]; then | ||
fail "asdf-$TOOL_NAME supports release installs only" | ||
fi | ||
|
||
( | ||
mkdir -p "$install_path" | ||
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path" | ||
|
||
# TODO: Asert docker-compose-v1 executable exists. | ||
local tool_cmd | ||
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)" | ||
test -x "$install_path/bin/$tool_cmd" || fail "Expected $install_path/bin/$tool_cmd to be executable." | ||
|
||
echo "$TOOL_NAME $version installation was successful!" | ||
) || ( | ||
rm -rf "$install_path" | ||
fail "An error ocurred while installing $TOOL_NAME $version." | ||
) | ||
} |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
exec shellcheck -s bash -x \ | ||
bin/* -P lib/ |
Oops, something went wrong.