Skip to content

Commit

Permalink
Merge pull request #224 from SchwarzIT/bugfix-register-network-resource
Browse files Browse the repository at this point in the history
bugfix: register stackit network resource
  • Loading branch information
EmilGeorgiev authored Feb 23, 2024
2 parents d3b291c + 45ef42b commit 91f128c
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 21 deletions.
40 changes: 40 additions & 0 deletions docs/data-sources/network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "stackit_network Data Source - stackit"
subcategory: ""
description: |-
Data source for STACKIT network
-> Environment supportTo set a custom API base URL, set STACKITKUBERNETESBASEURL environment variable
---

# stackit_network (Data Source)

Data source for STACKIT network

<br />

-> __Environment support__<small>To set a custom API base URL, set <code>STACKIT_KUBERNETES_BASEURL</code> environment variable </small>



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) the name of the network
- `project_id` (String) The project UUID.

### Optional

- `nameservers` (List of String) List of DNS Servers/Nameservers.
- `prefix_length_v4` (Number) prefix length

### Read-Only

- `network_id` (String) The ID of the network
- `prefixes` (List of String)
- `public_ip` (String) public IP address


40 changes: 40 additions & 0 deletions docs/resources/network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "stackit_network Resource - stackit"
subcategory: ""
description: |-
Manages STACKIT network
-> Environment supportTo set a custom API base URL, set STACKITRESOURCEMANAGEMENT_BASEURL environment variable
---

# stackit_network (Resource)

Manages STACKIT network

<br />

-> __Environment support__<small>To set a custom API base URL, set <code>STACKIT_RESOURCE_MANAGEMENT_BASEURL</code> environment variable </small>



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) the name of the network
- `project_id` (String) The project UUID.

### Optional

- `nameservers` (List of String) List of DNS Servers/Nameservers.
- `prefix_length_v4` (Number) prefix length

### Read-Only

- `network_id` (String) The ID of the network
- `prefixes` (List of String)
- `public_ip` (String) public IP address


2 changes: 1 addition & 1 deletion stackit/internal/data-sources/network/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = datasource.DataSource(&DataSource{})

// Metadata returns data resource metadata
func (d *DataSource) Metadata(_ context.Context, req datasource.MetadataRequest, res *datasource.MetadataResponse) {
res.TypeName = "stackit_project"
res.TypeName = "stackit_network"
}

// Configure configures the data source client
Expand Down
20 changes: 10 additions & 10 deletions stackit/internal/data-sources/network/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
type Network struct {
Name types.String `tfsdk:"name"`
NameServers []types.String `tfsdk:"nameservers"`
NetworkID types.String `tfsdk:"networkId"`
NetworkID types.String `tfsdk:"network_id"`
Prefixes []types.String `tfsdk:"prefixes"`
PrefixLengthV4 types.Int64 `tfsdk:"prefixLengthV4"`
PublicIp types.String `tssdk:"publicIp"`
PrefixLengthV4 types.Int64 `tfsdk:"prefix_length_v4"`
PublicIp types.String `tssdk:"public_ip"`
ProjectID types.String `tfsdk:"project_id"`
}

Expand All @@ -39,31 +39,31 @@ func (r *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, r
},
"nameservers": schema.ListAttribute{
Description: "List of DNS Servers/Nameservers.",
Required: false,
Optional: true,
ElementType: types.StringType,
Validators: []validator.List{
validate.NameServers(),
},
},
"networkId": schema.StringAttribute{
"network_id": schema.StringAttribute{
Description: "The ID of the network",
Required: true,
Computed: true,
},
"prefixes": schema.ListAttribute{
Required: true,
Computed: true,
ElementType: types.StringType,
Validators: []validator.List{
validate.Prefixes(),
},
},
"prefixLengthV4": schema.Int64Attribute{
"prefix_length_v4": schema.Int64Attribute{
Description: "prefix length",
Required: true,
Optional: true,
Validators: []validator.Int64{
validate.PrefixLengthV4(),
},
},
"publicIp": schema.StringAttribute{
"public_ip": schema.StringAttribute{
Description: "public IP address",
Computed: true,
Validators: []validator.String{
Expand Down
20 changes: 10 additions & 10 deletions stackit/internal/resources/network/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
type Network struct {
Name types.String `tfsdk:"name"`
NameServers []types.String `tfsdk:"nameservers"`
NetworkID types.String `tfsdk:"networkId"`
NetworkID types.String `tfsdk:"network_id"`
Prefixes []types.String `tfsdk:"prefixes"`
PrefixLengthV4 types.Int64 `tfsdk:"prefixLengthV4"`
PublicIp types.String `tssdk:"publicIp"`
PrefixLengthV4 types.Int64 `tfsdk:"prefix_length_v4"`
PublicIp types.String `tssdk:"public_ip"`
ProjectID types.String `tfsdk:"project_id"`
}

Expand All @@ -39,31 +39,31 @@ func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp
},
"nameservers": schema.ListAttribute{
Description: "List of DNS Servers/Nameservers.",
Required: false,
Optional: true,
ElementType: types.StringType,
Validators: []validator.List{
validate.NameServers(),
},
},
"networkId": schema.StringAttribute{
"network_id": schema.StringAttribute{
Description: "The ID of the network",
Required: true,
Computed: true,
},
"prefixes": schema.ListAttribute{
Required: true,
Computed: true,
ElementType: types.StringType,
Validators: []validator.List{
validate.Prefixes(),
},
},
"prefixLengthV4": schema.Int64Attribute{
"prefix_length_v4": schema.Int64Attribute{
Description: "prefix length",
Required: true,
Optional: true,
Validators: []validator.Int64{
validate.PrefixLengthV4(),
},
},
"publicIp": schema.StringAttribute{
"public_ip": schema.StringAttribute{
Description: "public IP address",
Computed: true,
Validators: []validator.String{
Expand Down
4 changes: 4 additions & 0 deletions stackit/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
dataLoadBalancer "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/load-balancer"
dataMongoDBFlexInstance "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/mongodb-flex/instance"
dataMongoDBFlexUser "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/mongodb-flex/user"
dataNetwork "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/network"
dataObjectStorageBucket "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/object-storage/bucket"
dataObjectStorageCredential "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/object-storage/credential"
dataObjectStorageCredentialsGroup "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/data-sources/object-storage/credentials-group"
Expand All @@ -32,6 +33,7 @@ import (
resourceLoadBalancer "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/load-balancer"
resourceMongoDBFlexInstance "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/mongodb-flex/instance"
resourceMongoDBFlexUser "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/mongodb-flex/user"
resourceNetwork "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/network"
resourceObjectStorageBucket "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/object-storage/bucket"
resourceObjectStorageCredential "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/object-storage/credential"
resourceObjectStorageCredentialsGroup "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/resources/object-storage/credentials-group"
Expand Down Expand Up @@ -175,6 +177,7 @@ func (p *StackitProvider) Resources(_ context.Context) []func() resource.Resourc
resourceProject.New,
resourceSecretsManagerInstance.New,
resourceSecretsManagerUser.New,
resourceNetwork.New,
}
}

Expand Down Expand Up @@ -211,6 +214,7 @@ func (p *StackitProvider) DataSources(context.Context) []func() datasource.DataS
dataProject.New,
dataSecretsManagerInstance.New,
dataSecretsManagerUser.New,
dataNetwork.New,
}
}

Expand Down

0 comments on commit 91f128c

Please sign in to comment.