Skip to content

Commit

Permalink
reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Apr 4, 2024
1 parent 2bb94ce commit d621f7a
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ metadata:
capabilities: Seamless Upgrades
categories: Monitoring, Developer Tools
containerImage: quay.io/cryostat/cryostat-operator:2.5.0-dev
createdAt: "2024-03-27T17:54:03Z"
createdAt: "2024-04-04T17:17:25Z"
description: JVM monitoring and profiling tool
operatorframework.io/initialization-resource: |-
{
Expand Down
12 changes: 6 additions & 6 deletions bundle/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- operator-install
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240326210241
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: operator-install
Expand All @@ -80,7 +80,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-cr
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240326210241
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: cryostat-cr
Expand All @@ -90,7 +90,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-multi-namespace
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240319151455
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: cryostat-multi-namespace
Expand All @@ -100,7 +100,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-recording
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240326210241
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: cryostat-recording
Expand All @@ -110,7 +110,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-config-change
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240326210241
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: cryostat-config-change
Expand All @@ -120,7 +120,7 @@ stages:
- entrypoint:
- cryostat-scorecard-tests
- cryostat-report
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240326210241
image: quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171629
labels:
suite: cryostat
test: cryostat-report
Expand Down
12 changes: 6 additions & 6 deletions config/scorecard/patches/custom.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
entrypoint:
- cryostat-scorecard-tests
- operator-install
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240327175405"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: operator-install
Expand All @@ -18,7 +18,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-cr
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240327175405"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: cryostat-cr
Expand All @@ -28,7 +28,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-multi-namespace
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240319151847"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: cryostat-multi-namespace
Expand All @@ -38,7 +38,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-recording
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240327175405"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: cryostat-recording
Expand All @@ -48,7 +48,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-config-change
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240327175405"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: cryostat-config-change
Expand All @@ -58,7 +58,7 @@
entrypoint:
- cryostat-scorecard-tests
- cryostat-report
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240327175405"
image: "quay.io/cryostat/cryostat-operator-scorecard:2.5.0-20240404171725"
labels:
suite: cryostat
test: cryostat-report
2 changes: 1 addition & 1 deletion internal/images/custom-scorecard-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func runTests(testNames []string, bundle *apimanifests.Bundle, namespace string,
case tests.CryostatCRTestName:
results = append(results, *tests.CryostatCRTest(bundle, namespace, openShiftCertManager))
case tests.CryostatMultiNamespaceTestName:
results = append(results, *tests.CryostatMultiNamespaceTest(bundle, namespace, namespaces, openShiftCertManager))
results = append(results, *tests.CryostatMultiNamespaceTest(bundle, namespace, openShiftCertManager))
case tests.CryostatRecordingTestName:
results = append(results, *tests.CryostatRecordingTest(bundle, namespace, openShiftCertManager))
case tests.CryostatConfigChangeTestName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ rules:
verbs:
- create
- delete
- get
- apiGroups:
- operator.cryostat.io
resources:
Expand All @@ -166,10 +165,3 @@ rules:
- clustercryostats/status
verbs:
- get
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- get
68 changes: 28 additions & 40 deletions internal/test/scorecard/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ func (c *OperatorCRDClient) Cryostats(namespace string) *CryostatClient {
}
}

// Cryostats returns a ClusterCryostatClient configured to a specific namespace
func (c *OperatorCRDClient) ClusterCryostats(namespace string) *CryostatClient {
// ClusterCryostats returns a ClusterCryostatClient
func (c *OperatorCRDClient) ClusterCryostats() *CryostatClient {
return &CryostatClient{
restClient: c.client,
namespace: namespace,
resource: "clustercryostats",
}
}
Expand Down Expand Up @@ -134,36 +133,18 @@ type CryostatClient struct {
}

// Get returns a Cryostat CR for the given name
func (c *CryostatClient) GetCluster(ctx context.Context, name string) (*operatorv1beta1.ClusterCryostat, error) {
return getCluster(ctx, c.restClient, c.resource, name, &operatorv1beta1.ClusterCryostat{})
func (c *CryostatClient) GetNonNamespaced(ctx context.Context, name string) (*operatorv1beta1.ClusterCryostat, error) {
return get(ctx, c.restClient, c.resource, c.namespace, name, &operatorv1beta1.ClusterCryostat{})
}

// Create creates the provided ClusterCryostat CR
func (c *CryostatClient) CreateCluster(ctx context.Context, obj *operatorv1beta1.ClusterCryostat) (*operatorv1beta1.ClusterCryostat, error) {
return createCluster(ctx, c.restClient, c.resource, obj, &operatorv1beta1.ClusterCryostat{})
func (c *CryostatClient) CreateNonNamespaced(ctx context.Context, obj *operatorv1beta1.ClusterCryostat) (*operatorv1beta1.ClusterCryostat, error) {
return create(ctx, c.restClient, c.resource, c.namespace, obj, &operatorv1beta1.ClusterCryostat{})
}

// Delete deletes the Cryostat CR with the given name
func (c *CryostatClient) DeleteCluster(ctx context.Context, name string, options *metav1.DeleteOptions) error {
return deleteCluster(ctx, c.restClient, c.resource, name, options)
}

func getCluster[r runtime.Object](ctx context.Context, c rest.Interface, res string, name string, result r) (r, error) {
err := c.Get().Resource(res).
Name(name).Do(ctx).Into(result)
return result, err
}

func createCluster[r runtime.Object](ctx context.Context, c rest.Interface, res string, obj r, result r) (r, error) {
err := c.Post().Resource(res).
Body(obj).Do(ctx).Into(result)
return result, err
}

func deleteCluster(ctx context.Context, c rest.Interface, res string, name string, opts *metav1.DeleteOptions) error {
return c.Delete().Resource(res).
Name(name).Body(opts).Do(ctx).
Error()
func (c *CryostatClient) DeleteNonNamespaced(ctx context.Context, name string, options *metav1.DeleteOptions) error {
return delete(ctx, c.restClient, c.resource, c.namespace, name, options)
}

// Get returns a Cryostat CR for the given name
Expand All @@ -187,31 +168,38 @@ func (c *CryostatClient) Delete(ctx context.Context, name string, options *metav
}

func get[r runtime.Object](ctx context.Context, c rest.Interface, res string, ns string, name string, result r) (r, error) {
err := c.Get().
Namespace(ns).Resource(res).
Name(name).Do(ctx).Into(result)
rq := c.Get().Resource(res).Name(name)
if len(ns) > 0 {
rq = rq.Namespace(ns)
}
err := rq.Do(ctx).Into(result)
return result, err
}

func create[r runtime.Object](ctx context.Context, c rest.Interface, res string, ns string, obj r, result r) (r, error) {
err := c.Post().
Namespace(ns).Resource(res).
Body(obj).Do(ctx).Into(result)
rq := c.Post().Resource(res).Body(obj)
if len(ns) > 0 {
rq = rq.Namespace(ns)
}
err := rq.Do(ctx).Into(result)
return result, err
}

func update[r runtime.Object](ctx context.Context, c rest.Interface, res string, ns string, obj r, result r, name string) (r, error) {
err := c.Put().
Namespace(ns).Resource(res).Name(name).
Body(obj).Do(ctx).Into(result)
rq := c.Put().Resource(res).Name(name).Body(obj)
if len(ns) > 0 {
rq = rq.Namespace(ns)
}
err := rq.Do(ctx).Into(result)
return result, err
}

func delete(ctx context.Context, c rest.Interface, res string, ns string, name string, opts *metav1.DeleteOptions) error {
return c.Delete().
Namespace(ns).Resource(res).
Name(name).Body(opts).Do(ctx).
Error()
rq := c.Delete().Resource(res).Name(name).Body(opts)
if len(ns) > 0 {
rq = rq.Namespace(ns)
}
return rq.Do(ctx).Error()
}

// CryostatRESTClientset contains methods to interact with
Expand Down
Loading

0 comments on commit d621f7a

Please sign in to comment.