diff --git a/docs/data-sources/intake_runner.md b/docs/data-sources/intake_runner.md index 52806a24a..73968c0c9 100644 --- a/docs/data-sources/intake_runner.md +++ b/docs/data-sources/intake_runner.md @@ -33,9 +33,11 @@ data "stackit_intake_runner" "example" { ### Read-Only +- `create_time` (String) The creation time of the runner. - `description` (String) The description of the runner. - `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`runner_id`". - `labels` (Map of String) User-defined labels. - `max_message_size_kib` (Number) The maximum message size in KiB. - `max_messages_per_hour` (Number) The maximum number of messages per hour. - `name` (String) The name of the runner. +- `uri` (String) The URI of the runner. diff --git a/docs/resources/intake_runner.md b/docs/resources/intake_runner.md index 4dd64b6ab..4ec4a797d 100644 --- a/docs/resources/intake_runner.md +++ b/docs/resources/intake_runner.md @@ -44,5 +44,7 @@ resource "stackit_intake_runner" "example" { ### Read-Only +- `create_time` (String) The creation time of the runner. - `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`runner_id`". - `runner_id` (String) The runner ID. +- `uri` (String) The URI of the runner. diff --git a/stackit/internal/services/intake/intake_acc_test.go b/stackit/internal/services/intake/intake_acc_test.go index 91d1c7a98..e7d2f9235 100644 --- a/stackit/internal/services/intake/intake_acc_test.go +++ b/stackit/internal/services/intake/intake_acc_test.go @@ -76,6 +76,8 @@ func TestAccIntakeRunnerMin(t *testing.T) { resource.TestCheckResourceAttr(intakeRunnerResource, "max_message_size_kib", testutil.ConvertConfigVariable(testIntakeRunnerConfigVarsMin["max_message_size_kib"])), resource.TestCheckResourceAttr(intakeRunnerResource, "max_messages_per_hour", testutil.ConvertConfigVariable(testIntakeRunnerConfigVarsMin["max_messages_per_hour"])), resource.TestCheckResourceAttrSet(intakeRunnerResource, "id"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "uri"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "create_time"), resource.TestCheckResourceAttr(intakeRunnerResource, "region", testutil.Region), ), }, @@ -98,6 +100,8 @@ func TestAccIntakeRunnerMin(t *testing.T) { resource.TestCheckResourceAttrPair(intakeRunnerResource, "region", "data.stackit_intake_runner.example", "region"), resource.TestCheckNoResourceAttr(intakeRunnerResource, "description"), resource.TestCheckNoResourceAttr(intakeRunnerResource, "labels"), + resource.TestCheckResourceAttrPair(intakeRunnerResource, "uri", "data.stackit_intake_runner.example", "uri"), + resource.TestCheckResourceAttrPair(intakeRunnerResource, "create_time", "data.stackit_intake_runner.example", "create_time"), resource.TestCheckResourceAttrPair(intakeRunnerResource, "max_messages_per_hour", "data.stackit_intake_runner.example", "max_messages_per_hour"), ), }, @@ -131,6 +135,8 @@ func TestAccIntakeRunnerMin(t *testing.T) { resource.TestCheckNoResourceAttr(intakeRunnerResource, "description"), resource.TestCheckNoResourceAttr(intakeRunnerResource, "labels"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "runner_id"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "uri"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "create_time"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "id"), ), }, @@ -158,6 +164,8 @@ func TestAccIntakeRunnerMax(t *testing.T) { resource.TestCheckResourceAttr(intakeRunnerResource, "labels.created_by", "terraform-provider-stackit"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "runner_id"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "id"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "uri"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "create_time"), resource.TestCheckResourceAttr(intakeRunnerResource, "region", testutil.ConvertConfigVariable(testIntakeRunnerConfigVarsMax["region"])), ), }, @@ -176,6 +184,8 @@ func TestAccIntakeRunnerMax(t *testing.T) { resource.TestCheckResourceAttrPair(intakeRunnerResource, "name", "data.stackit_intake_runner.example", "name"), resource.TestCheckResourceAttrPair(intakeRunnerResource, "description", "data.stackit_intake_runner.example", "description"), resource.TestCheckResourceAttrPair(intakeRunnerResource, "region", "data.stackit_intake_runner.example", "region"), + resource.TestCheckResourceAttrPair(intakeRunnerResource, "uri", "data.stackit_intake_runner.example", "uri"), + resource.TestCheckResourceAttrPair(intakeRunnerResource, "create_time", "data.stackit_intake_runner.example", "create_time"), resource.TestCheckResourceAttrPair(intakeRunnerResource, "labels.env", "data.stackit_intake_runner.example", "labels.env"), resource.TestCheckResourceAttrPair(intakeRunnerResource, "max_messages_per_hour", "data.stackit_intake_runner.example", "max_messages_per_hour"), ), @@ -212,6 +222,8 @@ func TestAccIntakeRunnerMax(t *testing.T) { resource.TestCheckResourceAttr(intakeRunnerResource, "labels.created_by", "terraform-provider-stackit"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "runner_id"), resource.TestCheckResourceAttrSet(intakeRunnerResource, "id"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "uri"), + resource.TestCheckResourceAttrSet(intakeRunnerResource, "create_time"), resource.TestCheckResourceAttr(intakeRunnerResource, "region", testutil.ConvertConfigVariable(testIntakeRunnerConfigVarsMax["region"])), ), }, diff --git a/stackit/internal/services/intake/runner/datasource.go b/stackit/internal/services/intake/runner/datasource.go index 2f3197b46..3e7d202d4 100644 --- a/stackit/internal/services/intake/runner/datasource.go +++ b/stackit/internal/services/intake/runner/datasource.go @@ -68,6 +68,8 @@ func (r *runnerDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, "labels": "User-defined labels.", "max_message_size_kib": "The maximum message size in KiB.", "max_messages_per_hour": "The maximum number of messages per hour.", + "uri": "The URI of the runner.", + "create_time": "The creation time of the runner.", "region": "The resource region. If not defined, the provider region is used.", } @@ -115,6 +117,14 @@ func (r *runnerDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, Description: descriptions["max_messages_per_hour"], Computed: true, }, + "uri": schema.StringAttribute{ + Description: descriptions["uri"], + Computed: true, + }, + "create_time": schema.StringAttribute{ + Description: descriptions["create_time"], + Computed: true, + }, "region": schema.StringAttribute{ Optional: true, Description: descriptions["region"], diff --git a/stackit/internal/services/intake/runner/resource.go b/stackit/internal/services/intake/runner/resource.go index d6fb036f4..f99bafbe5 100644 --- a/stackit/internal/services/intake/runner/resource.go +++ b/stackit/internal/services/intake/runner/resource.go @@ -47,6 +47,8 @@ type Model struct { MaxMessageSizeKiB types.Int32 `tfsdk:"max_message_size_kib"` MaxMessagesPerHour types.Int32 `tfsdk:"max_messages_per_hour"` Region types.String `tfsdk:"region"` + Uri types.String `tfsdk:"uri"` + CreateTime types.String `tfsdk:"create_time"` } // NewRunnerResource is a helper function to simplify the provider implementation. @@ -123,6 +125,8 @@ func (r *runnerResource) Schema(_ context.Context, _ resource.SchemaRequest, res "labels": "User-defined labels.", "max_message_size_kib": "The maximum message size in KiB.", "max_messages_per_hour": "The maximum number of messages per hour.", + "uri": "The URI of the runner.", + "create_time": "The creation time of the runner.", } resp.Schema = schema.Schema{ @@ -181,6 +185,20 @@ func (r *runnerResource) Schema(_ context.Context, _ resource.SchemaRequest, res Description: descriptions["max_messages_per_hour"], Required: true, }, + "uri": schema.StringAttribute{ + Description: descriptions["uri"], + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "create_time": schema.StringAttribute{ + Description: descriptions["create_time"], + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "region": schema.StringAttribute{ Optional: true, Computed: true, @@ -443,6 +461,8 @@ func mapFields(ctx context.Context, runnerResp *intake.IntakeRunnerResponse, mod model.Region = types.StringValue(region) model.MaxMessageSizeKiB = types.Int32Value(runnerResp.MaxMessageSizeKiB) model.MaxMessagesPerHour = types.Int32Value(runnerResp.MaxMessagesPerHour) + model.Uri = types.StringValue(runnerResp.Uri) + model.CreateTime = types.StringValue(runnerResp.CreateTime.String()) return nil } diff --git a/stackit/internal/services/intake/runner/resource_test.go b/stackit/internal/services/intake/runner/resource_test.go index 76f7af008..badce238c 100644 --- a/stackit/internal/services/intake/runner/resource_test.go +++ b/stackit/internal/services/intake/runner/resource_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "testing" + "time" "github.com/google/go-cmp/cmp" "github.com/google/uuid" @@ -17,6 +18,8 @@ import ( func TestMapFields(t *testing.T) { runnerId := uuid.New().String() + now := time.Now() + tests := []struct { description string input *intake.IntakeRunnerResponse @@ -34,6 +37,8 @@ func TestMapFields(t *testing.T) { Labels: map[string]string{"key": "value"}, MaxMessageSizeKiB: int32(1024), MaxMessagesPerHour: int32(100), + Uri: "c512e9ea-b086-4945-b8e1-8f9a4b592b06.intake.eu01.onstackit.cloud:9094", + CreateTime: now, }, &Model{ ProjectId: types.StringValue("pid"), @@ -49,6 +54,8 @@ func TestMapFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{"key": types.StringValue("value")}), MaxMessageSizeKiB: types.Int32Value(1024), MaxMessagesPerHour: types.Int32Value(100), + Uri: types.StringValue("c512e9ea-b086-4945-b8e1-8f9a4b592b06.intake.eu01.onstackit.cloud:9094"), + CreateTime: types.StringValue(now.String()), }, false, }, @@ -88,6 +95,8 @@ func TestMapFields(t *testing.T) { Labels: types.MapNull(types.StringType), MaxMessageSizeKiB: types.Int32Value(0), MaxMessagesPerHour: types.Int32Value(0), + Uri: types.StringValue(""), + CreateTime: types.StringValue(time.Time{}.String()), }, false, },