Skip to content

Commit

Permalink
feat: update policy engine schema (#1931)
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks authored Feb 20, 2025
1 parent 3411953 commit 7c32d24
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 3 deletions.
2 changes: 2 additions & 0 deletions assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4846,6 +4846,8 @@ export type PolicyConstraintEdge = {
/** Configuration for applying policy enforcement to a stack */
export type PolicyEngine = {
__typename?: 'PolicyEngine';
/** the maximum allowed severity without failing the stack run */
maxSeverity?: Maybe<VulnSeverity>;
/** the policy engine to use with this stack */
type: PolicyEngineType;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8376,6 +8376,29 @@ spec:
- observabilityProviderRef
type: object
type: array
policyEngine:
description: PolicyEngine is a configuration for applying policy enforcement
to a stack.
properties:
maxSeverity:
description: MaxSeverity is the maximum allowed severity without
failing the stack run
enum:
- UNKNOWN
- LOW
- MEDIUM
- HIGH
- CRITICAL
- NONE
type: string
type:
description: Type is the policy engine to use with this stack
enum:
- TRIVY
type: string
required:
- type
type: object
projectRef:
description: |-
ProjectRef references project this stack belongs to.
Expand Down
32 changes: 31 additions & 1 deletion go/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go/client/graph/stack.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fragment InfrastructureStackStatusFragment on InfrastructureStack {

fragment PolicyEngineFragment on PolicyEngine {
type
maxSeverity
}

fragment InfrastructureStackFragment on InfrastructureStack {
Expand Down Expand Up @@ -125,6 +126,7 @@ fragment StackViolationCauseFragment on StackViolationCause {
start
end
resource
filename
lines { ...StackViolationCauseLineFragment }
}

Expand Down
2 changes: 2 additions & 0 deletions go/client/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions go/controller/api/v1alpha1/infrastructurestack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ type InfrastructureStackSpec struct {
// stack Type (except [console.StackTypeCustom]).
// +kubebuilder:validation:Optional
Variables *runtime.RawExtension `json:"variables,omitempty"`

// PolicyEngine is a configuration for applying policy enforcement to a stack.
// +kubebuilder:validation:Optional
PolicyEngine *PolicyEngine `json:"policyEngine,omitempty"`
}

type StackFile struct {
Expand Down Expand Up @@ -244,3 +248,26 @@ type ObservableMetric struct {
// +kubebuilder:validation:Required
ObservabilityProviderRef corev1.ObjectReference `json:"observabilityProviderRef"`
}

type PolicyEngine struct {
// Type is the policy engine to use with this stack
// +kubebuilder:validation:Enum=TRIVY
// +kubebuilder:validation:Required
Type console.PolicyEngineType `json:"type"`

// MaxSeverity is the maximum allowed severity without failing the stack run
// +kubebuilder:validation:Enum=UNKNOWN;LOW;MEDIUM;HIGH;CRITICAL;NONE
// +kubebuilder:validation:Optional
MaxSeverity *console.VulnSeverity `json:"maxSeverity,omitempty"`
}

func (in *PolicyEngine) Attributes() *console.PolicyEngineAttributes {
if in == nil {
return nil
}

return &console.PolicyEngineAttributes{
Type: in.Type,
MaxSeverity: in.MaxSeverity,
}
}
25 changes: 25 additions & 0 deletions go/controller/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8376,6 +8376,29 @@ spec:
- observabilityProviderRef
type: object
type: array
policyEngine:
description: PolicyEngine is a configuration for applying policy enforcement
to a stack.
properties:
maxSeverity:
description: MaxSeverity is the maximum allowed severity without
failing the stack run
enum:
- UNKNOWN
- LOW
- MEDIUM
- HIGH
- CRITICAL
- NONE
type: string
type:
description: Type is the policy engine to use with this stack
enum:
- TRIVY
type: string
required:
- type
type: object
projectRef:
description: |-
ProjectRef references project this stack belongs to.
Expand Down
Loading

0 comments on commit 7c32d24

Please sign in to comment.