Skip to content

Commit 6360bbc

Browse files
authored
Merge pull request #66 from appuio/ocp-4.14
Support for OpenShift 4.14
2 parents 0763ad5 + da02ba4 commit 6360bbc

File tree

19 files changed

+89
-17
lines changed

19 files changed

+89
-17
lines changed

.cruft.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"template": "https://github.com/projectsyn/commodore-component-template.git",
3-
"commit": "a4aff6a9d004c1aad085a875c7759c8f8f1e0d3d",
3+
"commit": "e0fcaa457a78109244747e0879a87e0adaabbd10",
44
"checkout": "main",
55
"context": {
66
"cookiecutter": {
77
"name": "OpenShift4 Console",
88
"slug": "openshift4-console",
99
"parameter_key": "openshift4_console",
10-
"test_cases": "defaults custom-plugins custom-route custom-route-legacy custom-route-managed-tls custom-links custom-logo",
10+
"test_cases": "defaults custom-plugins custom-route custom-route-legacy custom-route-managed-tls custom-links custom-logo ocp-4.14",
1111
"add_lib": "n",
1212
"add_pp": "n",
1313
"add_golden": "y",

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- custom-route-managed-tls
4040
- custom-links
4141
- custom-logo
42+
- ocp-4.14
4243
defaults:
4344
run:
4445
working-directory: ${{ env.COMPONENT_NAME }}
@@ -60,6 +61,7 @@ jobs:
6061
- custom-route-managed-tls
6162
- custom-links
6263
- custom-logo
64+
- ocp-4.14
6365
defaults:
6466
run:
6567
working-directory: ${{ env.COMPONENT_NAME }}

Makefile.vars.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ KUBENT_IMAGE ?= ghcr.io/doitintl/kube-no-trouble:latest
5757
KUBENT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --entrypoint=/app/kubent $(KUBENT_IMAGE)
5858

5959
instance ?= defaults
60-
test_instances = tests/defaults.yml test/custom-plugins.yml tests/custom-route.yml tests/custom-route-legacy.yml tests/custom-route-managed-tls.yml tests/custom-links.yml tests/custom-logo.yml
60+
test_instances = tests/defaults.yml tests/custom-plugins.yml tests/custom-route.yml tests/custom-route-legacy.yml tests/custom-route-managed-tls.yml tests/custom-links.yml tests/custom-logo.yml tests/ocp-4.14.yml

class/defaults.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ parameters:
22
openshift4_console:
33
namespace: openshift-console
44
namespace_annotations:
5-
openshift.io/node-selector: node-role.kubernetes.io/master=
5+
openshift.io/node-selector: ''
6+
openshift_version:
7+
Major: '4'
8+
Minor: '13'
69
route:
710
console: {}
811
downloads: {}

component/main.jsonnet

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,34 @@ local tlsSecret =
4444
else
4545
null;
4646

47+
local consolePlugins =
48+
// set default plugins dynamically based on OCP minor version and append
49+
// user-configured plugins to the default.
50+
local defaults =
51+
if std.parseInt(params.openshift_version.Minor) > 13 then
52+
[ 'monitoring-plugin' ]
53+
else
54+
[];
55+
// render final plugins list by appending any user-provided plugins that
56+
// aren't part of the default plugins to the list of plugins. We use
57+
// `std.set()` on the user-provided plugins so that users don't have to
58+
// worry about including the same plugin multiple times. Note that this may
59+
// reorder plugins between the input and the resulting manifest.
60+
defaults + [
61+
p
62+
for p in std.set(std.get(params.config, 'plugins', []))
63+
if !std.member(defaults, p)
64+
];
65+
4766
local consoleSpec =
48-
// Remove provided route config from console `.spec`
67+
// Remove provided route config from console `.spec`, and skip field
68+
// `plugins` since we manage it dynamically.
4969
{
5070
[k]: params.config[k]
5171
for k in std.objectFields(params.config)
52-
if k != 'route'
72+
if !std.member([ 'route', 'plugins' ], k)
5373
} + {
54-
plugins+: [],
74+
plugins: consolePlugins,
5575
} +
5676
(
5777
if logoFileName != '' then

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,27 @@ default::
2121
+
2222
[source,yaml]
2323
----
24-
openshift.io/node-selector: node-role.kubernetes.io/master=
24+
openshift.io/node-selector: ''
2525
----
2626

2727
Annotations to add to the managed namespace.
2828
Annotations can be removed by setting the value to `null`.
2929

30+
== `openshift_version`
31+
32+
type:: dictionary
33+
default::
34+
+
35+
[source,yaml]
36+
----
37+
Major: '4'
38+
Minor: '13'
39+
----
40+
41+
The OpenShift major and minor version.
42+
43+
TIP: This parameter is intended to be populated from the `openshiftVersion` dynamic fact and replicates the fact's structure.
44+
3045
== `route`
3146

3247
[horizontal]
@@ -60,10 +75,16 @@ Indicates whether and how the operator should manage the console.
6075

6176
[horizontal]
6277
type:: list
63-
default:: `[]`
78+
default:: dynamic, depending on the reported OpenShift version
6479

6580
Add plugins to the console.
6681

82+
The component will inject a dynamic set of plugins into the configuration based on the reported OpenShift version in parameter `openshift_version`.
83+
For OpenShift 4.14 and newer, the component always adds plugin `monitoring-plugin`.
84+
Additionally, the component will remove duplicated entries from the list of configured plugins.
85+
86+
NOTE: The order of entries in the field isn't guaranteed to be stable.
87+
6788
=== `config.route`
6889

6990
[horizontal]
@@ -77,7 +98,7 @@ If the route is part of the default apps domain, no TLS cert needs to be specifi
7798
====
7899
This configuration parameter is deprecated starting with OpenShift 4.8, see the https://docs.openshift.com/container-platform/4.8/web_console/customizing-the-web-console.html#customizing-the-console-route_customizing-web-console[upstream documentation].
79100
80-
The component provides support to use the new recommended configuration via the `ingress.config.openshift.io/cluster` object, see the documentation for parameters <<_openshift_version,`openshift_version`>> and <<_route,`route`>>.
101+
The component always configures the console route via the `ingress.config.openshift.io/cluster` object.
81102
82103
If both this parameter and parameter `route` are present, parameter `route` has precedence over this parameter.
83104
====

tests/custom-plugins.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ parameters:
22
openshift4_console:
33
config:
44
plugins:
5+
- foo-bar
6+
- example-plugin
57
- example-plugin

tests/golden/custom-links/openshift4-console/openshift4-console/00_namespace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
annotations:
5-
openshift.io/node-selector: node-role.kubernetes.io/master=
5+
openshift.io/node-selector: ''
66
labels:
77
name: openshift-console
88
name: openshift-console

tests/golden/custom-logo/openshift4-console/openshift4-console/00_namespace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
annotations:
5-
openshift.io/node-selector: node-role.kubernetes.io/master=
5+
openshift.io/node-selector: ''
66
labels:
77
name: openshift-console
88
name: openshift-console

tests/golden/custom-plugins/openshift4-console/openshift4-console/00_namespace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
annotations:
5-
openshift.io/node-selector: node-role.kubernetes.io/master=
5+
openshift.io/node-selector: ''
66
labels:
77
name: openshift-console
88
name: openshift-console

0 commit comments

Comments
 (0)