|
36 | 36 | validPredicateTypes = sets.NewString("custom", "slsaprovenance", "spdx", "spdxjson", "cyclonedx", "link", "vuln") |
37 | 37 |
|
38 | 38 | // If a static matches, define the behaviour for it. |
39 | | - // TODO(vaikas): Consider adding a warn which would pass but use |
40 | | - // `warn` as return type for the webhook response. |
41 | 39 | validStaticRefTypes = sets.NewString("fail", "pass") |
42 | 40 |
|
43 | 41 | // Valid modes for a policy |
@@ -177,6 +175,10 @@ func (keyless *KeylessRef) Validate(ctx context.Context) *apis.FieldError { |
177 | 175 | if keyless.CACert != nil { |
178 | 176 | errs = errs.Also(keyless.DeepCopy().CACert.Validate(ctx).ViaField("ca-cert")) |
179 | 177 | } |
| 178 | + // Warn if there are no identities specified |
| 179 | + if len(keyless.Identities) == 0 { |
| 180 | + errs = errs.Also(apis.ErrMissingField("identities").At(apis.WarningLevel)) |
| 181 | + } |
180 | 182 | for i, identity := range keyless.Identities { |
181 | 183 | errs = errs.Also(identity.Validate(ctx).ViaFieldIndex("identities", i)) |
182 | 184 | } |
@@ -230,9 +232,6 @@ func (p *Policy) Validate(ctx context.Context) *apis.FieldError { |
230 | 232 |
|
231 | 233 | func (identity *Identity) Validate(ctx context.Context) *apis.FieldError { |
232 | 234 | var errs *apis.FieldError |
233 | | - if identity.Issuer == "" && identity.Subject == "" && identity.IssuerRegExp == "" && identity.SubjectRegExp == "" { |
234 | | - return apis.ErrMissingField("issuer", "subject", "issuerRegExp", "subjectRegExp") |
235 | | - } |
236 | 235 | if identity.Issuer != "" && identity.IssuerRegExp != "" { |
237 | 236 | errs = errs.Also(apis.ErrMultipleOneOf("issuer", "issuerRegExp")) |
238 | 237 | } |
|
0 commit comments