@@ -52,6 +52,34 @@ func ContainsAnyWriteOnlyChildAttributes(nestedAttr NestedAttribute) bool {
52
52
return false
53
53
}
54
54
55
+ // BlockContainsAnyWriteOnlyChildAttributes will return true if any child attribute for the
56
+ // given nested block has WriteOnly set to true.
57
+ func BlockContainsAnyWriteOnlyChildAttributes (block Block ) bool {
58
+ nestedObjAttrs := block .GetNestedObject ().GetAttributes ()
59
+ nestedObjBlocks := block .GetNestedObject ().GetBlocks ()
60
+
61
+ for _ , childAttr := range nestedObjAttrs {
62
+ if childAttr .IsWriteOnly () {
63
+ return true
64
+ }
65
+
66
+ nestedAttribute , ok := childAttr .(NestedAttribute )
67
+ if ok {
68
+ if ContainsAnyWriteOnlyChildAttributes (nestedAttribute ) {
69
+ return true
70
+ }
71
+ }
72
+ }
73
+
74
+ for _ , childBlock := range nestedObjBlocks {
75
+ if BlockContainsAnyWriteOnlyChildAttributes (childBlock ) {
76
+ return true
77
+ }
78
+ }
79
+
80
+ return false
81
+ }
82
+
55
83
func InvalidWriteOnlyNestedAttributeDiag (attributePath path.Path ) diag.Diagnostic {
56
84
return diag .NewErrorDiagnostic (
57
85
"Invalid Schema Implementation" ,
@@ -62,6 +90,26 @@ func InvalidWriteOnlyNestedAttributeDiag(attributePath path.Path) diag.Diagnosti
62
90
)
63
91
}
64
92
93
+ func InvalidSetNestedAttributeWithWriteOnlyDiag (attributePath path.Path ) diag.Diagnostic {
94
+ return diag .NewErrorDiagnostic (
95
+ "Invalid Schema Implementation" ,
96
+ "When validating the schema, an implementation issue was found. " +
97
+ "This is always an issue with the provider and should be reported to the provider developers.\n \n " +
98
+ fmt .Sprintf ("%q is a set nested attribute that contains a WriteOnly child attribute.\n \n " , attributePath )+
99
+ "Every child attribute of a set nested attribute must have WriteOnly set to false." ,
100
+ )
101
+ }
102
+
103
+ func SetBlockCollectionWithWriteOnlyDiag (attributePath path.Path ) diag.Diagnostic {
104
+ return diag .NewErrorDiagnostic (
105
+ "Invalid Schema Implementation" ,
106
+ "When validating the schema, an implementation issue was found. " +
107
+ "This is always an issue with the provider and should be reported to the provider developers.\n \n " +
108
+ fmt .Sprintf ("%q is a set nested block that contains a WriteOnly child attribute.\n \n " , attributePath )+
109
+ "Every child attribute within a set nested block must have WriteOnly set to false." ,
110
+ )
111
+ }
112
+
65
113
func InvalidComputedNestedAttributeWithWriteOnlyDiag (attributePath path.Path ) diag.Diagnostic {
66
114
return diag .NewErrorDiagnostic (
67
115
"Invalid Schema Implementation" ,
0 commit comments