Skip to content

Commit

Permalink
Sync monorepo state at "ucconfig gen-manifest: omit version field fro…
Browse files Browse the repository at this point in the history
…m attributes" (#17)

Syncing from
userclouds/userclouds@926d515
  • Loading branch information
uc-build-user committed Oct 11, 2023
1 parent 3688712 commit fd989f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/liveresource/liveresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ func MakeLiveResource(ctx context.Context, resourceType resourcetypes.ResourceTy
isSystem = v.Field(i).Bool()
continue
}
// Omit the version field from the attributes. It functions as an etag
// for versioned resources, and the Terraform provider won't allow it to
// be set
if jsonKey == "version" {
continue
}
if slices.Contains(resourceType.OmitAttributes, jsonKey) {
continue
}
Expand Down
11 changes: 11 additions & 0 deletions internal/liveresource/liveresource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ func TestGetLiveResourcesForType(t *testing.T) {
},
}})
}

func TestVersionAttributeOmitted(t *testing.T) {
res, err := MakeLiveResource(context.Background(), *resourcetypes.GetByTerraformTypeSuffix("userstore_accessor"), userstore.Accessor{
ID: uuid.Must(uuid.FromString("fe20fd48-a006-4ad8-9208-4aad540d8794")),
Version: 7,
Name: "TestAccessor",
})
assert.NoErr(t, err)
assert.Equal(t, res.Attributes["name"], "TestAccessor")
assert.Equal(t, res.Attributes["version"], nil)
}

0 comments on commit fd989f7

Please sign in to comment.