Skip to content

Commit 62487a7

Browse files
committed
Version the input files
1 parent f24f8d5 commit 62487a7

File tree

8 files changed

+85
-2
lines changed

8 files changed

+85
-2
lines changed

kubernetes/create-weblogic-domain-inputs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

4+
# The version of this inputs file. Do not modify.
5+
version: create-weblogic-domain-inputs/v1
6+
47
# Port number for admin server
58
adminPort: 7001
69

kubernetes/create-weblogic-operator-inputs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright 2017, 2018 Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

4+
# The version of this inputs file. Do not modify.
5+
version: create-weblogic-operator-inputs/v1
6+
47
# The name of the service account that the operator will use to
58
# make requests to the Kubernetes API server.
69
# The name must be lowercase

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ function initAndValidateOutputDir {
107107
domain-custom-resource.yaml
108108
}
109109

110+
#
111+
# Function to validate the version of the inputs file
112+
#
113+
function validateVersion {
114+
local requiredVersion='create-weblogic-domain-inputs/v1'
115+
if [ "${version}" != "${requiredVersion}" ]; then
116+
validationError "Invalid version: \"${version}\". Must be ${requiredVersion}."
117+
fi
118+
}
119+
110120
#
111121
# Function to ensure the domain uid is lowercase
112122
#
@@ -376,7 +386,8 @@ function initialize {
376386
weblogicCredentialsSecretName \
377387
namespace \
378388
javaOptions \
379-
t3PublicAddress
389+
t3PublicAddress \
390+
version
380391

381392
validateIntegerInputParamsSpecified \
382393
adminPort \
@@ -393,6 +404,7 @@ function initialize {
393404
exposeAdminT3Channel \
394405
exposeAdminNodePort
395406

407+
validateVersion
396408
validateDomainUid
397409
validateNamespace
398410
validateClusterName

kubernetes/internal/create-weblogic-operator.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ function initialize {
117117
# Parse the common inputs file
118118
parseCommonInputs
119119

120-
validateInputParamsSpecified serviceAccount namespace targetNamespaces weblogicOperatorImage
120+
validateInputParamsSpecified version serviceAccount namespace targetNamespaces weblogicOperatorImage
121121

122122
validateBooleanInputParamsSpecified elkIntegrationEnabled
123123

124+
validateVersion
125+
124126
validateServiceAccount
125127

126128
validateNamespace
@@ -203,6 +205,16 @@ function validateImagePullPolicy {
203205
fi
204206
}
205207

208+
#
209+
# Function to validate the version of the inputs file
210+
#
211+
function validateVersion {
212+
local requiredVersion='create-weblogic-operator-inputs/v1'
213+
if [ "${version}" != "${requiredVersion}" ]; then
214+
validationError "Invalid version: \"${version}\". Must be ${requiredVersion}."
215+
fi
216+
}
217+
206218
#
207219
# Function to validate the service account is lowercase
208220
#

operator/src/test/java/oracle/kubernetes/operator/create/CreateDomainInputs.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class CreateDomainInputs {
7676
private String loadBalancerVolumePath = "";
7777
private String loadBalancerAppPrepath = "";
7878
private String javaOptions = "";
79+
private String version = "";
7980

8081
public static CreateDomainInputs newInputs() throws Exception {
8182
return
@@ -534,6 +535,19 @@ public CreateDomainInputs javaOptions(String javaOptions) {
534535
return this;
535536
}
536537

538+
public String getVersion() {
539+
return version;
540+
}
541+
542+
public void setVersion(String version) {
543+
this.version = convertNullToEmptyString(version);
544+
}
545+
546+
public CreateDomainInputs version(String version) {
547+
setVersion(version);
548+
return this;
549+
}
550+
537551
private String convertNullToEmptyString(String val) {
538552
return Objects.toString(val, "");
539553
}

operator/src/test/java/oracle/kubernetes/operator/create/CreateDomainInputsValidationTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class CreateDomainInputsValidationTest {
4848
private static final String PARAM_LOAD_BALANCER_WEB_PORT = "loadBalancerWebPort";
4949
private static final String PARAM_LOAD_BALANCER_DASHBOARD_PORT = "loadBalancerDashboardPort";
5050
private static final String PARAM_JAVA_OPTIONS = "javaOptions";
51+
private static final String PARAM_VERSION = "version";
5152

5253
@Before
5354
public void setup() throws Exception {
@@ -523,6 +524,21 @@ public void createDomain_with_missingJavaOptions_failsAndReturnsError() throws E
523524
failsAndPrints(paramMissingError(PARAM_JAVA_OPTIONS)));
524525
}
525526

527+
@Test
528+
public void createDomain_with_missingVersion_failsAndReturnsError() throws Exception {
529+
assertThat(
530+
execCreateDomain(newInputs().version("")),
531+
failsAndPrints(paramMissingError(PARAM_VERSION)));
532+
}
533+
534+
@Test
535+
public void createDomainwith_invalidVersion_failsAndReturnsError() throws Exception {
536+
String val = "no-such-version";
537+
assertThat(
538+
execCreateDomain(newInputs().version(val)),
539+
failsAndPrints(invalidEnumParamValueError(PARAM_VERSION, val)));
540+
}
541+
526542
private void createDomain_with_validStartupControl_succeeds(String startupControl) throws Exception {
527543
createDomain_with_validInputs_succeeds(newInputs().startupControl(startupControl));
528544
}

operator/src/test/java/oracle/kubernetes/operator/create/CreateOperatorInputs.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ private String internalSans() {
148148
// Note: don't allow null strings since, if you use snakeyaml to write out the instance
149149
// to a yaml file, the nulls are written out as "null". Use "" instead.
150150

151+
private String version = "";
152+
public String getVersion() { return version; }
153+
public void setVersion(String val) { version = convertNullToEmptyString(val); }
154+
public CreateOperatorInputs version(String val) { setVersion(val); return this; }
155+
151156
private String serviceAccount = "";
152157
public String getServiceAccount() { return serviceAccount; }
153158
public void setServiceAccount(String val) { serviceAccount = convertNullToEmptyString(val); }

operator/src/test/java/oracle/kubernetes/operator/create/CreateOperatorInputsValidationTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void tearDown() throws Exception {
3333
}
3434
}
3535

36+
private static final String PARAM_VERSION = "version";
3637
private static final String PARAM_SERVICE_ACCOUNT = "serviceAccount";
3738
private static final String PARAM_NAMESPACE = "namespace";
3839
private static final String PARAM_TARGET_NAMESPACES = "targetNamespaces";
@@ -50,6 +51,23 @@ public void tearDown() throws Exception {
5051
private static final String PARAM_JAVA_LOGGING_LEVEL = "javaLoggingLevel";
5152
private static final String PARAM_ELK_INTEGRATION_ENABLED = "elkIntegrationEnabled";
5253

54+
private static final String VERSION_V1 = "create-weblogic-operator-inputs/v1";
55+
56+
@Test
57+
public void createOperator_with_missingVersion_failsAndReturnsError() throws Exception {
58+
assertThat(
59+
execCreateOperator(newInputs().version("")),
60+
failsAndPrints(paramMissingError(PARAM_VERSION)));
61+
}
62+
63+
@Test
64+
public void createOperator_with_invalidVersion_failsAndReturnsError() throws Exception {
65+
String val = "no-such-version";
66+
assertThat(
67+
execCreateOperator(newInputs().version(val)),
68+
failsAndPrints(invalidEnumParamValueError(PARAM_VERSION, val)));
69+
}
70+
5371
@Test
5472
public void createOperator_with_missingServiceAccount_failsAndReturnsError() throws Exception {
5573
assertThat(

0 commit comments

Comments
 (0)