-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into marcin/prod-2536-clus…
…ter-name-changes-should-not-force-replacement-in-tf
- Loading branch information
Showing
21 changed files
with
452 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "plural_infrastructure_stack Data Source - terraform-provider-plural" | ||
subcategory: "" | ||
description: |- | ||
Stack data source. | ||
--- | ||
|
||
# plural_infrastructure_stack (Data Source) | ||
|
||
Stack data source. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `id` (String) Internal identifier of this stack. | ||
- `name` (String) Human-readable name of this stack. | ||
|
||
### Read-Only | ||
|
||
- `approval` (Boolean) Determines whether to require approval. | ||
- `cluster_id` (String) The cluster on which the stack is be applied. | ||
- `project_id` (String) ID of the project that this stack belongs to. | ||
- `type` (String) A type for the stack, specifies the tool to use to apply it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "plural_pr_automation Data Source - terraform-provider-plural" | ||
subcategory: "" | ||
description: |- | ||
PR automation data source. | ||
--- | ||
|
||
# plural_pr_automation (Data Source) | ||
|
||
PR automation data source. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `id` (String) Internal identifier of this PR automation. | ||
- `name` (String) Name of this PR automation. | ||
|
||
### Read-Only | ||
|
||
- `identifier` (String) Identifier of this PR automation. | ||
- `message` (String) Message of this PR automation. | ||
- `title` (String) Title of this PR automation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
terraform { | ||
required_providers { | ||
plural = { | ||
source = "pluralsh/plural" | ||
version = "0.2.1" | ||
} | ||
} | ||
} | ||
|
||
provider "plural" { | ||
use_cli = true | ||
} | ||
|
||
data "plural_pr_automation" "automation" { | ||
name = "pr-test" | ||
} | ||
|
||
# resource "plural_pr_automation_trigger" "trigger" { | ||
# pr_automation_id = data.plural_pr_automation.automation.id | ||
# pr_automation_branch = "prautomation" | ||
# context = { | ||
# version: "v0.0.0" | ||
# } | ||
# } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package datasource | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"terraform-provider-plural/internal/client" | ||
"terraform-provider-plural/internal/common" | ||
"terraform-provider-plural/internal/model" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/path" | ||
"github.com/hashicorp/terraform-plugin-framework/schema/validator" | ||
) | ||
|
||
func NewInfrastructureStackDataSource() datasource.DataSource { | ||
return &InfrastructureStackDataSource{} | ||
} | ||
|
||
// InfrastructureStackDataSource defines the stack data source implementation. | ||
type InfrastructureStackDataSource struct { | ||
client *client.Client | ||
} | ||
|
||
func (r *InfrastructureStackDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_infrastructure_stack" | ||
} | ||
|
||
func (r *InfrastructureStackDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
MarkdownDescription: "Stack data source.", | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Optional: true, | ||
Description: "Internal identifier of this stack.", | ||
MarkdownDescription: "Internal identifier of this stack.", | ||
Validators: []validator.String{ | ||
stringvalidator.ExactlyOneOf(path.MatchRoot("name")), | ||
}, | ||
}, | ||
"name": schema.StringAttribute{ | ||
Optional: true, | ||
Description: "Human-readable name of this stack.", | ||
MarkdownDescription: "Human-readable name of this stack.", | ||
Validators: []validator.String{ | ||
stringvalidator.ExactlyOneOf(path.MatchRoot("id")), | ||
}, | ||
}, | ||
"type": schema.StringAttribute{ | ||
Description: "A type for the stack, specifies the tool to use to apply it. ", | ||
MarkdownDescription: "A type for the stack, specifies the tool to use to apply it. ", | ||
Computed: true, | ||
}, | ||
"approval": schema.BoolAttribute{ | ||
Description: "Determines whether to require approval.", | ||
MarkdownDescription: "Determines whether to require approval.", | ||
Computed: true, | ||
}, | ||
"project_id": schema.StringAttribute{ | ||
Description: "ID of the project that this stack belongs to.", | ||
MarkdownDescription: "ID of the project that this stack belongs to.", | ||
Computed: true, | ||
}, | ||
"cluster_id": schema.StringAttribute{ | ||
Description: "The cluster on which the stack is be applied.", | ||
MarkdownDescription: "The cluster on which the stack is be applied.", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (r *InfrastructureStackDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
data, ok := req.ProviderData.(*common.ProviderData) | ||
if !ok { | ||
resp.Diagnostics.AddError( | ||
"Unexpected Infrastructure Stack Resource Configure Type", | ||
fmt.Sprintf("Expected *common.ProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData), | ||
) | ||
|
||
return | ||
} | ||
|
||
r.client = data.Client | ||
} | ||
|
||
func (r *InfrastructureStackDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
data := new(model.InfrastructureStack) | ||
resp.Diagnostics.Append(req.Config.Get(ctx, data)...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
response, err := r.client.GetInfrastructureStack(ctx, data.Id.ValueStringPointer(), data.Name.ValueStringPointer()) | ||
if err != nil { | ||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to get stack, got error: %s", err)) | ||
return | ||
} | ||
|
||
if response == nil || response.InfrastructureStack == nil { | ||
resp.Diagnostics.AddError("Client Error", "Unable to find stack") | ||
return | ||
} | ||
|
||
data.From(response.InfrastructureStack) | ||
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) | ||
} |
Oops, something went wrong.