@@ -152,61 +152,66 @@ func (r *githubSupressionRuleResource) ValidateConfig(ctx context.Context, req r
152152
153153 switch rule .Type .ValueString () {
154154 case "source_code_overwritten" :
155- if rule .File .IsNull () || rule .File .IsUnknown () || rule .FilePath .IsNull () || rule .FilePath .IsUnknown ( ) {
155+ if ( ! rule .File .IsUnknown () && rule .File .IsNull ()) || ( ! rule .FilePath .IsUnknown () && rule .FilePath .IsNull () ) {
156156 resp .Diagnostics .AddError (
157157 "File is required" ,
158158 "File is required when type is source_code_overwritten" ,
159159 )
160160 }
161- if ! rule .Process .IsNull () {
161+ if ! rule .Process .IsUnknown () && ! rule . Process . IsNull () {
162162 resp .Diagnostics .AddError (
163163 "Process is not allowed" ,
164164 "Process is not allowed when type is source_code_overwritten" ,
165165 )
166166 }
167- if ! rule .Destination .IsNull () {
167+ if ! rule .Destination .IsUnknown () && ! rule . Destination . IsNull () {
168168 resp .Diagnostics .AddError (
169169 "Destination is not allowed" ,
170170 "Destination is not allowed when type is source_code_overwritten" ,
171171 )
172172 }
173173 case "anomalous_outbound_network_call" :
174- if ! rule .File .IsNull () || ! rule .FilePath .IsNull () {
174+ if ( ! rule .File .IsUnknown () && ! rule . File . IsNull ()) || ( ! rule .FilePath .IsUnknown () && ! rule . FilePath . IsNull () ) {
175175 resp .Diagnostics .AddError (
176176 "File, File Path parameters are not allowed" ,
177177 "File, File Path parameters are not allowed when type is anomalous_outbound_network_call" ,
178178 )
179179 }
180- if rule .Process .IsNull () || rule .Process .IsUnknown () {
180+ if ! rule .Process .IsUnknown () && rule .Process .IsNull () {
181181 resp .Diagnostics .AddError (
182182 "Process is required" ,
183183 "Process is required when type is anomalous_outbound_network_call" ,
184184 )
185185 }
186- if rule .Destination .IsNull () || rule .Destination .IsUnknown () {
186+ if ! rule .Destination .IsUnknown () && rule .Destination .IsNull () {
187187 resp .Diagnostics .AddError (
188188 "Destination is required" ,
189189 "Destination is required when type is anomalous_outbound_network_call" ,
190190 )
191191 }
192- var destination destinationModel
193- diags := rule .Destination .As (ctx , & destination , basetypes.ObjectAsOptions {})
194- resp .Diagnostics .Append (diags ... )
195- if resp .Diagnostics .HasError () {
196- return
197- }
198- isIpEmpty := destination .IP .IsNull () || destination .IP .IsUnknown ()
199- isDomainEmpty := destination .Domain .IsNull () || destination .Domain .IsUnknown ()
200- if isIpEmpty && isDomainEmpty {
201- resp .Diagnostics .AddError (
202- "Destination is required" ,
203- "Destination is required when type is anomalous_outbound_network_call. please provide either ip or domain." ,
204- )
205- } else if ! isIpEmpty && ! isDomainEmpty {
206- resp .Diagnostics .AddError (
207- "Cannot provide both ip and domain in destination" ,
208- "Destination can only have either ip or domain" ,
209- )
192+ if ! rule .Destination .IsUnknown () {
193+ var destination destinationModel
194+ diags := rule .Destination .As (ctx , & destination , basetypes.ObjectAsOptions {})
195+ resp .Diagnostics .Append (diags ... )
196+ if resp .Diagnostics .HasError () {
197+ return
198+ }
199+ // Skip validation if either field is unknown (from variables during plan)
200+ if ! destination .IP .IsUnknown () && ! destination .Domain .IsUnknown () {
201+ isIpEmpty := destination .IP .IsNull ()
202+ isDomainEmpty := destination .Domain .IsNull ()
203+ if isIpEmpty && isDomainEmpty {
204+ resp .Diagnostics .AddError (
205+ "Destination is required" ,
206+ "Destination is required when type is anomalous_outbound_network_call. please provide either ip or domain." ,
207+ )
208+ } else if ! isIpEmpty && ! isDomainEmpty {
209+ resp .Diagnostics .AddError (
210+ "Cannot provide both ip and domain in destination" ,
211+ "Destination can only have either ip or domain" ,
212+ )
213+ }
214+ }
210215 }
211216 }
212217}
0 commit comments