Skip to content

Commit 77fae78

Browse files
AleDecreenot24
andcommitted
Added provider and resources implementations
Co-authored-by: Erasmo <[email protected]>
1 parent 9f316d9 commit 77fae78

25 files changed

+2354
-16
lines changed

.github/workflows/lint.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Linting
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
golangci:
7+
name: Lint golang files
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.event.pull_request.head.sha }}
14+
repository: ${{github.event.pull_request.head.repo.full_name}}
15+
persist-credentials: false
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: 1.19
21+
22+
- name: golangci-lint
23+
uses: golangci/[email protected]
24+
with:
25+
only-new-issues: true
26+
version: v1.50.0
27+
28+
gomodtidy:
29+
name: Enforce go.mod tidiness
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
with:
36+
ref: "${{ github.event.pull_request.head.sha }}"
37+
repository: ${{github.event.pull_request.head.repo.full_name}}
38+
persist-credentials: false
39+
40+
- name: Setup Go
41+
uses: actions/setup-go@v3
42+
with:
43+
go-version: 1.19
44+
45+
- name: Execute go mod tidy and check the outcome
46+
working-directory: ./
47+
run: |
48+
go mod tidy
49+
exit_code=$(git diff --exit-code)
50+
exit ${exit_code}
51+
52+
markdownlint:
53+
name: Lint markdown files
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Check out code
57+
uses: actions/checkout@v3
58+
with:
59+
ref: "${{ github.event.pull_request.head.sha }}"
60+
repository: ${{github.event.pull_request.head.repo.full_name}}
61+
persist-credentials: false
62+
63+
- name: Lint markdown files
64+
uses: avto-dev/markdown-lint@v1
65+
with:
66+
config: '.markdownlint.yml'
67+
args: '**/*.md'

.github/workflows/release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Terraform Provider release workflow.
2+
name: Release
3+
4+
# This GitHub action creates a release when a tag that matches the pattern
5+
# "v*" (e.g. v0.1.0) is created.
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
# Releases need permissions to read and write the repository contents.
12+
# GitHub considers creating releases and uploading assets as writing contents.
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
goreleaser:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
# Allow goreleaser to access older tag information.
23+
fetch-depth: 0
24+
- uses: actions/setup-go@v3
25+
with:
26+
go-version-file: 'go.mod'
27+
cache: true
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@v5
30+
id: import_gpg
31+
with:
32+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
passphrase: ${{ secrets.PASSPHRASE }}
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v4
36+
with:
37+
args: release --rm-dist
38+
env:
39+
# GitHub sets the GITHUB_TOKEN secret automatically.
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.golangci.yml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
run:
2+
timeout: 10m
3+
skip-files:
4+
- "zz_generated.*.go"
5+
6+
linters-settings:
7+
exhaustive:
8+
check-generated: false
9+
default-signifies-exhaustive: true
10+
11+
lll:
12+
line-length: 150
13+
gomodguard:
14+
blocked:
15+
modules:
16+
- github.com/go-logr/logr:
17+
recommendations:
18+
- k8s.io/klog/v2
19+
gci:
20+
sections:
21+
- standard # Captures all standard packages if they do not match another section.
22+
- default # Contains all imports that could not be matched to another section type.
23+
- prefix(github.com/liqotech) # Groups all imports with the specified Prefix.
24+
goconst:
25+
min-len: 2
26+
min-occurrences: 2
27+
gocritic:
28+
enabled-tags:
29+
- diagnostic
30+
- experimental
31+
- opinionated
32+
- performance
33+
- style
34+
disabled-checks:
35+
# Conflicts with govet check-shadowing
36+
- sloppyReassign
37+
goimports:
38+
local-prefixes: github.com/liqotech
39+
govet:
40+
check-shadowing: true
41+
misspell:
42+
locale: US
43+
nolintlint:
44+
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
45+
allow-unused: false # report any unused nolint directives
46+
require-explanation: true # require an explanation for nolint directives
47+
require-specific: true # require nolint directives to be specific about which linter is being skipped
48+
dupl:
49+
threshold: 300
50+
51+
linters:
52+
disable-all: true
53+
enable:
54+
- asciicheck
55+
- bodyclose
56+
- depguard
57+
- dogsled
58+
- dupl
59+
- errcheck
60+
- errorlint
61+
- exhaustive
62+
- exportloopref
63+
# - funlen
64+
# - gochecknoglobals
65+
# - gochecknoinits
66+
# - gocognit
67+
- gci
68+
- goconst
69+
- gocritic
70+
- gocyclo
71+
- godot
72+
# - godox
73+
# - goerr113
74+
- gofmt
75+
- goheader
76+
- goimports
77+
- gomodguard
78+
# - gomnd
79+
- goprintffuncname
80+
- gosec
81+
- gosimple
82+
- govet
83+
- ineffassign
84+
- lll
85+
# - maligned
86+
- misspell
87+
- nakedret
88+
# - nestif
89+
- noctx
90+
- nolintlint
91+
# - prealloc
92+
- revive
93+
- rowserrcheck
94+
- staticcheck
95+
- stylecheck
96+
# - testpackage
97+
- typecheck
98+
- unconvert
99+
- unparam
100+
- unused
101+
- whitespace
102+
# - wsl
103+
104+
issues:
105+
#fix: true
106+
107+
max-issues-per-linter: 0
108+
max-same-issues: 0
109+
110+
# Disable the default exclude patterns (as they disable the mandatory comments)
111+
exclude-use-default: false
112+
exclude:
113+
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
114+
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
115+
116+
exclude-rules:
117+
- linters:
118+
- govet
119+
text: 'declaration of "(err|ctx)" shadows declaration at'
120+
- linters:
121+
- gosec
122+
# Disable the check to test that HTTP clients are not using an insecure TLS connection.
123+
# We need it to contact the remote authentication services exposing a self-signed certificate
124+
text: TLS InsecureSkipVerify set true.
125+
- linters:
126+
- errorlint
127+
# Disable the check to test errors type assertion on switches.
128+
text: type switch on error will fail on wrapped errors. Use errors.As to check for specific errors
129+
130+
# Exclude the following linters from running on tests files.
131+
- path: _test\.go
132+
linters:
133+
- whitespace

.goreleaser.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
# this is just an example and not a requirement for provider building/publishing
6+
- go mod tidy
7+
builds:
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: '{{ .CommitTimestamp }}'
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
18+
goos:
19+
- freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
- arm
27+
- arm64
28+
ignore:
29+
- goos: darwin
30+
goarch: '386'
31+
binary: '{{ .ProjectName }}_v{{ .Version }}'
32+
archives:
33+
- format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
35+
checksum:
36+
extra_files:
37+
- glob: 'terraform-registry-manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
39+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
40+
algorithm: sha256
41+
signs:
42+
- artifacts: checksum
43+
args:
44+
# if you are using this in a GitHub action or some other automated pipeline, you
45+
# need to pass the batch flag to indicate its not interactive.
46+
- "--batch"
47+
- "--local-user"
48+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
49+
- "--output"
50+
- "${signature}"
51+
- "--detach-sign"
52+
- "${artifact}"
53+
release:
54+
extra_files:
55+
- glob: 'terraform-registry-manifest.json'
56+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
57+
# If you want to manually examine the release before its live, uncomment this line:
58+
# draft: true
59+
changelog:
60+
skip: true

.markdownlint.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
default: true
2+
line-length: false
3+
no-inline-html: false

.markdownlintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs

README.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
# Liqo provider
22

3-
Provider for Terraform to perform Liqo operations.
3+
> Provider for Terraform to perform Liqo operations.
44
55
## Getting Started
6+
67
Follow this example steps to test locally the implemented provider.
78

89
### Prerequisites
10+
911
- [Terraform](https://developer.hashicorp.com/terraform/downloads)
10-
- [Liqo CLI tool](https://docs.liqo.io/en/v0.6.1/installation/liqoctl.html)
1112
- [go](https://go.dev/doc/install)
1213

1314
### Installation
14-
1. in ***.terraform.d*** folder (you should have it in home/\<usr\>/) make directory with this command replacing _architecture_ with your architecture (example: linux_arm64 or linux_amd64):
1515

16-
``` mkdir -p /plugins/liqo-provider/liqo/liqo/0.0.1/<architecture>/ ```
16+
1. in ***.terraform.d*** folder (you should have it in home/\<usr\>/) make directory with this command replacing *architecture* with your architecture (example: linux_arm64 or linux_amd64):
17+
18+
`mkdir -p /plugins/liqo-provider/liqo/liqo/0.0.1/<architecture>/`
1719

1820
my complete path is the following:
19-
```home/<usr>/.terraform.d/plugins/liqo-provider/liqo/liqo/0.0.1/linux_arm64/```
21+
`home/<usr>/.terraform.d/plugins/liqo-provider/liqo/liqo/0.0.1/linux_arm64/`
2022

21-
2. from root run command replacing _path_ with the one created in first step:
23+
2. from root run command replacing *path* with the one created in first step:
2224

23-
```go build -o <path>/terraform-provider-liqo ```
25+
`go build -o <path>/terraform-provider-liqo`
2426

25-
3. in your main.tf tell to Terraform to use provider implemented locally by yoursel with this directive in required_providers:
27+
3. in your main.tf tell to Terraform to use provider implemented locally
28+
by yourself with this directive in *required_providers*:
2629

2730
```source = "liqo-provider/liqo/liqo"```
2831

2932
for example:
30-
```hcl
33+
34+
```terraform
3135
terraform {
3236
required_providers {
3337
liqo = {
34-
source = "liqo-provider/liqo/liqo"
38+
source = "liqo-provider/liqo/liqo"
3539
}
3640
}
3741
}
3842
```
39-
40-
4. run command:
41-
42-
```terraform init ```
43-
44-
```terraform apply -auto-approve```

0 commit comments

Comments
 (0)