Skip to content

Commit

Permalink
feat(goharbor/harbor-cli): add
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Nov 13, 2024
1 parent c6240ab commit c17bfc7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
12 changes: 12 additions & 0 deletions goharbor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# GoHarbor

## HarborCLI ([releases](https://github.com/goharbor/harbor-cli/releases))

```yaml
ownbrew:
packages:
# https://github.com/goharbor/harbor-cli/releases
- name: harbor-cli
tap: foomo/tap/goharbor/harbor-cli
version: 0.0.1
```
47 changes: 47 additions & 0 deletions goharbor/harbor-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e

# colors
CRed='\033[1;31m'
CGray='\033[0;37m'
CGreen='\033[1;32m'
CYellow='\033[1;33m'
NC='\033[0m'

# logging
info() {
echo -e "${CGray}${1}${NC}"
}

warn() {
echo -e "${CYellow}${1}${NC}"
}

error() {
echo -e "${CRed}${1}${NC}"
}

success() {
echo -e "${CGreen}${1}${NC}"
}

# vars
os="${os:-${1}}"
arch="${arch:-${2}}"
version="${version:-${3}}"

info "downloading ..."
curl -fL "https://github.com/goharbor/harbor-cli/releases/download/v${version}/harbor_${version}_${os}_${arch}.tar.gz" -o "${TEMP_DIR}/harbor.tar.gz"
curl -fL "https://github.com/goharbor/harbor-cli/releases/download/v${version}/checksums.txt" -o "${TEMP_DIR}/harbor.sha256"

#info "validating ..."
#echo "$(cat "${TEMP_DIR}/harbor.sha256" | grep "harbor_${version}_${os}_${arch}.tar.gz" | awk '{print $1;}') ${TEMP_DIR}/harbor.tar.gz"

info "extracting ..."
tar -xzvf "${TEMP_DIR}/harbor.tar.gz" -C "${TEMP_DIR}" harbor
mv -f "${TEMP_DIR}/harbor" "${BIN_DIR}/harbor-${version}-${os}-${arch}"
chmod a+x "${BIN_DIR}/harbor-${version}-${os}-${arch}"

info "cleanup ..."
rm "${TEMP_DIR}/harbor.tar.gz" "${TEMP_DIR}/harbor.sha256"
5 changes: 5 additions & 0 deletions goharbor/harbor-cli_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source .include/test.sh

test "$(dirname "$0")/harbor-cli.sh" "0.0.1"

0 comments on commit c17bfc7

Please sign in to comment.