Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed overwriting the token value during read #50

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/resources/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Required:

Required:

- `org_id` (String) An organization ID. Identifies the organization that owns the resource.
- `type` (String) A resource type. Identifies the API resource's type (or kind).

Optional:

- `id` (String) A resource ID. Identifies a specific resource.
- `org` (String) An organization name. The organization that owns the resource.
- `org_id` (String) An organization ID. Identifies the organization that owns the resource.

Read-Only:

Expand Down
18 changes: 14 additions & 4 deletions examples/resources/authorization/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
terraform {
required_providers {
influxdb = {
source = "komminarlabs/influxdb"
}
}
}

provider "influxdb" {}

data "influxdb_organization" "iot" {
Expand All @@ -15,15 +23,17 @@ resource "influxdb_authorization" "signals" {
permissions = [{
action = "read"
resource = {
id = data.influxdb_bucket.signals.id
type = "buckets"
id = data.influxdb_bucket.signals.id
org_id = data.influxdb_organization.iot.id
type = "buckets"
}
},
{
action = "write"
resource = {
id = data.influxdb_bucket.signals.id
type = "buckets"
id = data.influxdb_bucket.signals.id
org_id = data.influxdb_organization.iot.id
type = "buckets"
}
}]
}
Expand Down
8 changes: 8 additions & 0 deletions examples/resources/bucket/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
terraform {
required_providers {
influxdb = {
source = "komminarlabs/influxdb"
}
}
}

provider "influxdb" {}

data "influxdb_organization" "iot" {
Expand Down
8 changes: 8 additions & 0 deletions examples/resources/organization/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
terraform {
required_providers {
influxdb = {
source = "komminarlabs/influxdb"
}
}
}

provider "influxdb" {}

resource "influxdb_organization" "iot" {
Expand Down
10 changes: 4 additions & 6 deletions internal/provider/authorization_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
Computed: true,
Description: "The API token.",
Sensitive: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},

Check warning on line 64 in internal/provider/authorization_resource.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/authorization_resource.go#L62-L64

Added lines #L62 - L64 were not covered by tests
},
"status": schema.StringAttribute{
Optional: true,
Expand Down Expand Up @@ -142,12 +145,8 @@
},
},
"org_id": schema.StringAttribute{
Computed: true,
Optional: true,
Required: true,

Check warning on line 148 in internal/provider/authorization_resource.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/authorization_resource.go#L148

Added line #L148 was not covered by tests
Description: "An organization ID. Identifies the organization that owns the resource.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"type": schema.StringAttribute{
Required: true,
Expand Down Expand Up @@ -300,7 +299,6 @@
state.Id = types.StringPointerValue(authorization.Id)
state.Org = types.StringPointerValue(authorization.Org)
state.OrgID = types.StringPointerValue(authorization.OrgID)
state.Token = types.StringPointerValue(authorization.Token)
state.CreatedAt = types.StringValue(authorization.CreatedAt.String())
state.UpdatedAt = types.StringValue(authorization.UpdatedAt.String())
state.Description = types.StringValue(*authorization.AuthorizationUpdateRequest.Description)
Expand Down
Loading