-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dummy provider and e2e for external data validation (#1606)
- Loading branch information
Showing
20 changed files
with
418 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM golang:1.17 | ||
|
||
RUN GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected] | ||
RUN GO111MODULE=on go install sigs.k8s.io/controller-tools/cmd/[email protected] | ||
|
||
RUN mkdir /gatekeeper | ||
WORKDIR /gatekeeper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ARG BUILDPLATFORM="linux/amd64" | ||
ARG BUILDERIMAGE="golang:1.17" | ||
ARG BASEIMAGE="gcr.io/distroless/static:nonroot" | ||
|
||
FROM --platform=$BUILDPLATFORM $BUILDERIMAGE as builder | ||
|
||
ARG TARGETPLATFORM | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG TARGETVARIANT="" | ||
ARG LDFLAGS | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=${TARGETOS} \ | ||
GOARCH=${TARGETARCH} \ | ||
GOARM=${TARGETVARIANT} | ||
|
||
WORKDIR /go/src/github.com/open-policy-agent/gatekeeper/test/externaldata/dummy-provider | ||
|
||
COPY . . | ||
|
||
RUN go mod init && go mod tidy | ||
|
||
RUN go build -o provider provider.go | ||
|
||
FROM $BASEIMAGE | ||
|
||
WORKDIR / | ||
|
||
COPY --from=builder /go/src/github.com/open-policy-agent/gatekeeper/test/externaldata/dummy-provider . | ||
|
||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/provider"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: dummy-provider | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: dummy-provider | ||
namespace: dummy-provider | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
run: dummy-provider | ||
template: | ||
metadata: | ||
labels: | ||
run: dummy-provider | ||
spec: | ||
containers: | ||
- image: dummy-provider:test | ||
imagePullPolicy: Never | ||
name: dummy-provider | ||
ports: | ||
- containerPort: 8090 | ||
protocol: TCP | ||
restartPolicy: Always | ||
nodeSelector: | ||
kubernetes.io/os: linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: externaldata.gatekeeper.sh/v1alpha1 | ||
kind: Provider | ||
metadata: | ||
name: dummy-provider | ||
spec: | ||
url: http://dummy-provider.dummy-provider:8090/validate | ||
timeout: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: dummy-provider | ||
namespace: dummy-provider | ||
spec: | ||
ports: | ||
- port: 8090 | ||
protocol: TCP | ||
targetPort: 8090 | ||
selector: | ||
run: dummy-provider | ||
sessionAffinity: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sExternalData | ||
metadata: | ||
name: dummy | ||
spec: | ||
enforcementAction: deny | ||
match: | ||
kinds: | ||
- apiGroups: ["apps"] | ||
kinds: ["Deployment"] |
19 changes: 19 additions & 0 deletions
19
test/externaldata/dummy-provider/policy/examples/error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: error-deployment | ||
labels: | ||
app: error-deployment | ||
spec: | ||
replicas: 0 # testing purposes only | ||
selector: | ||
matchLabels: | ||
app: error-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: error-deployment | ||
spec: | ||
containers: | ||
- name: error | ||
image: error_test/image:latest |
19 changes: 19 additions & 0 deletions
19
test/externaldata/dummy-provider/policy/examples/system-error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: system-error-deployment | ||
labels: | ||
app: system-error-deployment | ||
spec: | ||
replicas: 0 # testing purposes only | ||
selector: | ||
matchLabels: | ||
app: system-error-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: system-error-deployment | ||
spec: | ||
containers: | ||
- name: system-error | ||
image: test/image:latest_systemError |
19 changes: 19 additions & 0 deletions
19
test/externaldata/dummy-provider/policy/examples/valid.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: valid-deployment | ||
labels: | ||
app: valid-deployment | ||
spec: | ||
replicas: 0 # testing purposes only | ||
selector: | ||
matchLabels: | ||
app: valid-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: valid-deployment | ||
spec: | ||
containers: | ||
- name: valid | ||
image: test/image:v1 |
Oops, something went wrong.