Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update policy engine schema #1931

Merged
merged 5 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading