Skip to content
Open
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: 2 additions & 0 deletions docs/data-sources/intake_runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions docs/resources/intake_runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 12 additions & 0 deletions stackit/internal/services/intake/intake_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
Expand All @@ -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"),
),
},
Expand Down Expand Up @@ -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"),
),
},
Expand Down Expand Up @@ -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"])),
),
},
Expand All @@ -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"),
),
Expand Down Expand Up @@ -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"])),
),
},
Expand Down
10 changes: 10 additions & 0 deletions stackit/internal/services/intake/runner/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
}

Expand Down Expand Up @@ -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"],
Expand Down
20 changes: 20 additions & 0 deletions stackit/internal/services/intake/runner/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions stackit/internal/services/intake/runner/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
Expand All @@ -17,6 +18,8 @@ import (

func TestMapFields(t *testing.T) {
runnerId := uuid.New().String()
now := time.Now()

tests := []struct {
description string
input *intake.IntakeRunnerResponse
Expand All @@ -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"),
Expand All @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down