Skip to content
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: 1 addition & 1 deletion .github/workflows/e2e-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
- name: make
run: make
- name: Validate JSON
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
- name: make
run: make
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
- name: make
run: make
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
- name: make
run: make
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
# Check if the newest tag already exists
- name: Check if tag exist
uses: mukunku/tag-exists-action@5c39604fe8aef7e65acb6fbcf96ec580f7680313 # v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
go-version: '1.25'
- name: make
run: make run-unit-tests
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24-alpine
FROM golang:1.25-alpine

WORKDIR /draft

Expand Down
255 changes: 139 additions & 116 deletions go.mod

Large diffs are not rendered by default.

753 changes: 369 additions & 384 deletions go.sum

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion pkg/safeguards/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"helm.sh/helm/v3/pkg/chartutil"

apiconstraints "github.com/open-policy-agent/frameworks/constraint/pkg/apis/constraints"
constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client"
"github.com/open-policy-agent/frameworks/constraint/pkg/client/drivers/rego"
"github.com/open-policy-agent/frameworks/constraint/pkg/core/templates"
Expand Down Expand Up @@ -112,7 +113,11 @@ func getConstraintClient() (*constraintclient.Client, error) {
return nil, fmt.Errorf("could not create rego driver: %w", err)
}

c, err := constraintclient.NewClient(constraintclient.Targets(&target.K8sValidationTarget{}), constraintclient.Driver(driver))
c, err := constraintclient.NewClient(
constraintclient.Targets(&target.K8sValidationTarget{}),
constraintclient.Driver(driver),
constraintclient.EnforcementPoints(apiconstraints.WebhookEnforcementPoint),
)
if err != nil {
return nil, fmt.Errorf("could not create constraint client: %w", err)
}
Expand Down Expand Up @@ -140,6 +145,10 @@ func AddSafeguardCRIP() {

// loads constraint templates, constraints into constraint client
func loadConstraintTemplates(ctx context.Context, c *constraintclient.Client, constraintTemplates []*templates.ConstraintTemplate) error {
if c == nil {
return fmt.Errorf("constraint client is nil")
}

// AddTemplate adds the template source code to OPA and registers the CRD with the client for
// schema validation on calls to AddConstraint. On error, the responses return value
// will still be populated so that partial results can be analyzed.
Expand All @@ -154,6 +163,10 @@ func loadConstraintTemplates(ctx context.Context, c *constraintclient.Client, co
}

func loadConstraints(ctx context.Context, c *constraintclient.Client, constraints []*unstructured.Unstructured) error {
if c == nil {
return fmt.Errorf("constraint client is nil")
}

// AddConstraint validates the constraint and, if valid, inserts it into OPA.
// On error, the responses return value will still be populated so that
// partial results can be analyzed.
Expand All @@ -168,6 +181,10 @@ func loadConstraints(ctx context.Context, c *constraintclient.Client, constraint
}

func loadManifestObjects(ctx context.Context, c *constraintclient.Client, objects []*unstructured.Unstructured) error {
if c == nil {
return fmt.Errorf("constraint client is nil")
}

// AddData inserts the provided data into OPA for every target that can handle the data.
// On error, the responses return value will still be populated so that
// partial results can be analyzed.
Expand Down Expand Up @@ -198,6 +215,10 @@ func IsYAML(path string) bool {

// getObjectViolations executes validation on manifests based on loaded constraint templates and returns a map of manifest name to list of objectViolations
func getObjectViolations(ctx context.Context, c *constraintclient.Client, objects []*unstructured.Unstructured) (map[string][]string, error) {
if c == nil {
return nil, fmt.Errorf("constraint client is nil")
}

// Review makes sure the provided object satisfies all stored constraints.
// On error, the responses return value will still be populated so that
// partial results can be analyzed.
Expand Down
Loading