Skip to content

Commit 35f09a7

Browse files
authored
Refectoring from the Povider Interface. (#4)
Define the first "Stable" Version from the base provider configuration, use the original ids for the terraform state, and add import methode for some methodes.
1 parent 559eec5 commit 35f09a7

37 files changed

+937
-467
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ USER root
88
COPY --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /usr/local/bin/swagger /usr/local/bin/swagger
99
COPY --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /usr/local/bin/terraform /usr/local/bin/terraform
1010
COPY --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /usr/local/bin/terraform-doc /usr/local/bin/terraform-doc
11+
COPY --from=docker.pkg.github.com/nolte/vscode-devcontainers/devops:latest /usr/local/bin/shellcheck /usr/local/bin/shellcheck
1112

1213
RUN curl -sSL -k https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz -o /tmp/bats.tgz \
13-
&& tar -zxf /tmp/bats.tgz -C /tmp \
14-
&& /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
14+
&& tar -zxf /tmp/bats.tgz -C /tmp \
15+
&& /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
1516

1617
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 \
17-
&& tar -zxf /tmp/tfproviderdocs.tgz -C /tmp \
18-
&& mv /tmp/tfproviderdocs /usr/local/bin/
18+
&& tar -zxf /tmp/tfproviderdocs.tgz -C /tmp \
19+
&& mv /tmp/tfproviderdocs /usr/local/bin/
1920

2021

2122
RUN apk add --update-cache \
22-
nodejs npm \
23-
&& rm -rf /var/cache/apk/*
23+
nodejs npm \
24+
&& rm -rf /var/cache/apk/*
2425

2526
RUN mkdir -p /go/src && chown -R ${USER_UID}:${USER_GID} /go/src \
26-
&& mkdir -p /go/pkg && chown -R ${USER_UID}:${USER_GID} /go/pkg
27+
&& mkdir -p /go/pkg && chown -R ${USER_UID}:${USER_GID} /go/pkg
2728

2829
USER ${USERNAME}
2930

@@ -40,4 +41,4 @@ RUN npm config set prefix "/home/${USERNAME}/.npm-packages"
4041
RUN npm install swagger-merger --user -g
4142

4243
RUN helm repo add harbor https://helm.goharbor.io
43-
RUN npm install swagger-merger -g
44+
RUN npm install swagger-merger -g

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"ms-kubernetes-tools.vscode-kubernetes-tools",
5151
"jetmartin.bats",
5252
"EditorConfig.EditorConfig",
53+
"lonefy.vscode-js-css-html-formatter",
5354
],
5455
"settings": {
5556
// General settings
@@ -67,4 +68,4 @@
6768
"editor.detectIndentation": false
6869
}
6970
}
70-
}
71+
}

.editorconfig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
root = true
33

44
[*]
5-
indent_style = tab
5+
indent_style = space
66
indent_size = 4
77
end_of_line = lf
88
charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
1111

12+
[docs/**.md]
13+
# allow line break https://3os.org/markdownCheatSheet/lineBreaks/#line_break_with_2_spaces
14+
trim_trailing_whitespace = false
15+
16+
[makefile]
17+
indent_style = tabs
18+
1219
[{*.yml,*.yaml, *.tf}]
1320
indent_style = space
1421
indent_size = 2

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
linters:
2+
enable-all: true

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ fmtcheck:
4141
vet:
4242
go vet ./...
4343

44+
check-scripts:
45+
shellcheck scripts/*.sh
46+
shellcheck scripts/test/bats/build/*.bats
47+
4448
e2e_prepare:
4549
scripts/tst-00-prepare-kind.sh
4650
scripts/tst-01-prepare-harbor.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is original based on the Work from [BESTSELLER/terraform-harbor-provider](h
1313

1414
**Planed Branking Changes:**
1515

16-
- [ ] Rename provier attributes, like url etc.
16+
- [x] [Rename provider](https://github.com/nolte/terraform-provider-harbor/issues/3) attributes, like url etc.
1717
- [x] Planed Git Rebase for remove the Ugly CI/CD Test Commit
1818
- [x] Finazilize the frist version of common ci workflow
1919
- [x] Finazilize the frist version of release workflow

client/client.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,20 @@ import (
1010
apiclient "github.com/nolte/terraform-provider-harbor/gen/harborctl/client"
1111
)
1212

13-
type Client struct {
14-
url string
15-
username string
16-
password string
17-
insecure bool
18-
Client *apiclient.Harbor
19-
}
20-
2113
// NewClient creates common settings
22-
func NewClient(url string, username string, password string, insecure bool, basepath string) *Client {
14+
func NewClient(host string, username string, password string, insecure bool, basepath string, schema string) *apiclient.Harbor {
2315
basicAuth := httptransport.BasicAuth(username, password)
2416
// create the transport
25-
//proxyTLSClientConfig := &tls.Config{InsecureSkipVerify: true}
26-
2717
if insecure {
2818
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
2919
}
30-
transport := httptransport.New(url, basepath, apiclient.DefaultSchemes)
20+
apiSchemes := []string{schema}
21+
transport := httptransport.New(host, basepath, apiSchemes)
3122

3223
// add default auth
3324
transport.DefaultAuthentication = basicAuth
3425

3526
// create the API client, with the transport
3627
client := apiclient.New(transport, strfmt.Default)
37-
return &Client{
38-
url: url,
39-
username: username,
40-
password: password,
41-
insecure: insecure,
42-
Client: client,
43-
}
28+
return client
4429
}

docs/css/table.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.wy-nav-content {
2+
background: white;
3+
max-width: 100%;
4+
height: 100vh;
5+
margin: 0;
6+
}

docs/data_sources/harbor_label.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Data Source: harbor_label
2+
3+
## Example Usage
4+
5+
```hcl
6+
data "harbor_label" "label_1" {
7+
name = "main"
8+
scope = "g"
9+
}
10+
11+
data "harbor_label" "label_2" {
12+
id = 4
13+
}
14+
15+
```
16+
17+
## Argument Reference
18+
19+
- `id` - (Optional, int) ID of the label.
20+
- `name` - (Optional, string) Name of the label.
21+
- `scope` - (Optional, string) Scope of the label.
22+
23+
## Attributes Reference
24+
25+
- `id` - (int) Unique ID of the label.
26+
- `name` - (string) Name of the label.
27+
- `description` - (Optional) The description of the label account will be displayed in harbor.
28+
- `color` - (Optional) The color the label.
29+
- `scope` - (Optional) The scope the label, `p` for project and `g` for global.
30+
- `project_id` - (Optional) The ID of project that the label belongs to.
Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,24 @@
1-
---
2-
subcategory: "project"
3-
page_title: "Harbor: harbor_project"
4-
description: |-
5-
Get information on a Harbor Project
6-
---
7-
81
# Data Source: harbor_project
92

10-
Use this data source to get the ARN of a certificate in AWS Certificate
11-
Manager (ACM), you can reference
12-
it by domain without having to hard code the ARNs as input.
13-
143
## Example Usage
154

165
```hcl
17-
# Find a certificate that is issued
18-
data "aws_acm_certificate" "example" {
19-
domain = "tf.example.com"
20-
statuses = ["ISSUED"]
6+
data "harbor_project" "project_1" {
7+
name = "main"
218
}
229
23-
# Find a certificate issued by (not imported into) ACM
24-
data "aws_acm_certificate" "example" {
25-
domain = "tf.example.com"
26-
types = ["AMAZON_ISSUED"]
27-
most_recent = true
10+
data "harbor_project" "project_2" {
11+
id = 4
2812
}
2913
30-
# Find a RSA 4096 bit certificate
31-
data "aws_acm_certificate" "example" {
32-
domain = "tf.example.com"
33-
key_types = ["RSA_4096"]
34-
}
3514
```
3615

3716
## Argument Reference
3817

39-
* `domain` - (Required) The domain of the certificate to look up. If no certificate is found with this name, an error will be returned.
40-
* `key_types` - (Optional) A list of key algorithms to filter certificates. By default, ACM does not return all certificate types when searching. Valid values are `RSA_1024`, `RSA_2048`, `RSA_4096`, `EC_prime256v1`, `EC_secp384r1`, and `EC_secp521r1`.
41-
* `statuses` - (Optional) A list of statuses on which to filter the returned list. Valid values are `PENDING_VALIDATION`, `ISSUED`,
42-
`INACTIVE`, `EXPIRED`, `VALIDATION_TIMED_OUT`, `REVOKED` and `FAILED`. If no value is specified, only certificates in the `ISSUED` state
43-
are returned.
44-
* `types` - (Optional) A list of types on which to filter the returned list. Valid values are `AMAZON_ISSUED` and `IMPORTED`.
45-
* `most_recent` - (Optional) If set to true, it sorts the certificates matched by previous criteria by the NotBefore field, returning only the most recent one. If set to false, it returns an error if more than one certificate is found. Defaults to false.
18+
- `id` - (Optional, int) ID of the project.
19+
- `name` - (Optional, string) Name of the project.
4620

4721
## Attributes Reference
4822

49-
* `arn` - Set to the ARN of the found certificate, suitable for referencing in other resources that support ACM certificates.
50-
* `tags` - A mapping of tags for the resource.
51-
23+
- `id` - (int) Unique ID of the project.
24+
- `name` - (string) Name of the project.

0 commit comments

Comments
 (0)