Skip to content

Fix constraint template #591

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

Merged
merged 3 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix tests
  • Loading branch information
mrueg committed Feb 25, 2025
commit 97bc7c6e771e14c10182c4477581ba5a22ca233a
1 change: 0 additions & 1 deletion .github/workflows/cron_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ jobs:
run: |
chmod +x ./konstraint
./konstraint create -o e2e-resources examples
./konstraint create -o e2e-resources test

- name: create kind cluster
run: kind create cluster
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ jobs:
run: |
chmod +x ./konstraint
./konstraint create -o e2e-resources examples
./konstraint create -o e2e-resources test

- name: create kind cluster
run: kind create cluster
Expand Down
10 changes: 5 additions & 5 deletions internal/commands/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestRenderConstraint(t *testing.T) {
t.Errorf("Error getting violations: %v", err)
}

expected, err := os.ReadFile("../../test/constraint_Test.yaml")
expected, err := os.ReadFile("../../test/output/standard/constraint_FullMetadata.yaml")
if err != nil {
t.Errorf("Error reading expected file: %v", err)
}
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestRenderConstraintWithCustomTemplate(t *testing.T) {
t.Errorf("Error getting violations: %v", err)
}

expected, err := os.ReadFile("../../test/custom/constraint_Test.yaml")
expected, err := os.ReadFile("../../test/output/custom/constraint_FullMetadata.yaml")
if err != nil {
t.Errorf("Error reading expected file: %v", err)
}
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestRenderConstraintTemplate(t *testing.T) {
t.Errorf("Error getting violations: %v", err)
}

expected, err := os.ReadFile("../../test/template_Test.yaml")
expected, err := os.ReadFile("../../test/output/standard/template_FullMetadata.yaml")
if err != nil {
t.Errorf("Error reading expected file: %v", err)
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestRenderConstraintTemplateWithCustomTemplate(t *testing.T) {
t.Errorf("Error getting violations: %v", err)
}

expected, err := os.ReadFile("../../test/custom/template_Test.yaml")
expected, err := os.ReadFile("../../test/output/custom/template_FullMetadata.yaml")
if err != nil {
t.Errorf("Error reading expected file: %v", err)
}
Expand All @@ -129,7 +129,7 @@ func TestRenderConstraintTemplateWithCustomTemplate(t *testing.T) {
}

func GetViolations() ([]rego.Rego, error) {
violations, err := rego.GetViolations("../../test")
violations, err := rego.GetViolations("../../test/policies/")
if err != nil {
return nil, err
}
Expand Down
34 changes: 0 additions & 34 deletions test/output/custom/constraint_Policies.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions test/output/custom/constraint_Test.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion test/output/custom/template_FullMetadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- |-
package lib.libraryB
rego: |-
package test
package test_fullmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
2 changes: 1 addition & 1 deletion test/output/custom/template_PartialMetadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
- |-
package lib.libraryB
rego: |-
package test_partial_metadata
package test_partialmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
38 changes: 0 additions & 38 deletions test/output/custom/template_Policies.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions test/output/custom/template_Test.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: Test
kind: FullMetadata
metadata:
name: test
name: fullmetadata
spec:
match:
excludedNamespaces:
Expand Down
5 changes: 3 additions & 2 deletions test/output/standard/template_FullMetadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: templates.gatekeeper.sh/v1beta1
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
creationTimestamp: null
Expand All @@ -16,6 +16,7 @@ spec:
super duper cool parameter with a description
on two lines.
type: string
type: object
targets:
- libs:
- |-
Expand All @@ -24,7 +25,7 @@ spec:
import data.lib.libraryB
- package lib.libraryB
rego: |-
package test
package test_fullmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
2 changes: 1 addition & 1 deletion test/output/standard/template_NoMetadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: templates.gatekeeper.sh/v1beta1
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
creationTimestamp: null
Expand Down
4 changes: 2 additions & 2 deletions test/output/standard/template_PartialMetadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: templates.gatekeeper.sh/v1beta1
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
creationTimestamp: null
Expand All @@ -16,7 +16,7 @@ spec:
import data.lib.libraryB
- package lib.libraryB
rego: |-
package test_partial_metadata
package test_partialmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
38 changes: 0 additions & 38 deletions test/output/standard/template_Policies.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions test/output/standard/template_Test.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion test/policies/full-metadata/src.rego
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# - dev
# - stage
# - prod
package test
package test_fullmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
2 changes: 1 addition & 1 deletion test/policies/partial-metadata/src.rego
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - dev
# - stage
# - prod
package test_partial_metadata
package test_partialmetadata

import future.keywords.if
import data.lib.libraryA
Expand Down
Loading