Skip to content

Commit

Permalink
License integration (#77)
Browse files Browse the repository at this point in the history
* Add license fields

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Add license service annotations

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update bundle

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* updates to metadata

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Add license accept to tests

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update unit tests to include TLS_DIR added by default

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update sample and metadata

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update Dockerfiles + metadata

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update utils and namings

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Initialize license values + update sample

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>
  • Loading branch information
leochr committed Apr 10, 2022
1 parent b2c049d commit ba4c094
Show file tree
Hide file tree
Showing 97 changed files with 677 additions and 106 deletions.
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,26 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
ARG USER_ID=65532
ARG GROUP_ID=65532

LABEL vendor="WebSphere Liberty" \
name="WebSphere Liberty Operator" \
version="1.0.0" \
summary="Image for WebSphere Liberty Operator" \
description="This image contains the controllers for WebSphere Liberty Operator. See https://github.com/WASdev/websphere-liberty-operator#websphere-liberty-operator"

ARG VERSION_LABEL=1.0.0
ARG RELEASE_LABEL=XX
ARG VCS_REF=0123456789012345678901234567890123456789
ARG VCS_URL="https://github.com/WASdev/websphere-liberty-operator"
ARG NAME="websphere-liberty-operator"
ARG SUMMARY="WebSphere Liberty Operator"
ARG DESCRIPTION="This image contains the controllers for WebSphere Liberty Operator."

LABEL name=$NAME \
vendor=IBM \
version=$VERSION_LABEL \
release=$RELEASE_LABEL \
description=$DESCRIPTION \
summary=$SUMMARY \
io.k8s.display-name=$SUMMARY \
io.k8s.description=$DESCRIPTION \
vcs-type=git \
vcs-ref=$VCS_REF \
vcs-url=$VCS_URL \
url=$VCS_URL

COPY LICENSE /licenses/
WORKDIR /
Expand Down
74 changes: 73 additions & 1 deletion api/v1/webspherelibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import (
// Defines the desired state of WebSphereLibertyApplication.
type WebSphereLibertyApplicationSpec struct {

// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="License",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
License License `json:"license"`

// Application image to deploy.
// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="Application Image",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
ApplicationImage string `json:"applicationImage"`
Expand Down Expand Up @@ -133,6 +136,65 @@ type WebSphereLibertyApplicationSpec struct {
NetworkPolicy *WebSphereLibertyApplicationNetworkPolicy `json:"networkPolicy,omitempty"`
}

// License information is required.
type License struct {
// The license must be accepted before the Liberty application can be deployed. License information is available at https://ibm.biz/was-license
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Accept License",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:checkbox"}
// +kubebuilder:validation:Enum:=true
Accept bool `json:"accept"`

// Charge metric code. Defaults to Virtual Processor Core (VPC). Other option: Processor Value Unit (PVU)
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Metric"
Metric LicenseMetric `json:"metric,omitempty"`

// Product edition. Defaults to IBM WebSphere Application Server. Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere Application Server Network Deployment
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Edition"
Edition LicenseEdition `json:"edition,omitempty"`

// Entitlement source for the product. Defaults to Standalone. Other options: IBM Cloud Pak for Applications, IBM WebSphere Application Server Family Edition, IBM WebSphere Hybrid Edition
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Product Entitlement Source"
ProductEntitlementSource LicenseEntitlement `json:"productEntitlementSource,omitempty"`
}

// Defines the possible values for charge metric codes
// +kubebuilder:validation:Enum=Virtual Processor Core (VPC);Processor Value Unit (PVU)
type LicenseMetric string

const (
// Metric Virtual Processor Core (VPC)
LicenseMetricVPC LicenseMetric = "Virtual Processor Core (VPC)"
// Metric Processor Value Unit (PVU)
LicenseMetricPVU LicenseMetric = "Processor Value Unit (PVU)"
)

// Defines the possible values for editions
// +kubebuilder:validation:Enum=IBM WebSphere Application Server;IBM WebSphere Application Server Liberty Core;IBM WebSphere Application Server Network Deployment
type LicenseEdition string

const (
// Edition IBM WebSphere Application Server
LicenseEditionBase LicenseEdition = "IBM WebSphere Application Server"
// Edition IBM WebSphere Application Server Liberty Core
LicenseEditionCore LicenseEdition = "IBM WebSphere Application Server Liberty Core"
// Edition IBM WebSphere Application Server Network Deployment
LicenseEditionND LicenseEdition = "IBM WebSphere Application Server Network Deployment"
)

// Defines the possible values for product entitlement source
// +kubebuilder:validation:Enum=Standalone;IBM Cloud Pak for Applications;IBM WebSphere Application Server Family Edition;IBM WebSphere Hybrid Edition
type LicenseEntitlement string

const (
// Entitlement source Standalone
LicenseEntitlementStandalone LicenseEntitlement = "Standalone"
// Entitlement source IBM Cloud Pak for Applications
LicenseEntitlementCP4Apps LicenseEntitlement = "IBM Cloud Pak for Applications"
// Entitlement source IBM WebSphere Application Server Family Edition
LicenseEntitlementFamilyEdition LicenseEntitlement = "IBM WebSphere Application Server Family Edition"
// Entitlement source IBM WebSphere Hybrid Edition
LicenseEntitlementWSHE LicenseEntitlement = "IBM WebSphere Hybrid Edition"
)

// Define health checks on application container to determine whether it is alive or ready to receive traffic
type WebSphereLibertyApplicationProbes struct {
// Periodic probe of container liveness. Container will be restarted if the probe fails.
Expand Down Expand Up @@ -382,7 +444,7 @@ type StatusVersions struct {
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",priority=0,description="Age of the resource"
// +operator-sdk:csv:customresourcedefinitions:displayName="WebSphereLibertyApplication",resources={{Deployment,v1},{Service,v1},{StatefulSet,v1},{Route,v1},{HorizontalPodAutoscaler,v1},{ServiceAccount,v1},{Secret,v1},{NetworkPolicy,v1}}

// Represents the deployment of an WebSphere Liberty application
// Represents the deployment of a WebSphere Liberty application. Documentation: For more information about installation parameters, see https://ibm.biz/wlo-crs. License: By installing this product, you accept the license terms at https://ibm.biz/was-license.
type WebSphereLibertyApplication struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -998,6 +1060,16 @@ func (cr *WebSphereLibertyApplication) Initialize() {
}
}

if cr.Spec.License.Edition == "" {
cr.Spec.License.Edition = LicenseEditionBase
}
if cr.Spec.License.ProductEntitlementSource == "" {
cr.Spec.License.ProductEntitlementSource = LicenseEntitlementStandalone
}
if cr.Spec.License.Metric == "" {
cr.Spec.License.Metric = LicenseMetricVPC
}

}

// GetLabels returns set of labels to be added to all resources
Expand Down
7 changes: 6 additions & 1 deletion api/v1/webspherelibertydump_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (

// WebSphereLibertyDumpSpec defines the desired state of WebSphereLibertyDump
type WebSphereLibertyDumpSpec struct {

// License information is required.
// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="License",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
License LicenseSimple `json:"license"`

// The name of the Pod, which must be in the same namespace as the WebSphereLibertyDump CR.
PodName string `json:"podName"`
// Optional. List of memory dump types to request: thread, heap, system.
Expand Down Expand Up @@ -53,7 +58,7 @@ type DumpStatusVersions struct {
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Completed')].message",priority=1,description="Message for dump operation failing to complete"
// +kubebuilder:printcolumn:name="Dump file",type="string",JSONPath=".status.dumpFile",priority=0,description="Indicates filename of the server dump"
//+operator-sdk:csv:customresourcedefinitions:displayName="WebSphereLibertyDump"
// Day-2 operation for generating server dumps
// Day-2 operation for generating server dumps. Documentation: For more information about installation parameters, see https://ibm.biz/wlo-crs. License: By installing this product, you accept the license terms at https://ibm.biz/was-license.
type WebSphereLibertyDump struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
15 changes: 14 additions & 1 deletion api/v1/webspherelibertytrace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (

// Defines the desired state of WebSphereLibertyTrace
type WebSphereLibertyTraceSpec struct {

// License information is required.
// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="License",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
License LicenseSimple `json:"license"`

// The name of the Pod, which must be in the same namespace as the WebSphereLibertyTrace CR.
PodName string `json:"podName"`

Expand All @@ -25,6 +30,14 @@ type WebSphereLibertyTraceSpec struct {
Disable *bool `json:"disable,omitempty"`
}

// License information is required.
type LicenseSimple struct {
// The license must be accepted before day-2 operations can be deployed. License information is available at https://ibm.biz/was-license
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Accept License",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:checkbox"}
// +kubebuilder:validation:Enum:=true
Accept bool `json:"accept"`
}

// Defines the observed state of WebSphereLibertyTrace operation
type WebSphereLibertyTraceStatus struct {
// +listType=atomic
Expand All @@ -45,7 +58,7 @@ type TraceStatusVersions struct {
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Enabled')].reason",priority=1,description="Reason for the failure of trace condition"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Enabled')].message",priority=1,description="Failure message from trace condition"
// +operator-sdk:csv:customresourcedefinitions:displayName="WebSphereLibertyTrace"
// Day-2 operation for gathering server traces
// Day-2 operation for gathering server traces. Documentation: For more information about installation parameters, see https://ibm.biz/wlo-crs. License: By installing this product, you accept the license terms at https://ibm.biz/was-license.
type WebSphereLibertyTrace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
34 changes: 33 additions & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM scratch

ARG USER_ID=1001

# Core bundle labels.
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
Expand All @@ -21,5 +19,3 @@ LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/

USER ${USER_ID}
Loading

0 comments on commit ba4c094

Please sign in to comment.