Skip to content

Commit 8acfbc8

Browse files
committed
Initial commit
0 parents  commit 8acfbc8

Some content is hidden

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

55 files changed

+3252
-0
lines changed

GNUmakefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.PHONY: test unit-test acceptance-test
2+
3+
test: unit-test acceptance-test
4+
5+
unit-test:
6+
@echo "Running unit tests..."
7+
@go test -tags=unit ./... -v $(TESTARGS) -timeout 120m
8+
9+
acceptance-test:
10+
@echo "Running acceptance tests..."
11+
@go test -tags=acceptance ./... -v $(TESTARGS) -timeout 120m

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# liblab Terraform Provider 0.0.1
2+
3+
This repository contains a Terraform provider that allows you to manage resources through the liblab API.
4+
5+
## Prerequisites
6+
7+
- [Go](https://golang.org/doc/install) >= 1.19
8+
9+
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0
10+
11+
- Access to the liblab API.
12+
13+
## Installing The Provider
14+
15+
1. Clone the repository:
16+
17+
```bash
18+
git clone https://github.com/liblaber/terraform-provider-liblab.git
19+
```
20+
21+
2. Navigate to the directory:
22+
23+
```bash
24+
cd terraform-provider-liblab
25+
```
26+
27+
3. Update module references:
28+
29+
```bash
30+
go mod tidy
31+
```
32+
33+
4. Build the provider:
34+
35+
```bash
36+
go build -o terraform-provider-liblab
37+
```
38+
39+
5. Move the provider to your plugins directory:
40+
41+
```bash
42+
mkdir -p ~/.terraform.d/plugins/example.com/user/liblab/0.0.1/<distribution>
43+
mv terraform-provider-liblab ~/.terraform.d/plugins/example.com/user/liblab/0.0.1/<distribution>
44+
```
45+
46+
Note: The directory structure is important. The provider must be located at `~/.terraform.d/plugins/example.com/user/liblab/0.0.1/<distribution>/terraform-provider-liblab`
47+
Also please change `example.com/user` and `<distribution>` to match your real values.
48+
To get the <distribution> run `terraform version`, possible values: `linux_amd64`, `darwin_arm64`, `windows_amd64`, etc.
49+
50+
## Setting Up The Provider
51+
52+
1. Configure the provider:
53+
54+
In your Terraform configuration, reference the provider and supply the necessary credentials:
55+
56+
```hcl
57+
provider "liblab" {
58+
host = "https://localhost/"
59+
api_token = "YOUR_API_TOKEN"
60+
}
61+
```
62+
63+
## Running The Provider
64+
65+
To plan and apply your Terraform configuration:
66+
67+
1. Initialize your configuration:
68+
69+
```bash
70+
terraform init -plugin-dir=~/.terraform.d/plugins
71+
```
72+
73+
2. Plan your changes:
74+
75+
```bash
76+
terraform plan
77+
```
78+
79+
3. Apply your configuration:
80+
81+
```bash
82+
terraform apply
83+
```
84+
85+
## Debugging
86+
87+
If you encounter any issues or unexpected behaviors, enable debug mode by setting the environment variable:
88+
89+
```bash
90+
export TF_PROVIDER_DEBUG=true
91+
```
92+
93+
Then, run your Terraform commands.
94+
95+
## Running Tests
96+
97+
1. Generate the docs:
98+
99+
```bash
100+
go generate ./...
101+
```
102+
103+
2. To execute the provider's tests, follow these steps:
104+
105+
**a. Run Unit Tests**:
106+
107+
```bash
108+
make unit-test
109+
```
110+
111+
**b. Run Acceptance Tests**:
112+
113+
```bash
114+
make acceptance-test
115+
```
116+
117+
## Publishing the Provider
118+
119+
1. Tag your release:
120+
121+
```bash
122+
git tag v0.0.1
123+
git push --tags
124+
```
125+
126+
2. Build a release binary for your platform:
127+
128+
```bash
129+
GOOS=linux GOARCH=amd64 go build -o terraform-provider-liblab
130+
```
131+
132+
3. Upload the binary to the GitHub release or any other distribution method you prefer.
133+
134+
Note: For wide-reaching utility, consider registering your provider with the official Terraform provider registry once
135+
it becomes popular within the community.
136+
137+
<!-- Generated by LIBLAB | https://liblab.com -->

examples/provider/main.tf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
terraform {
2+
required_providers {
3+
liblab = {
4+
source = "hashicorp.com/edu/liblab"
5+
version = "0.0.1"
6+
}
7+
}
8+
}
9+
10+
provider "liblab" {
11+
12+
host = "https://api.example.com"
13+
14+
auth_token = "MY_TOKEN"
15+
16+
}

examples/resources/token/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resource "liblab_token" "example" {
2+
name = "My Token"
3+
4+
expires_at = "My Token"
5+
6+
scope = [
7+
"scope"
8+
]
9+
10+
}

go.mod

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
module github.com/terraform-provider-liblab
2+
3+
go 1.19
4+
5+
require (
6+
github.com/hashicorp/terraform-plugin-docs v0.16.0
7+
github.com/hashicorp/terraform-plugin-framework v1.3.5
8+
github.com/hashicorp/terraform-plugin-go v0.18.0
9+
github.com/hashicorp/terraform-plugin-testing v1.5.1
10+
github.com/liblab-sdk v0.0.0
11+
github.com/stretchr/testify v1.8.4
12+
)
13+
14+
require (
15+
github.com/Masterminds/goutils v1.1.1 // indirect
16+
github.com/Masterminds/semver/v3 v3.1.1 // indirect
17+
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
18+
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
19+
github.com/agext/levenshtein v1.2.2 // indirect
20+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
21+
github.com/armon/go-radix v1.0.0 // indirect
22+
github.com/bgentry/speakeasy v0.1.0 // indirect
23+
github.com/cloudflare/circl v1.3.3 // indirect
24+
github.com/davecgh/go-spew v1.1.1 // indirect
25+
github.com/fatih/color v1.13.0 // indirect
26+
github.com/golang/protobuf v1.5.3 // indirect
27+
github.com/google/go-cmp v0.5.9 // indirect
28+
github.com/google/uuid v1.3.0 // indirect
29+
github.com/hashicorp/errwrap v1.1.0 // indirect
30+
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
31+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
32+
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
33+
github.com/hashicorp/go-hclog v1.5.0 // indirect
34+
github.com/hashicorp/go-multierror v1.1.1 // indirect
35+
github.com/hashicorp/go-plugin v1.4.10 // indirect
36+
github.com/hashicorp/go-uuid v1.0.3 // indirect
37+
github.com/hashicorp/go-version v1.6.0 // indirect
38+
github.com/hashicorp/hc-install v0.5.2 // indirect
39+
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
40+
github.com/hashicorp/logutils v1.0.0 // indirect
41+
github.com/hashicorp/terraform-exec v0.18.1 // indirect
42+
github.com/hashicorp/terraform-json v0.17.1 // indirect
43+
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
44+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 // indirect
45+
github.com/hashicorp/terraform-registry-address v0.2.1 // indirect
46+
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
47+
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
48+
github.com/huandu/xstrings v1.3.2 // indirect
49+
github.com/imdario/mergo v0.3.13 // indirect
50+
github.com/mattn/go-colorable v0.1.13 // indirect
51+
github.com/mattn/go-isatty v0.0.16 // indirect
52+
github.com/mitchellh/cli v1.1.5 // indirect
53+
github.com/mitchellh/copystructure v1.2.0 // indirect
54+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
55+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
56+
github.com/mitchellh/mapstructure v1.5.0 // indirect
57+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
58+
github.com/oklog/run v1.0.0 // indirect
59+
github.com/pmezard/go-difflib v1.0.0 // indirect
60+
github.com/posener/complete v1.2.3 // indirect
61+
github.com/russross/blackfriday v1.6.0 // indirect
62+
github.com/shopspring/decimal v1.3.1 // indirect
63+
github.com/spf13/cast v1.5.0 // indirect
64+
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
65+
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
66+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
67+
github.com/zclconf/go-cty v1.13.3 // indirect
68+
golang.org/x/crypto v0.12.0 // indirect
69+
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
70+
golang.org/x/mod v0.11.0 // indirect
71+
golang.org/x/net v0.11.0 // indirect
72+
golang.org/x/sys v0.11.0 // indirect
73+
golang.org/x/text v0.12.0 // indirect
74+
google.golang.org/appengine v1.6.7 // indirect
75+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
76+
google.golang.org/grpc v1.56.1 // indirect
77+
google.golang.org/protobuf v1.31.0 // indirect
78+
gopkg.in/yaml.v3 v3.0.1 // indirect
79+
)
80+
81+
replace github.com/liblab-sdk => ./internal/client

0 commit comments

Comments
 (0)