Skip to content

Commit

Permalink
Merge pull request #494 from MusicDin/cp/fix-network-zones
Browse files Browse the repository at this point in the history
Fix network zone minor issue - from Incus
  • Loading branch information
simondeziel authored Jul 10, 2024
2 parents b06bbd6 + 80694d4 commit 32291df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/resources/network_zone.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "lxd_network_zone" "zone" {
resource "lxd_network_zone_record" "record" {
name = "ns"
zone = lxd_network_zone.zone.id
zone = lxd_network_zone.zone.name
entry {
type = "CNAME"
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/network_zone_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "lxd_network_zone" "zone" {
resource "lxd_network_zone_record" "record" {
name = "ns"
zone = lxd_network_zone.zone.id
zone = lxd_network_zone.zone.name
entry {
type = "CNAME"
Expand Down
11 changes: 6 additions & 5 deletions internal/network/resource_network_zone_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type NetworkZoneRecordModel struct {
Name types.String `tfsdk:"name"`
Zone types.String `tfsdk:"zone"`
Description types.String `tfsdk:"description"`
Enteries types.Set `tfsdk:"entry"`
Entries types.Set `tfsdk:"entry"`
Project types.String `tfsdk:"project"`
Remote types.String `tfsdk:"remote"`
Config types.Map `tfsdk:"config"`
Expand Down Expand Up @@ -118,7 +118,8 @@ func (r NetworkZoneRecordResource) Schema(_ context.Context, _ resource.SchemaRe
},

"ttl": schema.Int64Attribute{
Required: true,
Optional: true,
Computed: true,
Description: "Record entry TTL",
Validators: []validator.Int64{
int64validator.AtLeast(1),
Expand Down Expand Up @@ -168,7 +169,7 @@ func (r NetworkZoneRecordResource) Create(ctx context.Context, req resource.Crea
config, diags := common.ToConfigMap(ctx, plan.Config)
resp.Diagnostics.Append(diags...)

entries, diags := ToZoneRecordEntryList(ctx, plan.Enteries)
entries, diags := ToZoneRecordEntryList(ctx, plan.Entries)
resp.Diagnostics.Append(diags...)

if resp.Diagnostics.HasError() {
Expand Down Expand Up @@ -251,7 +252,7 @@ func (r NetworkZoneRecordResource) Update(ctx context.Context, req resource.Upda
config, diags := common.ToConfigMap(ctx, plan.Config)
resp.Diagnostics.Append(diags...)

entries, diags := ToZoneRecordEntryList(ctx, plan.Enteries)
entries, diags := ToZoneRecordEntryList(ctx, plan.Entries)
resp.Diagnostics.Append(diags...)

if resp.Diagnostics.HasError() {
Expand Down Expand Up @@ -347,7 +348,7 @@ func (r NetworkZoneRecordResource) SyncState(ctx context.Context, tfState *tfsdk
m.Zone = types.StringValue(zoneName)
m.Name = types.StringValue(record.Name)
m.Description = types.StringValue(record.Description)
m.Enteries = entries
m.Entries = entries
m.Config = config

if respDiags.HasError() {
Expand Down
3 changes: 1 addition & 2 deletions internal/network/resource_network_zone_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAccNetworkZoneRecord_entries(t *testing.T) {
entry1 := map[string]string{
"type": "CNAME",
"value": "one",
"ttl": "3600",
"ttl": "",
}

entry2 := map[string]string{
Expand Down Expand Up @@ -132,7 +132,6 @@ resource "lxd_network_zone_record" "record" {
entry {
type = "CNAME"
value = "one"
ttl = 3600
}
}
`, zoneName, recordName)
Expand Down

0 comments on commit 32291df

Please sign in to comment.