-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix perpetual diff in claim_ref (#1227)
The claim_ref attribute would perpetually show a diff if the PV was created without a claim_ref specified. This is because all PVs gain a claimRef once a PVC binds to it. (This creates the bi-directional link between PV and PVC, and it's done on the Kubernetes API side). To support this, `claim_ref` is now a Computed attribute, and it will update to show the claimRef once a PVC has bound to the PV, (only now it will do so without creating a diff in terraform). Also added extra tests to catch this case and moved claim_ref's flatteners/expanders/tests into the correct files.
- Loading branch information
Showing
7 changed files
with
183 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestFlattenObjectRef(t *testing.T) { | ||
cases := []struct { | ||
Input *v1.ObjectReference | ||
ExpectedOutput []interface{} | ||
}{ | ||
{ | ||
&v1.ObjectReference{ | ||
Name: "demo", | ||
Namespace: "default", | ||
}, | ||
[]interface{}{ | ||
map[string]interface{}{ | ||
"name": "demo", | ||
"namespace": "default", | ||
}, | ||
}, | ||
}, | ||
{ | ||
&v1.ObjectReference{}, | ||
[]interface{}{map[string]interface{}{}}, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
output := flattenObjectRef(tc.Input) | ||
if !reflect.DeepEqual(output, tc.ExpectedOutput) { | ||
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v", | ||
tc.ExpectedOutput, output) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters