update to latest release, minor cleanup
This commit is contained in:
parent
741b9dc260
commit
8097a119e6
@ -3,15 +3,11 @@ repos:
|
||||
hooks:
|
||||
- id: tfplugindocs
|
||||
name: tfplugindocs
|
||||
entry: bash -c "go get github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs && go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs && git checkout go.mod go.sum"
|
||||
entry: tfplugindocs
|
||||
language: system
|
||||
types: [go]
|
||||
pass_filenames: false
|
||||
- repo: https://github.com/dnephin/pre-commit-golang
|
||||
rev: v0.5.1
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v1.55.2
|
||||
hooks:
|
||||
- id: go-fmt
|
||||
- id: go-imports
|
||||
- id: go-lint
|
||||
- id: go-mod-tidy
|
||||
- id: go-vet
|
||||
- id: golangci-lint-full
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Terraform provider for Garage (terraform-provider-garage)
|
||||
|
||||
Work in progress to sort my cluster out, but I should be rewriting this to https://github.com/hashicorp/terraform-provider-scaffolding-framework soon
|
||||
|
||||
## Documentation
|
||||
|
||||
You can browse documentation on the [Terraform provider
|
||||
registry](https://registry.terraform.io/providers/prologin/garage).
|
||||
You can browse documentation on the [Terraform provider registry](https://registry.terraform.io/providers/prologin/garage).
|
||||
|
@ -58,5 +58,3 @@ Read-Only:
|
||||
- `permissions_owner` (Boolean)
|
||||
- `permissions_read` (Boolean)
|
||||
- `permissions_write` (Boolean)
|
||||
|
||||
|
||||
|
@ -37,5 +37,3 @@ resource "garage_bucket_global_alias" "www" {
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
|
||||
|
@ -43,5 +43,3 @@ resource "garage_bucket_key" "bucket_key_read-only" {
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
|
||||
|
@ -38,5 +38,3 @@ resource "garage_bucket_local_alias" "bucket_key_private-files" {
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
|
||||
|
@ -24,15 +24,16 @@ resource "garage_key" "key" {
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `name` (String) The name of the key.
|
||||
|
||||
### Optional
|
||||
|
||||
- `access_key_id` (String)
|
||||
- `name` (String) The name of the key.
|
||||
- `permissions` (Map of Boolean)
|
||||
- `secret_access_key` (String, Sensitive)
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ func resourceBucket() *schema.Resource {
|
||||
DeleteContext: resourceBucketDelete,
|
||||
Schema: schemaBucket(),
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,7 @@ func schemaKey() map[string]*schema.Schema {
|
||||
"name": {
|
||||
Description: "The name of the key.",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Required: true,
|
||||
},
|
||||
"access_key_id": {
|
||||
Type: schema.TypeString,
|
||||
@ -40,8 +39,6 @@ func schemaKey() map[string]*schema.Schema {
|
||||
"create_bucket": false,
|
||||
},
|
||||
},
|
||||
// Computed
|
||||
// TODO: buckets
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +51,7 @@ func resourceKey() *schema.Resource {
|
||||
DeleteContext: resourceKeyDelete,
|
||||
Schema: schemaKey(),
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -94,22 +91,22 @@ func resourceKeyCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
var keyInfo *garage.KeyInfo
|
||||
|
||||
var resp *garage.KeyInfo
|
||||
var err error
|
||||
nullableName := garage.NewNullableString(name)
|
||||
infoCtx := updateContext(ctx, p)
|
||||
if accessKeyID != "" || secretAccessKey != "" {
|
||||
importKeyRequest := *garage.NewImportKeyRequest(*garage.NewNullableString(name), accessKeyID, secretAccessKey)
|
||||
resp, _, err := p.client.KeyApi.ImportKey(updateContext(ctx, p)).ImportKeyRequest(importKeyRequest).Execute()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
keyInfo = resp
|
||||
importKeyRequest := *garage.NewImportKeyRequest(*nullableName, accessKeyID, secretAccessKey)
|
||||
resp, _, err = p.client.KeyApi.ImportKey(infoCtx).ImportKeyRequest(importKeyRequest).Execute()
|
||||
} else {
|
||||
addKeyRequest := *garage.NewAddKeyRequest()
|
||||
addKeyRequest.Name = *garage.NewNullableString(name)
|
||||
resp, _, err := p.client.KeyApi.AddKey(updateContext(ctx, p)).AddKeyRequest(addKeyRequest).Execute()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
keyInfo = resp
|
||||
addKeyRequest.Name = *nullableName
|
||||
resp, _, err = p.client.KeyApi.AddKey(infoCtx).AddKeyRequest(addKeyRequest).Execute()
|
||||
}
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
keyInfo = resp
|
||||
|
||||
d.SetId(*keyInfo.AccessKeyId)
|
||||
|
||||
@ -131,7 +128,7 @@ func resourceKeyCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
Deny: &deny,
|
||||
}
|
||||
|
||||
_, _, err := p.client.KeyApi.UpdateKey(updateContext(ctx, p), d.Id()).UpdateKeyRequest(updateKeyRequest).Execute()
|
||||
_, _, err := p.client.KeyApi.UpdateKey(updateContext(ctx, p)).Id(d.Id()).UpdateKeyRequest(updateKeyRequest).Execute()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -200,7 +197,7 @@ func resourceKeyUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
Deny: deny,
|
||||
}
|
||||
|
||||
_, _, err := p.client.KeyApi.UpdateKey(updateContext(ctx, p), d.Id()).UpdateKeyRequest(updateKeyRequest).Execute()
|
||||
_, _, err := p.client.KeyApi.UpdateKey(updateContext(ctx, p)).Id(d.Id()).UpdateKeyRequest(updateKeyRequest).Execute()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -216,7 +213,7 @@ func resourceKeyDelete(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
accessKeyID := d.Id()
|
||||
|
||||
_, err := p.client.KeyApi.DeleteKey(updateContext(ctx, p), accessKeyID).Execute()
|
||||
_, err := p.client.KeyApi.DeleteKey(updateContext(ctx, p)).Id(accessKeyID).Execute()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -3,7 +3,7 @@ module terraform-provider-garage
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
|
||||
github.com/thoas/go-funk v0.9.3
|
||||
)
|
||||
@ -26,6 +26,7 @@ require (
|
||||
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
|
||||
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/kr/pretty v0.3.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
|
13
go.sum
13
go.sum
@ -31,8 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d h1:GxlTiFj3WwYjULWp/MvW2iETmDf7TpOtEP2Qst2TkwU=
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e h1:C/D3P1+mWBTHiO3MeiNWB2S1AJ3A/m7OYGX4iS8nbtA=
|
||||
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
@ -48,6 +48,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -150,11 +151,13 @@ github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gav
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
@ -182,6 +185,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
|
Loading…
Reference in New Issue
Block a user