Skip to content

Commit ef48b35

Browse files
committed
Merge branch 'main' into prepare-publish-configs
2 parents e909bf7 + b19710f commit ef48b35

22 files changed

+2054
-140
lines changed

.golangci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
issues:
2+
max-issues-per-linter: 0
3+
max-same-issues: 0
4+
5+
linters:
6+
disable-all: true
7+
enable:
8+
- durationcheck
9+
- errcheck
10+
- copyloopvar
11+
- godot
12+
- gofmt
13+
- gosimple
14+
- ineffassign
15+
- makezero
16+
- misspell
17+
- nilerr
18+
- predeclared
19+
- staticcheck
20+
- tenv
21+
- unconvert
22+
- unparam
23+
- unused
24+
- govet

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build install test testacc
1+
.PHONY: build install test testacc doc lint
22

33
build:
44
@go build -o terraform-provider-karpor
@@ -7,8 +7,15 @@ install: build
77
@mkdir -p ~/.terraform.d/plugins/registry.terraform.io/KusionStack/karpor/0.1.0/darwin_amd64
88
@mv terraform-provider-karpor ~/.terraform.d/plugins/registry.terraform.io/KusionStack/karpor/0.1.0/darwin_amd64
99

10+
lint:
11+
@which golangci-lint > /dev/null || (echo "Installing golangci-lint@latest ..."; $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && echo -e "Installation complete!\n")
12+
golangci-lint run ././... --fast --verbose --print-resources-usage
13+
1014
test:
1115
@go test -v ./...
1216

17+
doc:
18+
@cd tools && go generate ./...
19+
1320
testacc:
1421
@TF_ACC=1 go test -v ./...

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ provider "karpor" {
3636
```hcl
3737
resource "karpor_cluster_registration" "production" {
3838
cluster_name = "production-cluster"
39-
api_server_url = "https://k8s.example.com"
4039
credentials = file("~/.kube/config")
4140
description = "Primary production cluster"
4241
}
@@ -58,7 +57,7 @@ make testacc # Run acceptance tests (requires API credentials)
5857
### Test Configuration
5958
Set environment variables before testing:
6059
```bash
61-
export KARPOR_ENDPOINT="https://api.karpor.example.com"
60+
export KARPOR_API_ENDPOINT="https://api.karpor.example.com"
6261
export KARPOR_API_KEY="your-api-key"
6362
```
6463

docs/data-sources/cluster.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "karpor_cluster Data Source - karpor"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# karpor_cluster (Data Source)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `cluster_name` (String)
21+
22+
### Read-Only
23+
24+
- `description` (String)
25+
- `display_name` (String)
26+
- `id` (String) The ID of this resource.

docs/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "karpor Provider"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# karpor Provider
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
karpor = {
19+
source = "registry.terraform.io/KusionStack/karpor"
20+
version = "0.1.0"
21+
}
22+
}
23+
}
24+
25+
provider "karpor" {
26+
api_endpoint = "https://api.karpor.example.com"
27+
api_key = "your-api-key-here"
28+
}
29+
```
30+
31+
<!-- schema generated by tfplugindocs -->
32+
## Schema
33+
34+
### Optional
35+
36+
- `api_endpoint` (String) Karpor API endpoint URL
37+
- `api_key` (String, Sensitive) API key for authentication
38+
- `skip_tls_verify` (Boolean) Skip TLS verification, by default it is false
Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
# karpor_cluster_registration
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "karpor_cluster_registration Resource - karpor"
4+
subcategory: ""
5+
description: |-
6+
7+
---
28

3-
Register and manage Kubernetes clusters in Karpor
9+
# karpor_cluster_registration (Resource)
410

5-
## Example Usage
611

7-
```hcl
8-
resource "karpor_cluster_registration" "example" {
9-
cluster_name = "production-cluster"
10-
api_server_url = "https://kubernetes.example.com"
11-
credentials = file("~/.kube/config")
12-
description = "Production Kubernetes cluster"
13-
}
14-
```
1512

16-
## Argument Reference
1713

18-
- `cluster_name` (Required) - Unique name for the cluster
19-
- `api_server_url` (Required) - Kubernetes API server URL
20-
- `credentials` (Required) - Path to kubeconfig file
21-
- `description` (Optional) - Human-readable description
2214

23-
## Attributes Reference
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
2417

25-
- `id` - Unique identifier for the registration
26-
- `registration_time` - Timestamp of registration
27-
- `health_status` - Current cluster health status
18+
### Required
19+
20+
- `cluster_name` (String) Unique name for the cluster
21+
- `credentials` (String, Sensitive) Path to kubeconfig file
22+
23+
### Optional
24+
25+
- `description` (String) Human-readable description
26+
- `display_name` (String) Human-readable display name
27+
28+
### Read-Only
29+
30+
- `id` (String) Unique identifier
31+
- `last_updated` (String) Last updated timestamp
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
terraform {
2+
required_providers {
3+
karpor = {
4+
source = "registry.terraform.io/KusionStack/karpor"
5+
version = "0.1.0"
6+
}
7+
}
8+
}
9+
10+
provider "karpor" {
11+
api_endpoint = "https://127.0.0.1:7443"
12+
api_key = "your-api-key-here"
13+
skip_tls_verify = true
14+
}
15+
16+
data "karpor_cluster" "example" {
17+
cluster_name = "local-cluster"
18+
}
19+
20+
output "cluster_name" {
21+
value = data.karpor_cluster.example.cluster_name
22+
}
23+
24+
output "display_name" {
25+
value = data.karpor_cluster.example.display_name
26+
}
27+
28+
output "description" {
29+
value = data.karpor_cluster.example.description
30+
}
31+

examples/provider/provider.tf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
karpor = {
4-
source = "KusionStack/karpor"
4+
source = "registry.terraform.io/KusionStack/karpor"
55
version = "0.1.0"
66
}
77
}
@@ -11,10 +11,3 @@ provider "karpor" {
1111
api_endpoint = "https://api.karpor.example.com"
1212
api_key = "your-api-key-here"
1313
}
14-
15-
resource "karpor_cluster_registration" "example" {
16-
cluster_name = "production-cluster"
17-
api_server_url = "https://kubernetes.example.com"
18-
credentials = file("~/.kube/config")
19-
description = "Production Kubernetes cluster"
20-
}

examples/resources/resource.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
terraform {
2+
required_providers {
3+
karpor = {
4+
source = "registry.terraform.io/KusionStack/karpor"
5+
version = "0.1.0"
6+
}
7+
}
8+
}
9+
10+
provider "karpor" {
11+
api_endpoint = "https://127.0.0.1:7443"
12+
api_key = "your-api-key-here"
13+
skip_tls_verify = true
14+
}
15+
16+
resource "karpor_cluster_registration" "example" {
17+
cluster_name = "local-cluster"
18+
display_name = "local-cluster-display-name"
19+
credentials = file("~/config")
20+
description = "Local Kubernetes cluster"
21+
}
22+
23+
24+
output "cluster_name" {
25+
value = karpor_cluster_registration.example.cluster_name
26+
}
27+
28+
output "display_name" {
29+
value = karpor_cluster_registration.example.display_name
30+
}

go.mod

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,62 @@
11
module github.com/KusionStack/terraform-provider-karpor
22

3-
go 1.21
3+
go 1.22.7
44

5-
require github.com/hashicorp/terraform-plugin-framework v1.5.0
5+
require (
6+
github.com/hashicorp/terraform-plugin-framework v1.13.0
7+
github.com/hashicorp/terraform-plugin-go v0.26.0
8+
github.com/hashicorp/terraform-plugin-log v0.9.0
9+
github.com/hashicorp/terraform-plugin-testing v1.11.0
10+
)
611

712
require (
8-
github.com/fatih/color v1.13.0 // indirect
9-
github.com/golang/protobuf v1.5.3 // indirect
10-
github.com/hashicorp/go-hclog v1.5.0 // indirect
11-
github.com/hashicorp/go-plugin v1.6.0 // indirect
13+
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
14+
github.com/agext/levenshtein v1.2.2 // indirect
15+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
16+
github.com/cloudflare/circl v1.3.7 // indirect
17+
github.com/fatih/color v1.16.0 // indirect
18+
github.com/golang/protobuf v1.5.4 // indirect
19+
github.com/google/go-cmp v0.6.0 // indirect
20+
github.com/hashicorp/errwrap v1.0.0 // indirect
21+
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
22+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
23+
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
24+
github.com/hashicorp/go-hclog v1.6.3 // indirect
25+
github.com/hashicorp/go-multierror v1.1.1 // indirect
26+
github.com/hashicorp/go-plugin v1.6.2 // indirect
27+
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
1228
github.com/hashicorp/go-uuid v1.0.3 // indirect
13-
github.com/hashicorp/terraform-plugin-go v0.20.0 // indirect
14-
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
15-
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
29+
github.com/hashicorp/go-version v1.7.0 // indirect
30+
github.com/hashicorp/hc-install v0.9.0 // indirect
31+
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
32+
github.com/hashicorp/logutils v1.0.0 // indirect
33+
github.com/hashicorp/terraform-exec v0.21.0 // indirect
34+
github.com/hashicorp/terraform-json v0.23.0 // indirect
35+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 // indirect
36+
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
1637
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
1738
github.com/hashicorp/yamux v0.1.1 // indirect
1839
github.com/mattn/go-colorable v0.1.13 // indirect
19-
github.com/mattn/go-isatty v0.0.16 // indirect
40+
github.com/mattn/go-isatty v0.0.20 // indirect
41+
github.com/mitchellh/copystructure v1.2.0 // indirect
2042
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
43+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
44+
github.com/mitchellh/mapstructure v1.5.0 // indirect
45+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
2146
github.com/oklog/run v1.0.0 // indirect
47+
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
2248
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
2349
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
24-
golang.org/x/net v0.17.0 // indirect
25-
golang.org/x/sys v0.13.0 // indirect
26-
golang.org/x/text v0.13.0 // indirect
27-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
28-
google.golang.org/grpc v1.60.0 // indirect
29-
google.golang.org/protobuf v1.31.0 // indirect
50+
github.com/zclconf/go-cty v1.15.0 // indirect
51+
golang.org/x/crypto v0.32.0 // indirect
52+
golang.org/x/mod v0.21.0 // indirect
53+
golang.org/x/net v0.34.0 // indirect
54+
golang.org/x/sync v0.10.0 // indirect
55+
golang.org/x/sys v0.29.0 // indirect
56+
golang.org/x/text v0.21.0 // indirect
57+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
58+
google.golang.org/appengine v1.6.8 // indirect
59+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
60+
google.golang.org/grpc v1.69.4 // indirect
61+
google.golang.org/protobuf v1.36.3 // indirect
3062
)

0 commit comments

Comments
 (0)