Skip to content

Commit

Permalink
Merge pull request #713 from fabriziosestito/fix/fix-golangci-lint
Browse files Browse the repository at this point in the history
fix: linter errors and remove requests defaults.
  • Loading branch information
fabriziosestito authored Apr 10, 2024
2 parents 3c264c0 + 53a129b commit 926e9b0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
5 changes: 2 additions & 3 deletions controllers/policyserver_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,9 @@ var _ = Describe("PolicyServer controller", func() {
}

Expect(deployment.Spec.Template.Spec.Containers[0].Resources.Limits).To(Equal(policyServer.Spec.Limits))
By("setting the requests to the same value as the limits")
Expect(deployment.Spec.Template.Spec.Containers[0].Resources.Requests).To(Equal(policyServer.Spec.Limits))

return nil
})
}, timeout, pollInterval).Should(Succeed())

By("creating a pod with limit and request set")
Eventually(func(g Gomega) error {
Expand All @@ -318,6 +316,7 @@ var _ = Describe("PolicyServer controller", func() {
}

Expect(pod.Spec.Containers[0].Resources.Limits).To(Equal(policyServer.Spec.Limits))
By("setting the requests to the same value as the limits")
Expect(pod.Spec.Containers[0].Resources.Requests).To(Equal(policyServer.Spec.Limits))

return nil
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/policies/v1/policyserver_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ func (ps *PolicyServer) Default() {
if ps.ObjectMeta.DeletionTimestamp == nil {
controllerutil.AddFinalizer(ps, constants.KubewardenFinalizer)
}

// Default the requests to the limits if not set
for limitName, limitQuantity := range ps.Spec.Limits {
if _, found := ps.Spec.Requests[limitName]; !found {
if ps.Spec.Requests == nil {
ps.Spec.Requests = make(corev1.ResourceList)
}
ps.Spec.Requests[limitName] = limitQuantity
}
}
}

// +kubebuilder:webhook:path=/validate-policies-kubewarden-io-v1-policyserver,mutating=false,failurePolicy=fail,sideEffects=None,groups=policies.kubewarden.io,resources=policyservers,verbs=create;update,versions=v1,name=vpolicyserver.kb.io,admissionReviewVersions=v1
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/policies/v1/policyserver_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func TestDefault(t *testing.T) {
policyServer.Default()

assert.Contains(t, policyServer.Finalizers, constants.KubewardenFinalizer)
assert.Equal(t, corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("1Gi"),
}, policyServer.Spec.Requests)
}

func TestValidatePolicyServerName(t *testing.T) {
Expand Down

0 comments on commit 926e9b0

Please sign in to comment.