Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #204 from thomasmckay/fix-scorecard
Browse files Browse the repository at this point in the history
fix failing scorecard tests
  • Loading branch information
thomasmckay authored Sep 23, 2021
2 parents 1d7c4f1 + 077ec29 commit 3bef731
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metada
sed -i 's/mediatype: \"\"/mediatype: \"image\/svg+xml\"/g' bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml
$(OPERATOR_SDK) bundle validate ./bundle

# Requires running cluster (for example through 'make test-cluster')
.PHONY: scorecard
scorecard: bundle
$(OPERATOR_SDK) scorecard ./bundle

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
$(DOCKER) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
Expand Down
29 changes: 26 additions & 3 deletions api/v1alpha1/gatekeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,39 @@ type GatekeeperSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Image Configuration"
// +optional
Image *ImageConfig `json:"image,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Audit Configuration"
// +optional
Audit *AuditConfig `json:"audit,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Validating Webhook"
// +optional
ValidatingWebhook *WebhookMode `json:"validatingWebhook,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Mutating Webhook"
// +optional
MutatingWebhook *WebhookMode `json:"mutatingWebhook,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Webhook Config"
// +optional
Webhook *WebhookConfig `json:"webhook,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Node Selector"
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Affinity"
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Tolerations"
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Pod Annotations"
// +optional
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
}
Expand Down Expand Up @@ -144,9 +161,14 @@ type GatekeeperStatus struct {
// Important: Run "make" to regenerate code after modifying this file

// ObservedGeneration is the generation as observed by the operator consuming this API.
ObservedGeneration int64 `json:"observedGeneration"`
AuditConditions []StatusCondition `json:"auditConditions"`
WebhookConditions []StatusCondition `json:"webhookConditions"`
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Observed Generation"
ObservedGeneration int64 `json:"observedGeneration"`

// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Audit Conditions"
AuditConditions []StatusCondition `json:"auditConditions"`

// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Webhook Conditions"
WebhookConditions []StatusCondition `json:"webhookConditions"`
}

// StatusCondition describes the current state of a component.
Expand Down Expand Up @@ -183,6 +205,7 @@ const (
//// +kubebuilder:printcolumn:name="Audit Status",type=string,JSONPath=`.status.auditConditions[0].type`,description="The status of the Gatekeeper Audit"
//// +kubebuilder:printcolumn:name="Webhook Status",type=string,JSONPath=`.status.webhookConditions[0].type`,description="The status of the Gatekeeper Webhook"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +operator-sdk:csv:customresourcedefinitions:displayName="Gatekeeper",resources={{Deployment,v1,gatekeeper-deployment}}

// Gatekeeper is the Schema for the gatekeepers API
type Gatekeeper struct {
Expand Down
36 changes: 35 additions & 1 deletion bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ metadata:
"metadata": {
"name": "gatekeeper"
},
"spec": null
"spec": {
"validatingWebhook": "Enabled"
}
}
]
capabilities: Basic Install
Expand All @@ -26,6 +28,38 @@ spec:
displayName: Gatekeeper
kind: Gatekeeper
name: gatekeepers.operator.gatekeeper.sh
resources:
- kind: Deployment
name: gatekeeper-deployment
version: v1
specDescriptors:
- displayName: Affinity
path: affinity
- displayName: Audit Configuration
path: audit
- displayName: Image Configuration
path: image
- displayName: Mutating Webhook
path: mutatingWebhook
- displayName: Node Selector
path: nodeSelector
- displayName: Pod Annotations
path: podAnnotations
- displayName: Tolerations
path: tolerations
- displayName: Validating Webhook
path: validatingWebhook
- displayName: Webhook Config
path: webhook
statusDescriptors:
- displayName: Audit Conditions
path: auditConditions
- description: ObservedGeneration is the generation as observed by the operator
consuming this API.
displayName: Observed Generation
path: observedGeneration
- displayName: Webhook Conditions
path: webhookConditions
version: v1alpha1
description: Operator for OPA Gatekeeper
displayName: Gatekeeper Operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ spec:
displayName: Gatekeeper
kind: Gatekeeper
name: gatekeepers.operator.gatekeeper.sh
resources:
- kind: Deployment
name: gatekeeper-deployment
version: v1
specDescriptors:
- displayName: Affinity
path: affinity
- displayName: Audit Configuration
path: audit
- displayName: Image Configuration
path: image
- displayName: Mutating Webhook
path: mutatingWebhook
- displayName: Node Selector
path: nodeSelector
- displayName: Pod Annotations
path: podAnnotations
- displayName: Tolerations
path: tolerations
- displayName: Validating Webhook
path: validatingWebhook
- displayName: Webhook Config
path: webhook
statusDescriptors:
- displayName: Audit Conditions
path: auditConditions
- description: ObservedGeneration is the generation as observed by the operator
consuming this API.
displayName: Observed Generation
path: observedGeneration
- displayName: Webhook Conditions
path: webhookConditions
version: v1alpha1
description: Operator for OPA Gatekeeper
displayName: Gatekeeper Operator
Expand Down
6 changes: 6 additions & 0 deletions config/samples/gatekeeper_empty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: operator.gatekeeper.sh/v1alpha1
kind: Gatekeeper
metadata:
name: gatekeeper
spec:
# Empty
3 changes: 2 additions & 1 deletion config/samples/gatekeeper_with_all_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: Gatekeeper
metadata:
name: gatekeeper
spec:
# Add fields here
image:
image: docker.io/openpolicyagent/gatekeeper:v3.5.2
imagePullPolicy: Always
Expand All @@ -23,6 +22,7 @@ spec:
cpu: 100m
memory: 20Mi
validatingWebhook: Enabled
mutatingWebhook: Enabled
webhook:
replicas: 2
logLevel: ERROR
Expand Down Expand Up @@ -57,3 +57,4 @@ spec:
podAnnotations:
some-annotation: "this is a test"
other-annotation: "another test"

2 changes: 1 addition & 1 deletion config/samples/operator_v1alpha1_gatekeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Gatekeeper
metadata:
name: gatekeeper
spec:
# Add fields here
validatingWebhook: Enabled
2 changes: 1 addition & 1 deletion test/e2e/gatekeeper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var _ = Describe("Gatekeeper", func() {
Describe("Overriding CR", func() {
It("Creating an empty gatekeeper contains default values", func() {
gatekeeper := emptyGatekeeper()
err := loadGatekeeperFromFile(gatekeeper, "operator_v1alpha1_gatekeeper.yaml")
err := loadGatekeeperFromFile(gatekeeper, "gatekeeper_empty.yaml")
Expect(err).ToNot(HaveOccurred())

By("Creating Gatekeeper resource", func() {
Expand Down

0 comments on commit 3bef731

Please sign in to comment.