diff --git a/CHANGELOG.md b/CHANGELOG.md index 703711f..8053c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,10 +21,13 @@ All notable changes to this project will be documented in this file. - Added support for naming service port. ([#237](https://github.com/appsody/appsody-operator/pull/237)) - Added must-gather scripts for troubleshooting. ([#209](https://github.com/appsody/appsody-operator/pull/209)) - Added the shortnames `app` and `apps` to the AppsodyApplication CRD. ([#198](https://github.com/appsody/appsody-operator/issues/198)) +- Added OpenShift specific annotations ([#54](https://github.com/application-stacks/runtime-component-operator/pull/54)) +- Set port name for Knative service if specified ([#55](https://github.com/application-stacks/runtime-component-operator/pull/55)) ### Changed - Changed the match label of the ServiceMonitor created by operator from `app.appsody.dev/monitor` to `monitor.appsody.dev/enabled` +- **Breaking change:** When `service.consumes[].namespace` is not specified, injected name of environment variable follows `_` format and binding information are mounted at `/`. ([#27](https://github.com/application-stacks/runtime-component-operator/pull/27) and [#46](https://github.com/application-stacks/runtime-component-operator/pull/46)) ## [0.3.0] @@ -62,7 +65,7 @@ All notable changes to this project will be documented in this file. - Support for watching multiple namespaces by setting `WATCH_NAMESPACE` to a comma-separated list of namespaces. ([#114](https://github.com/appsody/appsody-operator/issues/114)) - Allow users to add new labels or override default labels for resources created by the operator via setting labels on `AppsodyApplication` CRs. ([#118](https://github.com/appsody/appsody-operator/issues/118)) - Support for automatically creating and configuring `ServiceMonitor` resource for integration with Prometheus Operator. ([#125](https://github.com/appsody/appsody-operator/issues/125)) -- Automatically configure the `AppsodyApplication`'s Kubernetes resources to allow automatic creation of an application definition by [kAppNav](https://kappnav.io/), Kubernetes Application Navigator. ([#128](https://github.com/appsody/appsody-operator/issues/128),[#135](https://github.com/appsody/appsody-operator/issues/135)) +- Automatically configure the `AppsodyApplication`'s Kubernetes resources to allow automatic creation of an application definition by [kAppNav](https://kappnav.io/), Kubernetes Application Navigator. ([#128](https://github.com/appsody/appsody-operator/issues/128) and [#135](https://github.com/appsody/appsody-operator/issues/135)) ### Changed diff --git a/deploy/crds/appsody.dev_appsodyapplications_crd.yaml b/deploy/crds/appsody.dev_appsodyapplications_crd.yaml index 5a5a2a2..a7a972d 100644 --- a/deploy/crds/appsody.dev_appsodyapplications_crd.yaml +++ b/deploy/crds/appsody.dev_appsodyapplications_crd.yaml @@ -2156,7 +2156,7 @@ spec: type: array port: format: int32 - maximum: 65536 + maximum: 65535 minimum: 1 type: integer portName: @@ -2217,6 +2217,8 @@ spec: type: object targetPort: format: int32 + maximum: 65535 + minimum: 1 type: integer type: description: Service Type string describes ingress methods for a diff --git a/deploy/releases/0.4.0/appsody-app-crd.yaml b/deploy/releases/0.4.0/appsody-app-crd.yaml index 5a5a2a2..a7a972d 100644 --- a/deploy/releases/0.4.0/appsody-app-crd.yaml +++ b/deploy/releases/0.4.0/appsody-app-crd.yaml @@ -2156,7 +2156,7 @@ spec: type: array port: format: int32 - maximum: 65536 + maximum: 65535 minimum: 1 type: integer portName: @@ -2217,6 +2217,8 @@ spec: type: object targetPort: format: int32 + maximum: 65535 + minimum: 1 type: integer type: description: Service Type string describes ingress methods for a diff --git a/deploy/releases/daily/appsody-app-crd.yaml b/deploy/releases/daily/appsody-app-crd.yaml index 5a5a2a2..a7a972d 100644 --- a/deploy/releases/daily/appsody-app-crd.yaml +++ b/deploy/releases/daily/appsody-app-crd.yaml @@ -2156,7 +2156,7 @@ spec: type: array port: format: int32 - maximum: 65536 + maximum: 65535 minimum: 1 type: integer portName: @@ -2217,6 +2217,8 @@ spec: type: object targetPort: format: int32 + maximum: 65535 + minimum: 1 type: integer type: description: Service Type string describes ingress methods for a diff --git a/doc/user-guide.md b/doc/user-guide.md index 4a25cf5..5918860 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -76,7 +76,7 @@ Each `AppsodyApplication` CR must at least specify the `applicationImage` parame | `service.consumes` | An array consisting of services to be consumed by the `AppsodyApplication`. | | `service.consumes[].category` | The type of service binding to be consumed. At this time, the only allowed value is `openapi`. | | `service.consumes[].name` | The name of the service to be consumed. If binding to an `AppsodyApplication`, then this would be the provider's CR name. | -| `service.consumes[].namespace` | The namespace of the service to be consumed. If binding to an `AppsodyApplication`, then this would be the provider's CR name. | +| `service.consumes[].namespace` | The namespace of the service to be consumed. If binding to an `AppsodyApplication`, then this would be the provider's CR namespace. | | `service.consumes[].mountPath` | Optional field to specify which location in the pod, service binding secret should be mounted. If not specified, the secret keys would be injected as environment variables. | | `createKnativeService` | A boolean to toggle the creation of Knative resources and usage of Knative serving. | | `expose` | A boolean that toggles the external exposure of this deployment via a Route or a Knative Route resource. | diff --git a/go.mod b/go.mod index c0e900a..a75bc45 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/appsody/appsody-operator go 1.13 require ( - github.com/application-stacks/runtime-component-operator v0.4.0 + github.com/application-stacks/runtime-component-operator v0.4.1 github.com/coreos/prometheus-operator v0.34.0 github.com/go-openapi/spec v0.19.4 github.com/jetstack/cert-manager v0.12.0 diff --git a/go.sum b/go.sum index 4a8f3bf..27026e4 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/ant31/crd-validation v0.0.0-20180702145049-30f8a35d0ac2/go.mod h1:X0noFIik9YqfhGYBLEHg8LJKEwy7QIitLQuFMpKLcPk= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/application-stacks/runtime-component-operator v0.4.0 h1:ofejdFzaDxu2rY4PUNVY6X1LBg7/LzK5kRiEPa/XHbw= -github.com/application-stacks/runtime-component-operator v0.4.0/go.mod h1:3TJa36rzYElnHB7MRA/2GCpEq4SbGmBVw5O7ueN/JeM= +github.com/application-stacks/runtime-component-operator v0.4.1 h1:EXrV+i6/2sgVt+OILH6kgpS0670MXycR+drIztdynPw= +github.com/application-stacks/runtime-component-operator v0.4.1/go.mod h1:3TJa36rzYElnHB7MRA/2GCpEq4SbGmBVw5O7ueN/JeM= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= diff --git a/pkg/apis/appsody/v1beta1/appsodyapplication_types.go b/pkg/apis/appsody/v1beta1/appsodyapplication_types.go index 347077a..d3a7c8c 100644 --- a/pkg/apis/appsody/v1beta1/appsodyapplication_types.go +++ b/pkg/apis/appsody/v1beta1/appsodyapplication_types.go @@ -67,12 +67,15 @@ type AppsodyApplicationAutoScaling struct { type AppsodyApplicationService struct { Type *corev1.ServiceType `json:"type,omitempty"` - // +kubebuilder:validation:Maximum=65536 + // +kubebuilder:validation:Maximum=65535 + // +kubebuilder:validation:Minimum=1 + Port int32 `json:"port,omitempty"` + // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Minimum=1 - Port int32 `json:"port,omitempty"` - PortName string `json:"portName,omitempty"` TargetPort *int32 `json:"targetPort,omitempty"` + PortName string `json:"portName,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` // +listType=atomic Consumes []ServiceBindingConsumes `json:"consumes,omitempty"` @@ -858,7 +861,7 @@ func (cr *AppsodyApplication) GetLabels() map[string]string { "app.kubernetes.io/instance": cr.Name, "app.kubernetes.io/name": cr.Name, "app.kubernetes.io/managed-by": "appsody-operator", - "app.kubernetes.io/component": "backend", + "app.kubernetes.io/component": "backend", "app.kubernetes.io/part-of": cr.Spec.ApplicationName, } diff --git a/pkg/apis/appsody/v1beta1/zz_generated.openapi.go b/pkg/apis/appsody/v1beta1/zz_generated.openapi.go index d5b6817..69e860a 100644 --- a/pkg/apis/appsody/v1beta1/zz_generated.openapi.go +++ b/pkg/apis/appsody/v1beta1/zz_generated.openapi.go @@ -117,18 +117,18 @@ func schema_pkg_apis_appsody_v1beta1_AppsodyApplicationService(ref common.Refere Format: "int32", }, }, - "portName": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, "targetPort": { SchemaProps: spec.SchemaProps{ Type: []string{"integer"}, Format: "int32", }, }, + "portName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, "annotations": { SchemaProps: spec.SchemaProps{ Type: []string{"object"}, diff --git a/pkg/controller/appsodyapplication/appsodyapplication_controller.go b/pkg/controller/appsodyapplication/appsodyapplication_controller.go index c701af8..41be875 100644 --- a/pkg/controller/appsodyapplication/appsodyapplication_controller.go +++ b/pkg/controller/appsodyapplication/appsodyapplication_controller.go @@ -11,7 +11,6 @@ import ( oputils "github.com/application-stacks/runtime-component-operator/pkg/utils" appsodyv1beta1 "github.com/appsody/appsody-operator/pkg/apis/appsody/v1beta1" - autils "github.com/appsody/appsody-operator/pkg/utils" prometheusv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1" certmngrv1alpha2 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2" servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" @@ -446,6 +445,12 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco reqLogger.V(1).Info(fmt.Sprintf("%s is not supported on the cluster", applicationsv1beta1.SchemeGroupVersion.String())) } + if r.IsOpenShift() { + // The order of items passed to the MergeMaps matters here! Annotations from GetOpenShiftAnnotations have higher importance. Otherwise, + // it is not possible to override converted annotations. + instance.Annotations = oputils.MergeMaps(instance.Annotations, oputils.GetOpenShiftAnnotations(instance)) + } + currentGen := instance.Generation err = r.GetClient().Update(context.TODO(), instance) if err != nil { @@ -551,10 +556,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco ksvc := &servingv1alpha1.Service{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(ksvc, instance, func() error { oputils.CustomizeKnativeService(ksvc, instance) - if r.IsOpenShift() { - ksvc.Annotations = oputils.MergeMaps(ksvc.Annotations, autils.GetOpenShiftAnnotations(instance)) - ksvc.Spec.Template.ObjectMeta.Annotations = oputils.MergeMaps(oputils.GetConnectToAnnotation(instance), ksvc.Spec.Template.ObjectMeta.Annotations) - } return nil }) @@ -578,10 +579,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco svc := &corev1.Service{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(svc, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(instance.Annotations, autils.GetOpenShiftAnnotations(instance)) - } - oputils.CustomizeService(svc, ba) svc.Annotations = oputils.MergeMaps(svc.Annotations, instance.Spec.Service.Annotations) @@ -610,10 +607,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco } svc := &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: instance.Name + "-headless", Namespace: instance.Namespace}} err = r.CreateOrUpdate(svc, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(instance.Annotations, autils.GetOpenShiftAnnotations(instance)) - } - oputils.CustomizeService(svc, instance) svc.Spec.ClusterIP = corev1.ClusterIPNone svc.Spec.Type = corev1.ServiceTypeClusterIP @@ -626,10 +619,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco statefulSet := &appsv1.StatefulSet{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(statefulSet, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(autils.GetOpenShiftAnnotations(instance), instance.Annotations) - } - oputils.CustomizeStatefulSet(statefulSet, instance) oputils.CustomizePodSpec(&statefulSet.Spec.Template, instance) oputils.CustomizePersistence(statefulSet, instance) @@ -659,9 +648,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco } deploy := &appsv1.Deployment{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(deploy, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(autils.GetOpenShiftAnnotations(instance), instance.Annotations) - } oputils.CustomizeDeployment(deploy, instance) oputils.CustomizePodSpec(&deploy.Spec.Template, instance) return nil @@ -676,10 +662,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco if instance.Spec.Autoscaling != nil { hpa := &autoscalingv1.HorizontalPodAutoscaler{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(hpa, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(autils.GetOpenShiftAnnotations(instance), instance.Annotations) - } - oputils.CustomizeHPA(hpa, instance) return nil }) @@ -709,10 +691,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco return err } oputils.CustomizeRoute(route, ba, key, cert, caCert, destCACert) - if r.IsOpenShift() { - route.Annotations = oputils.MergeMaps(autils.GetOpenShiftAnnotations(ba), route.Annotations) - } - return nil }) if err != nil { @@ -738,10 +716,6 @@ func (r *ReconcileAppsodyApplication) Reconcile(request reconcile.Request) (reco if instance.Spec.Monitoring != nil && (instance.Spec.CreateKnativeService == nil || !*instance.Spec.CreateKnativeService) { sm := &prometheusv1.ServiceMonitor{ObjectMeta: defaultMeta} err = r.CreateOrUpdate(sm, instance, func() error { - if r.IsOpenShift() { - instance.Annotations = oputils.MergeMaps(autils.GetOpenShiftAnnotations(instance), instance.Annotations) - } - oputils.CustomizeServiceMonitor(sm, instance) return nil }) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go deleted file mode 100644 index 06e5675..0000000 --- a/pkg/utils/utils.go +++ /dev/null @@ -1,19 +0,0 @@ -package utils - -import ( - "github.com/application-stacks/runtime-component-operator/pkg/common" - - oputils "github.com/application-stacks/runtime-component-operator/pkg/utils" -) - -func GetOpenShiftAnnotations(ba common.BaseComponent) map[string]string { - annos := map[string]string{} - - for key, val := range ba.GetLabels() { - if key == "image.opencontainers.org/source" { - annos["app.openshift.io/vcs-ref"] = val - } - } - - return oputils.MergeMaps(annos, oputils.GetConnectToAnnotation(ba)) -} diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/runtimecomponent_types.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/runtimecomponent_types.go index 9fab163..dd69a32 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/runtimecomponent_types.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/runtimecomponent_types.go @@ -68,9 +68,12 @@ type RuntimeComponentAutoScaling struct { type RuntimeComponentService struct { Type *corev1.ServiceType `json:"type,omitempty"` - // +kubebuilder:validation:Maximum=65536 + // +kubebuilder:validation:Maximum=65535 // +kubebuilder:validation:Minimum=1 Port int32 `json:"port,omitempty"` + // +kubebuilder:validation:Maximum=65535 + // +kubebuilder:validation:Minimum=1 + TargetPort *int32 `json:"targetPort,omitempty"` PortName string `json:"portName,omitempty"` @@ -414,6 +417,15 @@ func (s *RuntimeComponentService) GetPort() int32 { return s.Port } +// GetTargetPort returns the internal target port for containers +func (s *RuntimeComponentService) GetTargetPort() *int32 { + if s.TargetPort == nil { + return nil + } + + return s.TargetPort +} + // GetPortName returns name of service port func (s *RuntimeComponentService) GetPortName() string { return s.PortName diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.deepcopy.go index b33a084..beb748c 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.deepcopy.go @@ -234,6 +234,11 @@ func (in *RuntimeComponentService) DeepCopyInto(out *RuntimeComponentService) { *out = new(corev1.ServiceType) **out = **in } + if in.TargetPort != nil { + in, out := &in.TargetPort, &out.TargetPort + *out = new(int32) + **out = **in + } if in.Annotations != nil { in, out := &in.Annotations, &out.Annotations *out = make(map[string]string, len(*in)) diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.openapi.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.openapi.go index ab9e6b6..58dc817 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.openapi.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1/zz_generated.openapi.go @@ -11,15 +11,15 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "./pkg/apis/appstacks/v1beta1.RuntimeComponent": schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref), - "./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAutoScaling(ref), - "./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref), - "./pkg/apis/appstacks/v1beta1.RuntimeComponentService": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref), - "./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref), - "./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref), - "./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes": schema_pkg_apis_appstacks_v1beta1_ServiceBindingConsumes(ref), - "./pkg/apis/appstacks/v1beta1.ServiceBindingProvides": schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref), - "./pkg/apis/appstacks/v1beta1.StatusCondition": schema_pkg_apis_appstacks_v1beta1_StatusCondition(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponent": schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAutoScaling(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes": schema_pkg_apis_appstacks_v1beta1_ServiceBindingConsumes(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides": schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref), + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition": schema_pkg_apis_appstacks_v1beta1_StatusCondition(ref), } } @@ -51,19 +51,19 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref common.ReferenceCall }, "spec": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus"), }, }, }, }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec", "./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -133,7 +133,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref common.Referenc }, "certificate": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.Certificate"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"), }, }, "certificateSecretRef": { @@ -158,7 +158,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref common.Referenc }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.Certificate"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"}, } } @@ -181,6 +181,12 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere Format: "int32", }, }, + "targetPort": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int32", + }, + }, "portName": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, @@ -212,7 +218,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes"), }, }, }, @@ -220,12 +226,12 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere }, "provides": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingProvides"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides"), }, }, "certificate": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.Certificate"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"), }, }, "certificateSecretRef": { @@ -238,7 +244,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.Certificate", "./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes", "./pkg/apis/appstacks/v1beta1.ServiceBindingProvides"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides"}, } } @@ -269,7 +275,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, "autoscaling": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling"), }, }, "pullPolicy": { @@ -336,7 +342,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, "service": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentService"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService"), }, }, "expose": { @@ -406,7 +412,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, "storage": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentStorage"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStorage"), }, }, "createKnativeService": { @@ -417,7 +423,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, "monitoring": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring"), }, }, "createAppDefinition": { @@ -470,7 +476,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, "route": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute"), }, }, }, @@ -478,7 +484,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling", "./pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring", "./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute", "./pkg/apis/appstacks/v1beta1.RuntimeComponentService", "./pkg/apis/appstacks/v1beta1.RuntimeComponentStorage", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStorage", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"}, } } @@ -500,7 +506,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref common.Referen Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.StatusCondition"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition"), }, }, }, @@ -537,7 +543,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref common.Referen }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.StatusCondition"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition"}, } } @@ -606,7 +612,7 @@ func schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref common.Referen }, "auth": { SchemaProps: spec.SchemaProps{ - Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingAuth"), + Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingAuth"), }, }, }, @@ -614,7 +620,7 @@ func schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref common.Referen }, }, Dependencies: []string{ - "./pkg/apis/appstacks/v1beta1.ServiceBindingAuth"}, + "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingAuth"}, } } diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/common/types.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/common/types.go index c1c646c..56e1fda 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/common/types.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/common/types.go @@ -72,6 +72,7 @@ type BaseComponentStorage interface { // BaseComponentService represents basic service configuration type BaseComponentService interface { GetPort() int32 + GetTargetPort() *int32 GetPortName() string GetType() *corev1.ServiceType GetAnnotations() map[string]string diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/reconciler.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/reconciler.go index 2a88932..1ad03e4 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/reconciler.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/reconciler.go @@ -359,9 +359,10 @@ func (r *ReconcilerBase) ReconcileProvides(ba common.BaseComponent) (_ reconcile logger := log.WithValues("ba.Namespace", mObj.GetNamespace(), "ba.Name", mObj.GetName()) secretName := BuildServiceBindingSecretName(mObj.GetName(), mObj.GetNamespace()) - if ba.GetService().GetProvides() != nil && ba.GetService().GetProvides().GetCategory() == common.ServiceBindingCategoryOpenAPI { + provides := ba.GetService().GetProvides() + if provides != nil && provides.GetCategory() == common.ServiceBindingCategoryOpenAPI { var creds map[string]string - if ba.GetService().GetProvides().GetAuth() != nil { + if provides.GetAuth() != nil { if creds, err = r.GetServiceBindingCreds(ba); err != nil { r.ManageError(errors.Wrapf(err, "service binding dependency not satisfied"), common.StatusConditionTypeDependenciesSatisfied, ba) return r.ManageError(errors.New("failed to get authentication info"), common.StatusConditionTypeReconciled, ba) @@ -374,7 +375,7 @@ func (r *ReconcilerBase) ReconcileProvides(ba common.BaseComponent) (_ reconcile } providerSecret := &corev1.Secret{ObjectMeta: secretMeta} err = r.CreateOrUpdate(providerSecret, mObj, func() error { - CustomizeServieBindingSecret(providerSecret, creds, ba) + CustomizeServiceBindingSecret(providerSecret, creds, ba) return nil }) if err != nil { @@ -394,8 +395,9 @@ func (r *ReconcilerBase) ReconcileProvides(ba common.BaseComponent) (_ reconcile } } else { // Delete all copies of this secret in other namespaces - if providerSecret.Annotations["service."+ba.GetGroupName()+"/copied-to-namespaces"] != "" { - namespaces := strings.Split(providerSecret.Annotations["service."+ba.GetGroupName()+"/copied-to-namespaces"], ",") + copiedToNamespacesKey := getCopiedToNamespacesAnnotationKey(ba) + if providerSecret.Annotations[copiedToNamespacesKey] != "" { + namespaces := strings.Split(providerSecret.Annotations[copiedToNamespacesKey], ",") for _, ns := range namespaces { err = r.GetClient().Delete(context.TODO(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: secretName, Namespace: ns}}) if err != nil { @@ -425,23 +427,21 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R mObj := ba.(metav1.Object) for _, con := range ba.GetService().GetConsumes() { if con.GetCategory() == common.ServiceBindingCategoryOpenAPI { - namespace := "" - if con.GetNamespace() == "" { - namespace = mObj.GetNamespace() - } else { - namespace = con.GetNamespace() + conNamespace := con.GetNamespace() + if conNamespace == "" { + conNamespace = mObj.GetNamespace() } - secretName := BuildServiceBindingSecretName(con.GetName(), namespace) + secretName := BuildServiceBindingSecretName(con.GetName(), conNamespace) existingSecret := &corev1.Secret{} - err := r.GetClient().Get(context.TODO(), types.NamespacedName{Name: secretName, Namespace: namespace}, existingSecret) + err := r.GetClient().Get(context.TODO(), types.NamespacedName{Name: secretName, Namespace: conNamespace}, existingSecret) if err != nil { if kerrors.IsNotFound(err) { delErr := r.DeleteResource(&corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: secretName, Namespace: mObj.GetNamespace()}}) if delErr != nil && !kerrors.IsNotFound(delErr) { delErr = errors.Wrapf(delErr, "unable to delete orphaned secret %q from namespace %q", secretName, mObj.GetNamespace()) - err = errors.Wrapf(delErr, "unable to find service binding secret %q for service %q in namespace %q", secretName, con.GetName(), con.GetNamespace()) + err = errors.Wrapf(delErr, "unable to find service binding secret %q for service %q in namespace %q", secretName, con.GetName(), conNamespace) } else { - err = errors.Wrapf(err, "unable to find service binding secret %q for service %q in namespace %q", secretName, con.GetName(), con.GetNamespace()) + err = errors.Wrapf(err, "unable to find service binding secret %q for service %q in namespace %q", secretName, con.GetName(), conNamespace) } } r.ManageError(errors.Wrapf(err, "service binding dependency not satisfied"), common.StatusConditionTypeDependenciesSatisfied, ba) @@ -451,8 +451,8 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R if existingSecret.Annotations == nil { existingSecret.Annotations = map[string]string{} } - existingSecret.Annotations["service."+ba.GetGroupName()+"/copied-to-namespaces"] = - AppendIfNotSubstring(mObj.GetNamespace(), existingSecret.Annotations["service."+ba.GetGroupName()+"/copied-to-namespaces"]) + copiedToNamespacesKey := getCopiedToNamespacesAnnotationKey(ba) + existingSecret.Annotations[copiedToNamespacesKey] = AppendIfNotSubstring(mObj.GetNamespace(), existingSecret.Annotations[copiedToNamespacesKey]) err = r.GetClient().Update(context.TODO(), existingSecret) if err != nil { r.ManageError(errors.Wrapf(err, "failed to update service provider secret"), common.StatusConditionTypeDependenciesSatisfied, ba) @@ -461,6 +461,7 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R copiedSecret := &corev1.Secret{} err = r.GetClient().Get(context.TODO(), types.NamespacedName{Name: secretName, Namespace: mObj.GetNamespace()}, copiedSecret) + consumedByKey := getConsumedByAnnotationKey(ba) if kerrors.IsNotFound(err) { owner, _ := r.AsOwner(rObj, false) copiedSecret = &corev1.Secret{ @@ -469,7 +470,7 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R Namespace: mObj.GetNamespace(), Labels: existingSecret.Labels, OwnerReferences: []metav1.OwnerReference{owner}, - Annotations: map[string]string{"service." + ba.GetGroupName() + "/consumed-by": mObj.GetName()}, + Annotations: map[string]string{consumedByKey: mObj.GetName()}, }, Data: existingSecret.Data, } @@ -479,11 +480,11 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R if copiedSecret.Annotations == nil { copiedSecret.Annotations = map[string]string{} } - copiedSecret.Annotations["service."+ba.GetGroupName()+"/consumed-by"] = AppendIfNotSubstring(mObj.GetName(), copiedSecret.Annotations["service."+ba.GetGroupName()+"/consumed-by"]) + copiedSecret.Annotations[consumedByKey] = AppendIfNotSubstring(mObj.GetName(), copiedSecret.Annotations[consumedByKey]) copiedSecret.Data = existingSecret.Data // Skip setting the owner on the copiedSecret if the consumer and provider are in the same namespace // This is because we want the secret to be deleted if the provider is deleted - if con.GetNamespace() != copiedSecret.Namespace { + if conNamespace != copiedSecret.Namespace { owner, _ := r.AsOwner(rObj, false) EnsureOwnerRef(copiedSecret, owner) } @@ -516,6 +517,14 @@ func (r *ReconcilerBase) ReconcileConsumes(ba common.BaseComponent) (reconcile.R return r.ManageSuccess(common.StatusConditionTypeDependenciesSatisfied, ba) } +func getCopiedToNamespacesAnnotationKey(ba common.BaseComponent) string { + return "service." + ba.GetGroupName() + "/copied-to-namespaces" +} + +func getConsumedByAnnotationKey(ba common.BaseComponent) string { + return "service." + ba.GetGroupName() + "/consumed-by" +} + // ReconcileCertificate used to manage cert-manager integration func (r *ReconcilerBase) ReconcileCertificate(ba common.BaseComponent) (reconcile.Result, error) { owner := ba.(metav1.Object) diff --git a/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/utils.go b/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/utils.go index 3323787..c38563c 100644 --- a/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/utils.go +++ b/vendor/github.com/application-stacks/runtime-component-operator/pkg/utils/utils.go @@ -168,10 +168,14 @@ func CustomizeService(svc *corev1.Service, ba common.BaseComponent) { svc.Spec.Selector = map[string]string{ "app.kubernetes.io/instance": obj.GetName(), } + + if ba.GetService().GetTargetPort() != nil { + svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(*ba.GetService().GetTargetPort())) + } } -// CustomizeServieBindingSecret ... -func CustomizeServieBindingSecret(secret *corev1.Secret, auth map[string]string, ba common.BaseComponent) { +// CustomizeServiceBindingSecret ... +func CustomizeServiceBindingSecret(secret *corev1.Secret, auth map[string]string, ba common.BaseComponent) { obj := ba.(metav1.Object) secret.Labels = ba.GetLabels() secret.Annotations = MergeMaps(secret.Annotations, ba.GetAnnotations()) @@ -222,12 +226,18 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) { if len(appContainer.Ports) == 0 { appContainer.Ports = append(appContainer.Ports, corev1.ContainerPort{}) } - appContainer.Ports[0].ContainerPort = ba.GetService().GetPort() + + if ba.GetService().GetTargetPort() != nil { + appContainer.Ports[0].ContainerPort = *ba.GetService().GetTargetPort() + } else { + appContainer.Ports[0].ContainerPort = ba.GetService().GetPort() + } + appContainer.Image = ba.GetStatus().GetImageReference() if ba.GetService().GetPortName() != "" { appContainer.Ports[0].Name = ba.GetService().GetPortName() } else { - appContainer.Ports[0].Name = strconv.Itoa(int(ba.GetService().GetPort())) + "-tcp" + appContainer.Ports[0].Name = strconv.Itoa(int(appContainer.Ports[0].ContainerPort)) + "-tcp" } if ba.GetResourceConstraints() != nil { appContainer.Resources = *ba.GetResourceConstraints() @@ -293,7 +303,10 @@ func CustomizeConsumedServices(podSpec *corev1.PodSpec, ba common.BaseComponent) if ba.GetStatus().GetConsumedServices() != nil { appContainer := GetAppContainer(podSpec.Containers) for _, svc := range ba.GetStatus().GetConsumedServices()[common.ServiceBindingCategoryOpenAPI] { - c, _ := findConsumes(svc, ba) + c, err := findConsumes(svc, ba) + if err != nil { + continue + } if c.GetMountPath() != "" { actualMountPath := strings.Join([]string{c.GetMountPath(), c.GetNamespace(), c.GetName()}, "/") volMount := corev1.VolumeMount{Name: svc, MountPath: actualMountPath, ReadOnly: true} @@ -310,7 +323,12 @@ func CustomizeConsumedServices(podSpec *corev1.PodSpec, ba common.BaseComponent) podSpec.Volumes = append(podSpec.Volumes, vol) } else { // The characters allowed in names are: digits (0-9), lower case letters (a-z), -, and .. - keyPrefix := normalizeEnvVariableName(c.GetNamespace() + "_" + c.GetName() + "_") + var keyPrefix string + if c.GetNamespace() == "" { + keyPrefix = normalizeEnvVariableName(c.GetName() + "_") + } else { + keyPrefix = normalizeEnvVariableName(c.GetNamespace() + "_" + c.GetName() + "_") + } keys := []string{"username", "password", "url", "hostname", "protocol", "port", "context"} trueVal := true for _, k := range keys { @@ -464,7 +482,16 @@ func CustomizeKnativeService(ksvc *servingv1alpha1.Service, ba common.BaseCompon ksvc.Spec.Template.ObjectMeta.Labels = ba.GetLabels() ksvc.Spec.Template.ObjectMeta.Annotations = MergeMaps(ksvc.Spec.Template.ObjectMeta.Annotations, ba.GetAnnotations()) - ksvc.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort = ba.GetService().GetPort() + if ba.GetService().GetTargetPort() != nil { + ksvc.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort = *ba.GetService().GetTargetPort() + } else { + ksvc.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort = ba.GetService().GetPort() + } + + if ba.GetService().GetPortName() != "" { + ksvc.Spec.Template.Spec.Containers[0].Ports[0].Name = ba.GetService().GetPortName() + } + ksvc.Spec.Template.Spec.Containers[0].Image = ba.GetStatus().GetImageReference() // Knative sets its own resource constraints //ksvc.Spec.Template.Spec.Containers[0].Resources = *cr.Spec.ResourceConstraints @@ -648,6 +675,7 @@ func GetWatchNamespaces() ([]string, error) { // MergeMaps returns a map containing the union of al the key-value pairs from the input maps. The order of the maps passed into the // func, defines the importance. e.g. if (keyA, value1) is in map1, and (keyA, value2) is in map2, mergeMaps(map1, map2) would contain (keyA, value2). +// If the input map is nil, it is treated as empty map. func MergeMaps(maps ...map[string]string) map[string]string { dest := make(map[string]string) @@ -763,6 +791,24 @@ func GetConnectToAnnotation(ba common.BaseComponent) map[string]string { return anno } +// GetOpenShiftAnnotations returns OpenShift specific annotations +func GetOpenShiftAnnotations(ba common.BaseComponent) map[string]string { + // Conversion table between the pseudo Open Container Initiative <-> OpenShift annotations + conversionMap := map[string]string{ + "image.opencontainers.org/source": "app.openshift.io/vcs-uri", + "image.opencontainers.org/revision": "app.openshift.io/vcs-ref", + } + + annos := map[string]string{} + for from, to := range conversionMap { + if annoVal, ok := ba.GetAnnotations()[from]; ok { + annos[to] = annoVal + } + } + + return MergeMaps(annos, GetConnectToAnnotation(ba)) +} + // IsClusterWide returns true if watchNamespaces is set to [""] func IsClusterWide(watchNamespaces []string) bool { return len(watchNamespaces) == 1 && watchNamespaces[0] == "" diff --git a/vendor/modules.txt b/vendor/modules.txt index 914288b..7852784 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -15,7 +15,7 @@ github.com/Azure/go-autorest/tracing github.com/PuerkitoBio/purell # github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 github.com/PuerkitoBio/urlesc -# github.com/application-stacks/runtime-component-operator v0.4.0 +# github.com/application-stacks/runtime-component-operator v0.4.1 github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1 github.com/application-stacks/runtime-component-operator/pkg/common github.com/application-stacks/runtime-component-operator/pkg/utils