Skip to content

Commit 1a642bc

Browse files
author
nolte
committed
init
0 parents  commit 1a642bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+28189
-0
lines changed

.circleci/config.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
version: 2
2+
3+
jobs:
4+
test:
5+
docker:
6+
- image: circleci/golang:1.13
7+
steps:
8+
- checkout
9+
- run: go get -v ./...
10+
build:
11+
docker:
12+
- image: circleci/golang:1.13
13+
steps:
14+
- checkout
15+
- run:
16+
name: update n upgrade
17+
command: |
18+
sudo apt update
19+
sudo apt upgrade -y
20+
- run: go get -v ./...
21+
- run:
22+
name: Build terraform provider for multiple platforms
23+
command: |
24+
package_name=terraform-harbor-provider
25+
26+
platforms=(
27+
"darwin/amd64"
28+
"linux/amd64"
29+
"windows/amd64" )
30+
31+
for platform in "${platforms[@]}"
32+
do
33+
platform_split=(${platform//\// })
34+
GOOS=${platform_split[0]}
35+
GOARCH=${platform_split[1]}
36+
output_name=$package_name
37+
if [ $GOOS = "windows" ]; then
38+
output_name+='.exe'
39+
fi
40+
41+
env CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name
42+
43+
zip -v terraform-harbor-provider-$GOOS-$GOARCH $output_name
44+
rm $output_name
45+
done
46+
cat /etc/*release
47+
ls -lh
48+
49+
- run:
50+
name: Create release
51+
command: |
52+
curl -X POST \
53+
https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases \
54+
-H "authorization: Basic $GH_TOKEN" \
55+
-H 'content-type: application/json' \
56+
-d '{
57+
"tag_name": "'$CIRCLE_TAG'",
58+
"target_commitish": "master",
59+
"name": "'$CIRCLE_TAG'",
60+
"body": "",
61+
"draft": false,
62+
"prerelease": false
63+
}' | jq
64+
- run:
65+
name: Upload release assets
66+
command: |
67+
id=$(curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases/latest -H "authorization: Basic $GH_TOKEN" | jq '.id')
68+
69+
FILES=$(ls -l terraform-harbor-provider* | awk '{print $9}')
70+
for f in $FILES
71+
do
72+
GH_ASSET="https://uploads.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases/$id/assets?name=$(basename $f)"
73+
74+
curl --data-binary @"$f" -H "authorization: Basic $GH_TOKEN" -H "Content-Type: application/zip" $GH_ASSET | jq
75+
done
76+
77+
workflows:
78+
version: 2
79+
build-n-release:
80+
jobs:
81+
- build:
82+
filters:
83+
branches:
84+
ignore: /.*/
85+
tags:
86+
only: /v[0-9]+.[0-9]+.[0-9]+/

.devcontainer/Dockerfile

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM docker.pkg.github.com/nolte/vscode-devcontainers/k8s-operator:latest
2+
3+
4+
5+
# https://github.com/bats-core/bats-core
6+
ENV BATS_VERSION=1.2.0
7+
8+
ENV SWAGGER_VERSION=v0.23.0
9+
10+
USER root
11+
12+
COPY --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /usr/local/bin/terraform /usr/local/bin/terraform
13+
RUN curl -sSL -k https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz -o /tmp/bats.tgz \
14+
&& tar -zxf /tmp/bats.tgz -C /tmp \
15+
&& /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
16+
17+
RUN curl -Lo /usr/local/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64 \
18+
&& chmod +x /usr/local/bin/swagger
19+
20+
ENV TERRAFORM_DOC_VERSION=v0.9.1
21+
22+
RUN curl -Lo /usr/local/bin/terraform-doc https://github.com/segmentio/terraform-docs/releases/download/${TERRAFORM_DOC_VERSION}/terraform-docs-${TERRAFORM_DOC_VERSION}-$(uname | tr '[:upper:]' '[:lower:]')-amd64 \
23+
&& chmod +x /usr/local/bin/terraform-doc
24+
25+
26+
RUN curl -sSL -k https://github.com/bflad/tfproviderdocs/releases/download/v0.6.0/tfproviderdocs_0.6.0_linux_amd64.tar.gz -o /tmp/tfproviderdocs.tgz \
27+
&& tar -zxf /tmp/tfproviderdocs.tgz -C /tmp \
28+
&& mv /tmp/tfproviderdocs /usr/local/bin/
29+
30+
31+
RUN apk add --update-cache \
32+
nodejs npm \
33+
&& rm -rf /var/cache/apk/*
34+
35+
36+
RUN mkdir -p /home/$USERNAME/.vscode-server/extensions \
37+
/home/$USERNAME/.vscode-server-insiders/extensions \
38+
&& chown -R $USERNAME \
39+
/home/$USERNAME/.vscode-server \
40+
/home/$USERNAME/.vscode-server-insiders
41+
42+
RUN mkdir -p /go/src && chown -R ${USER_UID}:${USER_GID} /go/src \
43+
&& mkdir -p /go/pkg && chown -R ${USER_UID}:${USER_GID} /go/pkg
44+
45+
USER ${USERNAME}
46+
47+
#COPY --chown=${USER_UID}:${USER_GID} --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /home/${USERNAME}/.zshrc-specific /home/${USERNAME}/.zshrc-specific
48+
COPY --chown=${USER_UID}:${USER_GID} files/devops-zshrc-specific /home/${USERNAME}/.zshrc-specific
49+
COPY --chown=${USER_UID}:${USER_GID} files/devops-welcome.sh /home/${USERNAME}/.welcome.sh
50+
51+
RUN mkdir -p /home/${USERNAME}/.terraform.d/plugins/linux_amd64
52+
53+
ENV PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
54+
55+
RUN mkdir "/home/${USERNAME}/.npm-packages"
56+
RUN npm config set prefix "/home/${USERNAME}/.npm-packages"
57+
RUN npm install swagger-merger --user -g
58+
59+
RUN helm repo add harbor https://helm.goharbor.io
60+
RUN npm install swagger-merger -g

.devcontainer/devcontainer.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "terraform-provider-harbor",
3+
"dockerComposeFile": [
4+
"docker-compose.yml"
5+
],
6+
"service": "vscode",
7+
"runServices": [
8+
"vscode"
9+
],
10+
"mounts": [
11+
"source=terraform-harbor-vol,target=/home/vscode/.vscode-server/extensions,type=volume",
12+
// And/or for VS Code Insiders
13+
"source=terraform-harbor-vol-insiders,target=/home/vscode/.vscode-server-insiders/extensions,type=volume",
14+
],
15+
"shutdownAction": "stopCompose",
16+
"postCreateCommand": "chmod -R 700 .git",
17+
"workspaceFolder": "/go/src/github.com/nolte/terraform-provider-harbor",
18+
// "overrideCommand": "",
19+
"extensions": [
20+
// General backend
21+
"mohsen1.prettify-json",
22+
"redhat.vscode-yaml", // Kubernetes and Kedge syntax support
23+
// Go
24+
"ms-vscode.go",
25+
"ethan-reesor.vscode-go-test-adapter",
26+
// Console
27+
"IBM.output-colorizer",
28+
// Git
29+
"eamodio.gitlens",
30+
"mhutchie.git-graph",
31+
// Other linters
32+
"davidanson.vscode-markdownlint",
33+
"ms-azuretools.vscode-docker",
34+
// Other helpers
35+
"shardulm94.trailing-spaces",
36+
"Gruntfuggly.todo-tree",
37+
"bierner.emojisense",
38+
"stkb.rewrap", // rewrap comments after n characters on one line
39+
// Other
40+
"jrebocho.vscode-random", // generate random values
41+
"alefragnani.Bookmarks",
42+
"quicktype.quicktype", // Paste JSON as code
43+
"spikespaz.vscode-smoothtype", // smooth cursor animation
44+
"vscode-icons-team.vscode-icons",
45+
// markdown
46+
"docsmsft.docs-article-templates",
47+
"docsmsft.docs-markdown",
48+
"mauve.terraform",
49+
"ms-kubernetes-tools.kind-vscode",
50+
"ms-kubernetes-tools.vscode-kubernetes-tools",
51+
"jetmartin.bats"
52+
],
53+
"settings": {
54+
// General settings
55+
"files.eol": "\n",
56+
"files.encoding": "utf8",
57+
"editor.insertSpaces": true,
58+
"editor.tabSize": 4,
59+
"editor.renderWhitespace": "all",
60+
// Docker
61+
"remote.extensionKind": {
62+
"ms-azuretools.vscode-docker": "workspace"
63+
},
64+
"[makefile]": {
65+
"editor.insertSpaces": false,
66+
"editor.detectIndentation": false
67+
}
68+
}
69+
}

.devcontainer/docker-compose.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "3.7"
2+
3+
services:
4+
vscode:
5+
build: .
6+
# image: docker.pkg.github.com/nolte/vscode-devcontainers/k8s-operator:latest
7+
# image: qmcgaw/godevcontainer:alpine
8+
# image: qmcgaw/godevcontainer:debian
9+
volumes:
10+
- ../:/go/src/github.com/nolte/terraform-provider-harbor
11+
- ~/.ssh:/home/vscode/.ssh:ro
12+
- ~/.ssh:/root/.ssh:ro
13+
- /var/run/docker.sock:/var/run/docker.sock
14+
## reuse volumes for extensions
15+
- terraform-harbor-vol:/home/vscode/.vscode-server/extensions
16+
# And/or for VS Code Insiders
17+
- terraform-harbor-vol-insiders:/home/vscode/.vscode-server-insiders/extensions
18+
environment:
19+
- TZ=Europe/Berlin # $(cat /etc/timezone)
20+
cap_add:
21+
- SYS_PTRACE
22+
security_opt:
23+
- seccomp:unconfined
24+
entrypoint: zsh -c "while sleep 1000; do :; done"
25+
network_mode: "host"
26+
27+
volumes:
28+
terraform-harbor-vol:
29+
terraform-harbor-vol-insiders:

.devcontainer/files/devops-welcome.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
echo "Minimal Dev Env:"
3+
echo " * pre-commit virtual env"
4+
echo " * python3"
5+
echo " "
6+
echo "Activate the Python Dev Virtual Env by default."
7+
echo "call 'deactivate' for exiting the virtual env"
8+
source ~/.virtualenvs/development/bin/activate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins=(vscode git colorize docker docker-compose kubetail kubectl terraform pass)
2+
source <(kubectl completion zsh)
3+
NPM_PACKAGES="${HOME}/.npm-packages"
4+
export PATH="$PATH:$NPM_PACKAGES/bin"
5+
# Preserve MANPATH if you already defined it somewhere in your config.
6+
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
7+
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

.github/workflows/go.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up Go 1.x
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: ^1.13
18+
id: go
19+
20+
- name: Get dependencies
21+
run: |
22+
SWAGGER_VERSION=v0.23.0
23+
curl -Lo /usr/local/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64 \
24+
&& chmod +x /usr/local/bin/swagger
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v1
27+
with:
28+
node-version: 12.x
29+
- run: npm install swagger-merger -g
30+
31+
- name: Check out code into the Go module directory
32+
uses: actions/checkout@v2
33+
34+
- run: make generate
35+
36+
- name: Get dependencies
37+
run: |
38+
go get -v -t -d ./...
39+
if [ -f Gopkg.toml ]; then
40+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
41+
dep ensure
42+
fi
43+
44+
- name: Build
45+
run: go build -v .
46+
47+
- name: Test
48+
run: go test -v .

.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
terraform-provider-harbor_*
2+
gen
3+
4+
# Local .terraform directories
5+
**/.terraform/*
6+
7+
# .tfstate files
8+
*.tfstate
9+
*.tfstate.*
10+
11+
# Crash log files
12+
crash.log
13+
14+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
15+
# .tfvars files are managed as part of configuration and so should be included in
16+
# version control.
17+
#
18+
# example.tfvars
19+
20+
# Ignore override files as they are usually used to override resources locally and so
21+
# are not checked in
22+
override.tf
23+
override.tf.json
24+
*_override.tf
25+
*_override.tf.json
26+
27+
# Include override files you do wish to add to version control using negated pattern
28+
#
29+
# !example_override.tf
30+
31+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
32+
# example: *tfplan*
33+
34+
# Ignore CLI configuration files
35+
.terraformrc
36+
terraform.rc

.vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${fileDirname}",
13+
"env": {},
14+
"args": []
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)