From e5e6bd6009ede473444bab563be71f520c9f73e9 Mon Sep 17 00:00:00 2001 From: mlopez122 Date: Thu, 9 Dec 2021 23:36:32 -0500 Subject: [PATCH 1/5] add eksctl first attempt --- eksctl/README.md | 46 ++++++++++++++++++++++++++++++++++ eksctl/install.ps1 | 61 ++++++++++++++++++++++++++++++++++++++++++++++ eksctl/install.sh | 46 ++++++++++++++++++++++++++++++++++ eksctl/releases.js | 20 +++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 eksctl/README.md create mode 100644 eksctl/install.ps1 create mode 100644 eksctl/install.sh create mode 100644 eksctl/releases.js diff --git a/eksctl/README.md b/eksctl/README.md new file mode 100644 index 000000000..befda9e5c --- /dev/null +++ b/eksctl/README.md @@ -0,0 +1,46 @@ +--- +title: eksctl +homepage: https://github.com/webinstall/foobar +tagline: | + The official CLI for Amazon EKS +--- + + + +To update or switch versions, run `webi example@stable` (or `@v2`, `@beta`, +etc). + +### Files + +These are the files / directories that are created and/or modified with this +install: + +```txt +~/.config/envman/PATH.env +~/.local/bin/foo +~/.local/opt/foo +``` + +## Cheat Sheet + +> `foo` doesn't exist and this text should have been replaced. It doesn't do +> anything, but what it does is useful because it is; everybody knows it. + +To run foo: + +```bash +foo +``` + +### Add Baz Highlighting + +To run foo with both bar and baz highlighting turned on: + +```bash +foo --bar=baz +``` diff --git a/eksctl/install.ps1 b/eksctl/install.ps1 new file mode 100644 index 000000000..e54d5b643 --- /dev/null +++ b/eksctl/install.ps1 @@ -0,0 +1,61 @@ +#!/usr/bin/env pwsh + +################## +# Install eksctl # +################## + +# Every package should define these variables +$pkg_cmd_name = "eksctl" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\eksctl.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\eksctl-v$Env:WEBI_VERSION\bin\eksctl.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\eksctl-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\eksctl-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | out-null +$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) +{ + echo "Downloading eksctl from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing eksctl" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\eksctl-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\eksctl.exe" -Recurse -ErrorAction Ignore + + # NOTE: DELETE THIS COMMENT IF NOT USED + # Move single binary into root of temporary folder + #& move "$pkg_download" "eksctl.exe" + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null + Move-Item -Path ".\eksctl.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/eksctl/install.sh b/eksctl/install.sh new file mode 100644 index 000000000..0fc4cef59 --- /dev/null +++ b/eksctl/install.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# shellcheck disable=SC2034 +# "'pkg_cmd_name' appears unused. Verify it or export it." + +function __init_eksctl() { + set -e + set -u + + ################## + # Install eksctl # + ################## + + # Every package should define these 6 variables + pkg_cmd_name="eksctl" + + pkg_dst_cmd="$HOME/.local/bin/eksctl" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/eksctl-v$WEBI_VERSION/bin/eksctl" + pkg_src_dir="$HOME/.local/opt/eksctl-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/eksctl-v0.99.9/bin + mkdir -p "$(dirname "${pkg_src_cmd}")" + + # mv ./eksctl-*/eksctl ~/.local/opt/eksctl-v0.99.9/bin/eksctl + mv ./eksctl "${pkg_src_cmd}" + } + + # pkg_get_current_version is recommended, but not required + pkg_get_current_version() { + # 'eksctl --version' has output in this format: + # eksctl 0.99.9 (rev abcdef0123) + # This trims it down to just the version number: + # 0.99.9 + eksctl --version 2> /dev/null | + head -n 1 | + cut -d ' ' -f 2 + } + +} + +__init_eksctl diff --git a/eksctl/releases.js b/eksctl/releases.js new file mode 100644 index 000000000..cb658fd17 --- /dev/null +++ b/eksctl/releases.js @@ -0,0 +1,20 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'weaveworks'; +var repo = 'eksctl'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + // just select the first 5 for demonstration + all.releases = all.releases.slice(0, 5); + console.info(JSON.stringify(all, null, 2)); + }); +} From 4fe0d7bf3871497898f41ff38c3dfb714d8fae24 Mon Sep 17 00:00:00 2001 From: mlopez122 Date: Thu, 9 Dec 2021 23:43:34 -0500 Subject: [PATCH 2/5] add eksctl first attempt --- eksctl/README.md | 7 ------- package-lock.json | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/eksctl/README.md b/eksctl/README.md index befda9e5c..bdbdbb1b4 100644 --- a/eksctl/README.md +++ b/eksctl/README.md @@ -5,13 +5,6 @@ tagline: | The official CLI for Amazon EKS --- - - To update or switch versions, run `webi example@stable` (or `@v2`, `@beta`, etc). diff --git a/package-lock.json b/package-lock.json index b2abb458a..b9d40a13c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,52 @@ { "name": "@webinstall/webi-installers", "version": "0.2.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "@webinstall/webi-installers", + "version": "0.2.0", + "license": "MPL-2.0", + "dependencies": { + "@root/request": "^1.6.1", + "dotenv": "^8.2.0", + "shmatter": "^1.0.1" + } + }, + "node_modules/@root/request": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz", + "integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ==" + }, + "node_modules/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/marked": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz", + "integrity": "sha512-EkE7RW6KcXfMHy2PA7Jg0YJE1l8UPEZE8k45tylzmZM30/r1M1MUXWQfJlrSbsTeh7m/XTwHbWUENvAJZpp1YA==", + "bin": { + "marked": "bin/marked" + }, + "engines": { + "node": ">= 8.16.2" + } + }, + "node_modules/shmatter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/shmatter/-/shmatter-1.0.1.tgz", + "integrity": "sha512-bBAvHI8640XcMDsShK2HOR8WOkF65hMprXr7Rsqb3z+26/5qna3jZfP7VZScItGoULUYyNeen9isD60KxtD2hQ==", + "dependencies": { + "marked": "^1.0.0" + } + } + }, "dependencies": { "@root/request": { "version": "1.6.1", From 861133e6b09254f3bdb6c5ac0cd92d5d604ef7e7 Mon Sep 17 00:00:00 2001 From: mlopez122 Date: Fri, 10 Dec 2021 00:41:26 -0500 Subject: [PATCH 3/5] fixed bugs and edited the ReadMe --- eksctl/README.md | 27 ++++++++++++++++++--------- eksctl/install.ps1 | 6 +++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/eksctl/README.md b/eksctl/README.md index bdbdbb1b4..0d7568906 100644 --- a/eksctl/README.md +++ b/eksctl/README.md @@ -1,6 +1,6 @@ --- title: eksctl -homepage: https://github.com/webinstall/foobar +homepage: https://github.com/weaveworks/eksctl tagline: | The official CLI for Amazon EKS --- @@ -15,25 +15,34 @@ install: ```txt ~/.config/envman/PATH.env -~/.local/bin/foo -~/.local/opt/foo +~/.local/bin/eksctl +~/.local/opt/eksctl ``` ## Cheat Sheet -> `foo` doesn't exist and this text should have been replaced. It doesn't do -> anything, but what it does is useful because it is; everybody knows it. +> From the `eksctl` ReadMe: +> You can create a cluster in minutes with just one command – eksctl create cluster! +> AWS Account +> You will need to have AWS API credentials configured. What works for AWS CLI or any other tools (kops, Terraform etc), should be sufficient. You can use ~/.aws/credentials file or environment variables. For more information read AWS documentation. -To run foo: + +You will also need AWS IAM Authenticator for Kubernetes command (either aws-iam-authenticator or aws eks get-token (available in version 1.16.156 or greater of AWS CLI) in your PATH. + + +The IAM account used for EKS cluster creation should have these minimal access levels. + + +To run eksctl: ```bash -foo +eksctl ``` ### Add Baz Highlighting -To run foo with both bar and baz highlighting turned on: +To run eksctl with both bar and baz highlighting turned on: ```bash -foo --bar=baz +eksctl --bar=baz ``` diff --git a/eksctl/install.ps1 b/eksctl/install.ps1 index e54d5b643..247ba7266 100644 --- a/eksctl/install.ps1 +++ b/eksctl/install.ps1 @@ -40,12 +40,12 @@ IF (!(Test-Path -Path "$pkg_src_cmd")) # NOTE: DELETE THIS COMMENT IF NOT USED # Move single binary into root of temporary folder - #& move "$pkg_download" "eksctl.exe" + & move "$pkg_download" "eksctl.exe" # Unpack archive file into this temporary directory # Windows BSD-tar handles zip. Imagine that. - echo "Unpacking $pkg_download" - & tar xf "$pkg_download" + # echo "Unpacking $pkg_download" + # & tar xf "$pkg_download" # Settle unpacked archive into place echo "Install Location: $pkg_src_cmd" From 90827ced974c0b678aaa2fabf07c27bf5f1b42dd Mon Sep 17 00:00:00 2001 From: mlopez122 Date: Fri, 10 Dec 2021 00:44:44 -0500 Subject: [PATCH 4/5] edited the ReadMe to include a link to original WeaveWorks ReadMe --- eksctl/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eksctl/README.md b/eksctl/README.md index 0d7568906..24bdf2831 100644 --- a/eksctl/README.md +++ b/eksctl/README.md @@ -46,3 +46,6 @@ To run eksctl with both bar and baz highlighting turned on: ```bash eksctl --bar=baz ``` + +### Further Reading and Direct Link to Original ReadMe: +https://github.com/weaveworks/eksctl \ No newline at end of file From 0bd26af9b0b179bc376281f0f782cba92bc1c360 Mon Sep 17 00:00:00 2001 From: mlopez122 Date: Fri, 10 Dec 2021 00:46:14 -0500 Subject: [PATCH 5/5] edited the ReadMe with basic cluster command --- eksctl/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eksctl/README.md b/eksctl/README.md index 24bdf2831..67b0f69b1 100644 --- a/eksctl/README.md +++ b/eksctl/README.md @@ -33,10 +33,10 @@ You will also need AWS IAM Authenticator for Kubernetes command (either aws-iam- The IAM account used for EKS cluster creation should have these minimal access levels. -To run eksctl: +To create a basic cluster: ```bash -eksctl +eksctl create cluster ``` ### Add Baz Highlighting