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

fix: rename alias and title to name #42

Merged
merged 9 commits into from
Oct 21, 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
6 changes: 3 additions & 3 deletions pkg/config-api-provider/examples/full-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ removed {
}
*/
resource "uxi_wireless_network" "my_wireless_network" {
alias = "alias"
name = "name"
}

import {
Expand All @@ -102,7 +102,7 @@ removed {
}
*/
resource "uxi_wired_network" "my_wired_network" {
alias = "alias"
name = "name"
}

import {
Expand All @@ -121,7 +121,7 @@ removed {
}
*/
resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type wiredNetworkDataSource struct {

type wiredNetworkDataSourceModel struct {
ID types.String `tfsdk:"id"`
Alias types.String `tfsdk:"alias"`
Name types.String `tfsdk:"name"`
IpVersion types.String `tfsdk:"ip_version"`
Security types.String `tfsdk:"security"`
DnsLookupDomain types.String `tfsdk:"dns_lookup_domain"`
Expand All @@ -50,7 +50,7 @@ func (d *wiredNetworkDataSource) Schema(_ context.Context, _ datasource.SchemaRe
"id": schema.StringAttribute{
Computed: true,
},
"alias": schema.StringAttribute{
"name": schema.StringAttribute{
Computed: true,
},
"ip_version": schema.StringAttribute{
Expand Down Expand Up @@ -116,7 +116,7 @@ func (d *wiredNetworkDataSource) Read(ctx context.Context, req datasource.ReadRe

network := networkResponse.Items[0]
state.ID = types.StringValue(network.Id)
state.Alias = types.StringValue(network.Name)
state.Name = types.StringValue(network.Name)
state.IpVersion = types.StringValue(network.IpVersion)
state.Security = types.StringValue(*network.Security.Get())
state.DnsLookupDomain = types.StringValue(*network.DnsLookupDomain.Get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type wirelessNetworkDataSource struct {
type wirelessNetworkDataSourceModel struct {
ID types.String `tfsdk:"id"`
Ssid types.String `tfsdk:"ssid"`
Alias types.String `tfsdk:"alias"`
Name types.String `tfsdk:"name"`
IpVersion types.String `tfsdk:"ip_version"`
Security types.String `tfsdk:"security"`
Hidden types.Bool `tfsdk:"hidden"`
Expand Down Expand Up @@ -55,7 +55,7 @@ func (d *wirelessNetworkDataSource) Schema(_ context.Context, _ datasource.Schem
"ssid": schema.StringAttribute{
Computed: true,
},
"alias": schema.StringAttribute{
"name": schema.StringAttribute{
Computed: true,
},
"ip_version": schema.StringAttribute{
Expand Down Expand Up @@ -125,7 +125,7 @@ func (d *wirelessNetworkDataSource) Read(ctx context.Context, req datasource.Rea
network := networkResponse.Items[0]
state.ID = types.StringValue(network.Id)
state.Ssid = types.StringValue(network.Ssid)
state.Alias = types.StringValue(network.Name)
state.Name = types.StringValue(network.Name)
state.IpVersion = types.StringValue(network.IpVersion)
state.Security = types.StringValue(*network.Security.Get())
state.Hidden = types.BoolValue(network.Hidden)
Expand Down
12 changes: 6 additions & 6 deletions pkg/config-api-provider/provider/resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
)

type serviceTestResourceModel struct {
ID types.String `tfsdk:"id"`
Title types.String `tfsdk:"title"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
}

// TODO: Switch this to use the Client Model when that becomes available
type ServiceTestResponseModel struct {
Uid string // <service_test_uid:str>,
Category string // <category:str>,
Title string // <title:str>,
Name string // <name:str>,
Target string // Nullable<<target:str>>,
Template string // <template:str>,
IsEnabled bool // <is_enabled:bool>
Expand All @@ -52,7 +52,7 @@
stringplanmodifier.UseStateForUnknown(),
},
},
"title": schema.StringAttribute{
"name": schema.StringAttribute{
Required: true,
},
},
Expand Down Expand Up @@ -82,7 +82,7 @@
response := GetServiceTest(state.ID.ValueString())

// Update state from client response
state.Title = types.StringValue(response.Title)
state.Name = types.StringValue(response.Name)

// Set refreshed state
diags = resp.State.Set(ctx, &state)
Expand Down Expand Up @@ -119,7 +119,7 @@
return ServiceTestResponseModel{
Uid: uid,
Category: "category",
Title: "title",
Name: "name",

Check warning on line 122 in pkg/config-api-provider/provider/resources/service.go

View check run for this annotation

Codecov / codecov/patch

pkg/config-api-provider/provider/resources/service.go#L122

Added line #L122 was not covered by tests
Target: "target",
Template: "template",
IsEnabled: true,
Expand Down
8 changes: 4 additions & 4 deletions pkg/config-api-provider/provider/resources/wired_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var (
)

type wiredNetworkResourceModel struct {
ID types.String `tfsdk:"id"`
Alias types.String `tfsdk:"alias"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
}

func NewWiredNetworkResource() resource.Resource {
Expand All @@ -45,7 +45,7 @@ func (r *wiredNetworkResource) Schema(_ context.Context, _ resource.SchemaReques
stringplanmodifier.UseStateForUnknown(),
},
},
"alias": schema.StringAttribute{
"name": schema.StringAttribute{
Required: true,
},
},
Expand Down Expand Up @@ -110,7 +110,7 @@ func (r *wiredNetworkResource) Read(ctx context.Context, req resource.ReadReques
network := networkResponse.Items[0]

// Update state from client response
state.Alias = types.StringValue(network.Name)
state.Name = types.StringValue(network.Name)

// Set refreshed state
diags = resp.State.Set(ctx, &state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var (
)

type wirelessNetworkResourceModel struct {
ID types.String `tfsdk:"id"`
Alias types.String `tfsdk:"alias"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
}

func NewWirelessNetworkResource() resource.Resource {
Expand All @@ -45,7 +45,7 @@ func (r *wirelessNetworkResource) Schema(_ context.Context, _ resource.SchemaReq
stringplanmodifier.UseStateForUnknown(),
},
},
"alias": schema.StringAttribute{
"name": schema.StringAttribute{
Required: true,
},
},
Expand Down Expand Up @@ -110,7 +110,7 @@ func (r *wirelessNetworkResource) Read(ctx context.Context, req resource.ReadReq
network := networkResponse.Items[0]

// Update state from client response
state.Alias = types.StringValue(network.Name)
state.Name = types.StringValue(network.Name)

// Set refreshed state
diags = resp.State.Set(ctx, &state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestWiredNetworkDataSource(t *testing.T) {
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "id", "uid"),
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "alias", "alias"),
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "name", "name"),
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "ip_version", "ip_version"),
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "security", "security"),
resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "dns_lookup_domain", "dns_lookup_domain"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestWirelessNetworkDataSource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "id", "uid"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "ssid", "ssid"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "alias", "alias"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "name", "name"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "ip_version", "ip_version"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "security", "security"),
resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "hidden", "false"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand All @@ -155,7 +155,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) {
}

resource "uxi_wired_network" "my_network_2" {
alias = "alias_2"
name = "name_2"
}

import {
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) {
}

resource "uxi_wireless_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) {
}

resource "uxi_wireless_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand All @@ -377,7 +377,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) {
}

resource "uxi_wireless_network" "my_network_2" {
alias = "alias_2"
name = "name_2"
}

import {
Expand Down Expand Up @@ -504,7 +504,7 @@ func TestNetworkGroupAssignmentResource429Handling(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -611,7 +611,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -655,7 +655,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -709,7 +709,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down Expand Up @@ -766,7 +766,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) {
}

resource "uxi_wired_network" "my_network" {
alias = "alias"
name = "name"
}

import {
Expand Down
8 changes: 4 additions & 4 deletions pkg/config-api-provider/test/resources/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestServiceTestResource(t *testing.T) {
{
Config: provider.ProviderConfig + `
resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}`,

ExpectError: regexp.MustCompile(`(?s)creating a service_test is not supported; service_tests can only be\s*imported`),
Expand All @@ -41,7 +41,7 @@ func TestServiceTestResource(t *testing.T) {
},
Config: provider.ProviderConfig + `
resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand All @@ -50,7 +50,7 @@ func TestServiceTestResource(t *testing.T) {
}`,

Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "title", "title"),
resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "name", "name"),
resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "id", "uid"),
),
},
Expand All @@ -64,7 +64,7 @@ func TestServiceTestResource(t *testing.T) {
{
Config: provider.ProviderConfig + `
resource "uxi_service_test" "my_service_test" {
title = "updated_title"
name = "updated_name"
}`,
ExpectError: regexp.MustCompile(`(?s)updating a service_test is not supported; service_tests can only be updated\s*through the dashboard`),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) {
}

resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) {
}

resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand All @@ -141,7 +141,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) {
}

resource "uxi_service_test" "my_service_test_2" {
title = "title_2"
name = "name_2"
}

import {
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestServiceTestGroupAssignmentResource429Handling(t *testing.T) {
}

resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand Down Expand Up @@ -331,7 +331,7 @@ func TestServiceTestGroupAssignmentResourceHttpErrorHandling(t *testing.T) {
}

resource "uxi_service_test" "my_service_test" {
title = "title"
name = "name"
}

import {
Expand Down
Loading
Loading