Skip to content

Commit

Permalink
chore(discovery): ensure consistent names for discovery options in CRD
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed May 22, 2024
1 parent ad96512 commit ab2146c
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 42 deletions.
14 changes: 7 additions & 7 deletions api/v1beta1/cryostat_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ func convertTargetDiscoveryTo(srcOpts *TargetDiscoveryOptions) *operatorv1beta2.
var dstOpts *operatorv1beta2.TargetDiscoveryOptions
if srcOpts != nil {
dstOpts = &operatorv1beta2.TargetDiscoveryOptions{
BuiltInDiscoveryDisabled: srcOpts.BuiltInDiscoveryDisabled,
DisableBuiltInPortNames: srcOpts.DisableBuiltInPortNames,
DiscoveryPortNames: srcOpts.DiscoveryPortNames,
DisableBuiltInPortNumbers: srcOpts.DisableBuiltInPortNumbers,
DiscoveryPortNumbers: srcOpts.DiscoveryPortNumbers,
BuiltInDiscoveryDisabled: srcOpts.BuiltInDiscoveryDisabled,
BuiltInPortNamesDisabled: srcOpts.DisableBuiltInPortNames,
DiscoveryPortNames: srcOpts.DiscoveryPortNames,
BuiltInPortNumbersDisabled: srcOpts.DisableBuiltInPortNumbers,
DiscoveryPortNumbers: srcOpts.DiscoveryPortNumbers,
}
}
return dstOpts
Expand Down Expand Up @@ -508,9 +508,9 @@ func convertTargetDiscoveryFrom(srcOpts *operatorv1beta2.TargetDiscoveryOptions)
if srcOpts != nil {
dstOpts = &TargetDiscoveryOptions{
BuiltInDiscoveryDisabled: srcOpts.BuiltInDiscoveryDisabled,
DisableBuiltInPortNames: srcOpts.DisableBuiltInPortNames,
DisableBuiltInPortNames: srcOpts.BuiltInPortNamesDisabled,
DiscoveryPortNames: srcOpts.DiscoveryPortNames,
DisableBuiltInPortNumbers: srcOpts.DisableBuiltInPortNumbers,
DisableBuiltInPortNumbers: srcOpts.BuiltInPortNumbersDisabled,
DiscoveryPortNumbers: srcOpts.DiscoveryPortNumbers,
}
}
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta2/cryostat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,18 @@ type TargetDiscoveryOptions struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Discovery",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
BuiltInDiscoveryDisabled bool `json:"builtInDiscoveryDisabled,omitempty"`
// When true, the Cryostat application will use the default port name jfr-jmx to look for JMX connectable targets.
// When false and discoveryPortNames is empty, the Cryostat application will use the default port name jfr-jmx to look for JMX connectable targets.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Port Names",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
DisableBuiltInPortNames bool `json:"disableBuiltInPortNames,omitempty"`
BuiltInPortNamesDisabled bool `json:"builtInPortNamesDisabled,omitempty"`
// List of port names that the Cryostat application should look for in order to consider a target as JMX connectable.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldDependency:targetDiscoveryOptions.disableBuiltInPortNames:true"}
DiscoveryPortNames []string `json:"discoveryPortNames,omitempty"`
// When true, the Cryostat application will use the default port number 9091 to look for JMX connectable targets.
// When false and discoveryPortNumbers is empty, the Cryostat application will use the default port number 9091 to look for JMX connectable targets.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Disable Built-in Port Numbers",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
DisableBuiltInPortNumbers bool `json:"disableBuiltInPortNumbers,omitempty"`
BuiltInPortNumbersDisabled bool `json:"builtInPortNumbersDisabled,omitempty"`
// List of port numbers that the Cryostat application should look for in order to consider a target as JMX connectable.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldDependency:targetDiscoveryOptions.disableBuiltInPortNumbers:true"}
Expand Down
14 changes: 7 additions & 7 deletions bundle/manifests/cryostat-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ metadata:
capabilities: Seamless Upgrades
categories: Monitoring, Developer Tools
containerImage: quay.io/cryostat/cryostat-operator:3.0.0-dev
createdAt: "2024-05-20T05:12:58Z"
createdAt: "2024-05-22T04:36:29Z"
description: JVM monitoring and profiling tool
operatorframework.io/initialization-resource: |-
{
Expand Down Expand Up @@ -845,16 +845,16 @@ spec:
path: targetDiscoveryOptions.builtInDiscoveryDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
name jfr-jmx to look for JMX connectable targets.
- description: When false and discoveryPortNames is empty, the Cryostat application
will use the default port name jfr-jmx to look for JMX connectable targets.
displayName: Disable Built-in Port Names
path: targetDiscoveryOptions.disableBuiltInPortNames
path: targetDiscoveryOptions.builtInPortNamesDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
number 9091 to look for JMX connectable targets.
- description: When false and discoveryPortNumbers is empty, the Cryostat application
will use the default port number 9091 to look for JMX connectable targets.
displayName: Disable Built-in Port Numbers
path: targetDiscoveryOptions.disableBuiltInPortNumbers
path: targetDiscoveryOptions.builtInPortNumbersDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: List of port names that the Cryostat application should look
Expand Down
14 changes: 8 additions & 6 deletions bundle/manifests/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9715,13 +9715,15 @@ spec:
description: When true, the Cryostat application will disable
the built-in discovery mechanisms. Defaults to false
type: boolean
disableBuiltInPortNames:
description: When true, the Cryostat application will use the
default port name jfr-jmx to look for JMX connectable targets.
builtInPortNamesDisabled:
description: When false and discoveryPortNames is empty, the Cryostat
application will use the default port name jfr-jmx to look for
JMX connectable targets.
type: boolean
disableBuiltInPortNumbers:
description: When true, the Cryostat application will use the
default port number 9091 to look for JMX connectable targets.
builtInPortNumbersDisabled:
description: When false and discoveryPortNumbers is empty, the
Cryostat application will use the default port number 9091 to
look for JMX connectable targets.
type: boolean
discoveryPortNames:
description: List of port names that the Cryostat application
Expand Down
14 changes: 8 additions & 6 deletions config/crd/bases/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9705,13 +9705,15 @@ spec:
description: When true, the Cryostat application will disable
the built-in discovery mechanisms. Defaults to false
type: boolean
disableBuiltInPortNames:
description: When true, the Cryostat application will use the
default port name jfr-jmx to look for JMX connectable targets.
builtInPortNamesDisabled:
description: When false and discoveryPortNames is empty, the Cryostat
application will use the default port name jfr-jmx to look for
JMX connectable targets.
type: boolean
disableBuiltInPortNumbers:
description: When true, the Cryostat application will use the
default port number 9091 to look for JMX connectable targets.
builtInPortNumbersDisabled:
description: When false and discoveryPortNumbers is empty, the
Cryostat application will use the default port number 9091 to
look for JMX connectable targets.
type: boolean
discoveryPortNames:
description: List of port names that the Cryostat application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,16 @@ spec:
path: targetDiscoveryOptions.builtInDiscoveryDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
name jfr-jmx to look for JMX connectable targets.
- description: When false and discoveryPortNames is empty, the Cryostat application
will use the default port name jfr-jmx to look for JMX connectable targets.
displayName: Disable Built-in Port Names
path: targetDiscoveryOptions.disableBuiltInPortNames
path: targetDiscoveryOptions.builtInPortNamesDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: When true, the Cryostat application will use the default port
number 9091 to look for JMX connectable targets.
- description: When false and discoveryPortNumbers is empty, the Cryostat application
will use the default port number 9091 to look for JMX connectable targets.
displayName: Disable Built-in Port Numbers
path: targetDiscoveryOptions.disableBuiltInPortNumbers
path: targetDiscoveryOptions.builtInPortNumbersDisabled
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: List of port names that the Cryostat application should look
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,13 +1099,13 @@ func NewCoreContainer(cr *model.CryostatInstance, specs *ServiceSpecs, imageTag

if len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNames) > 0 {
k8sDiscoveryPortNames = strings.Join(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNames[:], ",")
} else if cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNames {
} else if cr.Spec.TargetDiscoveryOptions.BuiltInPortNamesDisabled {
k8sDiscoveryPortNames = ""
}

if len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNumbers) > 0 {
k8sDiscoveryPortNumbers = strings.Trim(strings.ReplaceAll(fmt.Sprint(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNumbers), " ", ","), "[]")
} else if cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNumbers {
} else if cr.Spec.TargetDiscoveryOptions.BuiltInPortNumbersDisabled {
k8sDiscoveryPortNumbers = ""
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2618,8 +2618,8 @@ func (t *cryostatTestInput) checkMainPodTemplate(deployment *appsv1.Deployment,
len(cr.Spec.TargetDiscoveryOptions.DiscoveryPortNumbers) > 0
builtInDiscoveryDisabled := cr.Spec.TargetDiscoveryOptions != nil && cr.Spec.TargetDiscoveryOptions.BuiltInDiscoveryDisabled
builtInPortConfigDisabled := cr.Spec.TargetDiscoveryOptions != nil &&
cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNames &&
cr.Spec.TargetDiscoveryOptions.DisableBuiltInPortNumbers
cr.Spec.TargetDiscoveryOptions.BuiltInPortNamesDisabled &&
cr.Spec.TargetDiscoveryOptions.BuiltInPortNumbersDisabled
dbSecretProvided := cr.Spec.DatabaseOptions != nil && cr.Spec.DatabaseOptions.SecretName != nil

t.checkCoreContainer(&coreContainer, ingress, reportsUrl,
Expand Down
4 changes: 2 additions & 2 deletions internal/test/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ func (r *TestResources) NewCryostatWithDiscoveryPortConfig() *model.CryostatInst
func (r *TestResources) NewCryostatWithBuiltInPortConfigDisabled() *model.CryostatInstance {
cr := r.NewCryostat()
cr.Spec.TargetDiscoveryOptions = &operatorv1beta2.TargetDiscoveryOptions{
DisableBuiltInPortNames: true,
DisableBuiltInPortNumbers: true,
BuiltInPortNamesDisabled: true,
BuiltInPortNumbersDisabled: true,
}
return cr
}
Expand Down

0 comments on commit ab2146c

Please sign in to comment.