Skip to content

Commit

Permalink
HAWNG-613: Restores the version property to the operator CRD
Browse files Browse the repository at this point in the history
* Makefile
 * Adds a CSV_SKIP_RANGE to hide the 1.0.0 - 1.0.1 versions of the operator
   that contain the problematic CRD
 * Adds support to pre-bundle rule for CSV_SKIP_RANGE
 * Switches to speech marks around sed patterns to stop the < & > operators
   in the CSV_SKIP_RANGE from acting as shell redirection operators

* .../hawtio-operator.clusterserviceversion.yaml
 * Executing `make bundle` adds the skipRange property to the CSV

* ...hawtio_cr.yaml
 * version property is a string so should be enclosed with speech marks
 * Includes a default version property in v1 version

* v1/hawtio_types.go
 * Restores the version property and adds comment explaining this is only
   for legacy purposes. This comment is carried through to the Hawtio form
   shown in the OpenShift console

* v1alpha1/hawtio_types.go
 * Adds the deprecation warning
 * Tidies up some minor comments

* hawtio.io_hawtios.yaml CRD
 * Re-generated CRD with latest changes including insertion of the version
   property into the v1 schema
  • Loading branch information
phantomjinx committed Apr 5, 2024
1 parent a54c298 commit fe0eda5
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 21 deletions.
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ CSV_FILENAME := $(PACKAGE).clusterserviceversion.yaml
CSV_PATH := $(MANIFESTS)/bases/$(CSV_FILENAME)
# Not required for first version to be deployed to Operator Hub
CSV_REPLACES := $(LAST_RELEASED_IMAGE_NAME).v$(LAST_RELEASED_VERSION)
#CSV_SKIP_RANGE :=
# Hides the 1.0.0 & 1.0.1 releases with the CRD that removes the 'version' property
CSV_SKIP_RANGE := >=1.0.0 <1.0.2
IMAGE_NAME ?= $(DEFAULT_IMAGE)

# Test Bundle Index
Expand Down Expand Up @@ -233,10 +234,19 @@ pre-bundle:
@sed -i 's/^ name: .*.\(v.*\)/ name: $(CSV_NAME)/' $(CSV_PATH)
@sed -i 's/^ displayName: .*/ displayName: $(CSV_DISPLAY_NAME)/' $(CSV_PATH)
@sed -i 's/^ version: .*/ version: $(CSV_VERSION)/' $(CSV_PATH)
# If there is a replaces version then insert/update it
@if grep -q replaces $(CSV_PATH); \
then sed -i 's/^ replaces: .*/ replaces: $(CSV_REPLACES)/' $(CSV_PATH); \
else sed -i '/ version: ${CSV_VERSION}/a \ \ replaces: $(CSV_REPLACES)' $(CSV_PATH); \
then sed -i "s/^ replaces: .*/ replaces: $(CSV_REPLACES)/" $(CSV_PATH); \
else sed -i "/ version: ${CSV_VERSION}/a \ \ replaces: $(CSV_REPLACES)" $(CSV_PATH); \
fi
# If there is a skipRange version range then insert/update it
ifneq ($(CSV_SKIP_RANGE), "")
@if grep -q olm.skipRange $(CSV_PATH); \
then sed -i "s/olm.skipRange: .*/olm.skipRange: '$(CSV_SKIP_RANGE)'/" $(CSV_PATH); \
else sed -i "/ annotations:/a \ \ \ \ olm.skipRange: '$(CSV_SKIP_RANGE)'" $(CSV_PATH); \
fi
endif


#---
#
Expand Down Expand Up @@ -300,7 +310,7 @@ bundle-build: bundle
bundle-index: opm yq
BUNDLE_INDEX=$(BUNDLE_INDEX) INDEX_DIR=$(INDEX_DIR) PACKAGE=$(PACKAGE) YQ=$(YQ) \
OPM=$(OPM) BUNDLE_IMAGE=$(BUNDLE_IMAGE_NAME):$(VERSION) CSV_NAME=$(CSV_NAME) \
CSV_SKIPS=$(CSV_SKIP_RANGE) CSV_REPLACES=$(CSV_REPLACES) CHANNELS="$(CHANNELS)" \
CSV_SKIPS="$(CSV_SKIP_RANGE)" CSV_REPLACES=$(CSV_REPLACES) CHANNELS="$(CHANNELS)" \
./script/build_bundle_index.sh

#
Expand Down
1 change: 1 addition & 0 deletions bundle/bases/hawtio-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
olm.skipRange: '>=1.0.0 <1.0.2'
capabilities: Seamless Upgrades
categories: Integration & Delivery
certified: "false"
Expand Down
21 changes: 16 additions & 5 deletions bundle/manifests/hawt.io_hawtios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ spec:
kind: Hawtio
listKind: HawtioList
plural: hawtios
shortNames:
- hwt
- hio
- hawt
singular: hawtio
scope: Namespaced
versions:
Expand Down Expand Up @@ -241,7 +245,7 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
Expand All @@ -253,7 +257,7 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
route:
Expand Down Expand Up @@ -304,6 +308,11 @@ spec:
- Cluster
- Namespace
type: string
version:
description: 'The Hawtio console container image version. Deprecated:
Remains for legacy purposes in respect of older operators (<1.0.0)
still requiring it for their installs'
type: string
type: object
status:
description: Reports the observed state of Hawtio
Expand Down Expand Up @@ -355,10 +364,12 @@ spec:
jsonPath: .status.URL
name: URL
type: string
deprecated: true
deprecationWarning: v1alpha1.Hawtio is deprecated, please, use v1.Hawtio instead
name: v1alpha1
schema:
openAPIV3Schema:
description: Hawtio Console
description: Hawtio is the Schema for the Hawtio Console API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down Expand Up @@ -563,7 +574,7 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
Expand All @@ -575,7 +586,7 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
route:
Expand Down
8 changes: 5 additions & 3 deletions bundle/manifests/hawtio-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ metadata:
"memory": "32Mi"
}
},
"type": "Namespace"
"type": "Namespace",
"version": "1.12"
}
},
{
Expand All @@ -52,17 +53,18 @@ metadata:
}
},
"type": "Namespace",
"version": 1.12
"version": "1.12"
}
}
]
capabilities: Seamless Upgrades
categories: Integration & Delivery
certified: "false"
containerImage: quay.io/hawtio/operator:1.0.2
createdAt: "2024-04-04T14:20:31Z"
createdAt: "2024-04-05T13:13:52Z"
description: Hawtio eases the discovery and management of Java applications deployed
on OpenShift.
olm.skipRange: '>=1.0.0 <1.0.2'
operators.operatorframework.io/builder: operator-sdk-v1.28.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
repository: https://github.com/hawtio/hawtio-operator
Expand Down
21 changes: 16 additions & 5 deletions deploy/crd/hawt.io_hawtios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ spec:
kind: Hawtio
listKind: HawtioList
plural: hawtios
shortNames:
- hwt
- hio
- hawt
singular: hawtio
scope: Namespaced
versions:
Expand Down Expand Up @@ -243,7 +247,7 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
Expand All @@ -255,7 +259,7 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
route:
Expand Down Expand Up @@ -306,6 +310,11 @@ spec:
- Cluster
- Namespace
type: string
version:
description: 'The Hawtio console container image version. Deprecated:
Remains for legacy purposes in respect of older operators (<1.0.0)
still requiring it for their installs'
type: string
type: object
status:
description: Reports the observed state of Hawtio
Expand Down Expand Up @@ -357,10 +366,12 @@ spec:
jsonPath: .status.URL
name: URL
type: string
deprecated: true
deprecationWarning: v1alpha1.Hawtio is deprecated, please, use v1.Hawtio instead
name: v1alpha1
schema:
openAPIV3Schema:
description: Hawtio Console
description: Hawtio is the Schema for the Hawtio Console API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down Expand Up @@ -565,7 +576,7 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
Expand All @@ -577,7 +588,7 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
route:
Expand Down
4 changes: 4 additions & 0 deletions deploy/crs/hawtio_v1_hawtio_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ metadata:
name: hawtio-online
spec:
type: Namespace

# Included for backward compatibility - not used in hawtio-online 2.0.0+
version: "1.12"

replicas: 1
auth:
clientCertCheckSchedule: "* */12 * * *"
Expand Down
2 changes: 1 addition & 1 deletion deploy/crs/hawtio_v1alpha1_hawtio_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: hawtio-online
spec:
type: Namespace
version: 1.12
version: "1.12"
replicas: 1
auth:
clientCertCheckSchedule: "* */12 * * *"
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/hawtio/v1/hawtio_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hawtios,scope=Namespaced,shortName=hawt,categories=hawtio
// +kubebuilder:resource:path=hawtios,scope=Namespaced,shortName=hwt;hio;hawt,categories=hawtio
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
Expand Down Expand Up @@ -72,6 +72,10 @@ type HawtioSpec struct {
Route HawtioRoute `json:"route,omitempty"`
// List of external route names that will be annotated by the operator to access the console using the routes
ExternalRoutes []string `json:"externalRoutes,omitempty"`
// The Hawtio console container image version.
// Deprecated: Remains for legacy purposes in respect of older
// operators (<1.0.0) still requiring it for their installs
Version string `json:"version,omitempty"`
// The authentication configuration
Auth HawtioAuth `json:"auth,omitempty"`
// The Nginx runtime configuration
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/hawtio/v1alpha1/hawtio_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ const (
NamespaceHawtioDeploymentType HawtioDeploymentType = "Namespace"
)

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hawtios,scope=Namespaced,categories=hawtio
// +kubebuilder:resource:path=hawtios,scope=Namespaced,shortName=hwt;hio;hawt,categories=hawtio
// +kubebuilder:deprecatedversion:warning="v1alpha1.Hawtio is deprecated, please, use v1.Hawtio instead"
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Creation phase"
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.status.image`,description="Console image"
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`,description="Console phase"
// +kubebuilder:printcolumn:name="URL",type=string,JSONPath=`.status.URL`,description="Console URL"

// Hawtio Console
// Hawtio is the Schema for the Hawtio Console API.
type Hawtio struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down

0 comments on commit fe0eda5

Please sign in to comment.