Skip to content

Commit

Permalink
Do not remove server side fields for datasources
Browse files Browse the repository at this point in the history
It does not make sense to delete server side fields for datasources, the user
should be responsible for not creating loops which would cause a perpetual
diff.

This allows reading the status field for the generic `kubernetes_resource`
datasource. Thus this PR Fixes
#1699

Signed-off-by: Julien DOCHE <[email protected]>
  • Loading branch information
St0rmingBr4in committed Aug 9, 2022
1 parent c370d92 commit 31caf7a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions manifest/provider/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ func (s *RawProviderServer) ReadDataSource(ctx context.Context, req *tfprotov5.R
return resp, nil
}

fo := RemoveServerSideFields(res.Object)
nobj, err := payload.ToTFValue(fo, objectType, th, tftypes.NewAttributePath())
nobj, err := payload.ToTFValue(res.Object, objectType, th, tftypes.NewAttributePath())
if err != nil {
resp.Diagnostics = append(resp.Diagnostics, &tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityError,
Expand Down
2 changes: 2 additions & 0 deletions manifest/test/acceptance/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
tfstate.AssertAttributeValues(t, tfstatehelper.AttributeValues{
"data.kubernetes_resource.test_config.object.data.TEST": "hello world",
})
// check that the data source has the status field defined
tfstate.AssertAttributeNotEmpty(t, "data.kubernetes_resource.test_config.object.status")
// check the resource was created with the correct value
tfstate.AssertAttributeValues(t, tfstatehelper.AttributeValues{
"kubernetes_manifest.test_config2.object.data.TEST": "hello world",
Expand Down

0 comments on commit 31caf7a

Please sign in to comment.