diff --git a/pkg/config/resource.go b/pkg/config/resource.go index 160ca70f..58bec39b 100644 --- a/pkg/config/resource.go +++ b/pkg/config/resource.go @@ -495,6 +495,7 @@ type Resource struct { requiredFields []string } +// RequiredFields returns slice of the marked as required fieldpaths. func (r *Resource) RequiredFields() []string { return r.requiredFields } diff --git a/pkg/types/builder.go b/pkg/types/builder.go index dfbe1cc3..1afb68d8 100644 --- a/pkg/types/builder.go +++ b/pkg/types/builder.go @@ -380,10 +380,7 @@ func newTopLevelRequiredParam(path string, includeInit bool) *topLevelRequiredPa } func (r *resource) addParameterField(f *Field, field *types.Var) { - requiredBySchema := !f.Schema.Optional - if f.Required { - requiredBySchema = f.Required - } + requiredBySchema := !f.Schema.Optional || f.Required // Note(turkenh): We are collecting the top level required parameters that // are not identifier fields. This is for generating CEL validation rules for // those parameters and not to require them if the management policy is set