Skip to content
Open
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
8 changes: 8 additions & 0 deletions .editorconfig
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
48 changes: 48 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Main workflow

on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
schedule:
- cron: "0 0 * * 5"

jobs:
plugin_test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: asdf_plugin_test
uses: asdf-vm/actions/[email protected]
with:
command: operator-sdk version

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run ShellCheck
run: shellcheck bin/*

format:
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install shfmt
run: brew install shfmt

- name: Run shfmt
run: shfmt -d -i 2 -ci .
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# asdf-operator-sdk

[![Build Status](https://travis-ci.org/Medium/asdf-operator-sdk.svg?branch=master)](https://travis-ci.org/Medium/asdf-operator-sdk)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Medium/asdf-operator-sdk/Main%20workflow?style=flat-square)](https://github.com/Medium/asdf-operator-sdk/actions)

[Operator SDK](https://github.com/operator-framework/operator-sdk) plugin for [asdf](https://github.com/asdf-vm/asdf) version manager

Expand Down
63 changes: 34 additions & 29 deletions bin/install
Original file line number Diff line number Diff line change
@@ -1,59 +1,64 @@
#!/usr/bin/env bash

set -e
set -o pipefail
set -eo pipefail

install_operator_sdk() {
local install_type=$1
local version=$2
local install_path=$3
install_type=$1
version=$2
install_path=$3

if [ "$install_type" != "version" ]; then
echo "asdf-operator-sdk supports release installs only"
exit 1
fi

os="$(uname | tr '[:upper:]' '[:lower:]')"

local os="$(uname | tr '[:upper:]' '[:lower:]')"
if [ "$os" = "darwin" ]; then
local os="apple-$os"
os="apple-$os"
elif [ "$os" = "linux" ]; then
local os="$os-gnu"
os="$os-gnu"
fi
local platform="$(uname -m)-$os"

local bin_install_path="$install_path/bin"
local binary_path="$bin_install_path/operator-sdk"
local download_url=$(get_download_url $version $platform)
platform="$(uname -m)-$os"
bin_install_path="$install_path/bin"
binary_path="$bin_install_path/operator-sdk"
download_url="$(get_download_url "$version" "$platform")"

if [ "$TMPDIR" = "" ]; then
local tmp_download_dir=$(mktemp -d -t operator-sdk_XXXXXX)
tmp_download_dir="$(mktemp -d -t operator-sdk_XXXXXX)"
else
local tmp_download_dir=$TMPDIR
tmp_download_dir=$TMPDIR
fi

local download_path="$tmp_download_dir/$(get_filename $version $platform)"
download_path="$tmp_download_dir/$(get_filename "$version" "$platform")"

echo "Downloading operator-sdk from ${download_url} to ${download_path}"
curl -Lo $download_path $download_url
echo "Downloading operator-sdk from $download_url to $download_path"
curl -Lo "$download_path" "$download_url"

echo "Creating bin directory"
mkdir -p "${bin_install_path}"
mkdir -p "$bin_install_path"

echo "Cleaning previous binaries"
rm -f $binary_path 2>/dev/null || true
rm -f "$binary_path" 2>/dev/null || true

echo "Copying binary"
cp ${download_path} ${binary_path}
chmod +x ${binary_path}
cp "$download_path" "$binary_path"
chmod +x "$binary_path"
}

get_filename() {
local version="$1"
local platform="$2"
version="$1"
platform="$2"

echo "operator-sdk-v${version}-${platform}"
echo "operator-sdk-v$version-$platform"
}

get_download_url() {
local version="$1"
local platform="$2"
local filename="$(get_filename $version $platform)"
echo "https://github.com/operator-framework/operator-sdk/releases/download/v${version}/${filename}"
version="$1"
platform="$2"
filename="$(get_filename "$version" "$platform")"
echo "https://github.com/operator-framework/operator-sdk/releases/download/v$version/$filename"
}

install_operator_sdk $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH
install_operator_sdk "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
24 changes: 12 additions & 12 deletions bin/list-all
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env bash

releases_path=https://api.github.com/repos/operator-framework/operator-sdk/releases
cmd="curl -s"
if [ -n "$GITHUB_API_TOKEN" ]; then
cmd="$cmd -H 'Authorization: token $GITHUB_API_TOKEN'"
fi
cmd="$cmd $releases_path"
set -eo pipefail

# stolen from https://github.com/rbenv/ruby-build/pull/631/files#diff-fdcfb8a18714b33b07529b7d02b54f1dR942
function sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \
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}'
}

# Fetch all tag names, and get only second column. Then remove all unnecesary characters.
versions=$(eval $cmd | grep -oE "tag_name\": *\".{1,15}\"," | sed 's/tag_name\": *\"v//;s/\",//' | sort_versions)
echo $versions
versions=$(
git ls-remote --tags https://github.com/operator-framework/operator-sdk.git |
awk '!/({})/ {print $2}' |
grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" |
sort_versions |
xargs
)

echo "$versions"