|
| 1 | +// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Universal Permissive License v 1.0 as shown at |
| 3 | +// http://oss.oracle.com/licenses/upl. |
| 4 | + |
| 5 | +package oracle.kubernetes.operator.helm; |
| 6 | + |
| 7 | +import static oracle.kubernetes.operator.helm.MapUtils.addMapEntry; |
| 8 | +import static oracle.kubernetes.operator.helm.MapUtils.addStringMapEntry; |
| 9 | +import static oracle.kubernetes.operator.helm.MapUtils.integerValue; |
| 10 | +import static oracle.kubernetes.operator.helm.MapUtils.loadBooleanFromMap; |
| 11 | +import static oracle.kubernetes.operator.helm.MapUtils.loadFromMap; |
| 12 | +import static oracle.kubernetes.operator.helm.MapUtils.loadIntegerFromMap; |
| 13 | + |
| 14 | +import java.util.HashMap; |
| 15 | +import java.util.Map; |
| 16 | +import oracle.kubernetes.operator.utils.DomainValues; |
| 17 | + |
| 18 | +class HelmDomainValues extends DomainValues { |
| 19 | + HelmDomainValues() {} |
| 20 | + |
| 21 | + HelmDomainValues(Map<String, Object> map) { |
| 22 | + loadFromMap(map, this::setAdminServerName, "adminServerName"); |
| 23 | + loadFromMap(map, this::setDomainName, "domainName"); |
| 24 | + loadFromMap(map, this::setDomainUID, "domainUID"); |
| 25 | + loadFromMap(map, this::setClusterName, "clusterName"); |
| 26 | + loadFromMap(map, this::setClusterType, "clusterType"); |
| 27 | + loadFromMap(map, this::setStartupControl, "startupControl"); |
| 28 | + loadFromMap(map, this::setManagedServerNameBase, "managedServerNameBase"); |
| 29 | + loadFromMap(map, this::setWeblogicImage, "weblogicImage"); |
| 30 | + loadFromMap(map, this::setWeblogicDomainStorageType, "weblogicDomainStorageType"); |
| 31 | + loadFromMap( |
| 32 | + map, this::setWeblogicDomainStorageReclaimPolicy, "weblogicDomainStorageReclaimPolicy"); |
| 33 | + loadFromMap(map, this::setWeblogicDomainStorageSize, "weblogicDomainStorageSize"); |
| 34 | + loadFromMap(map, this::setWeblogicCredentialsSecretName, "weblogicCredentialsSecretName"); |
| 35 | + loadFromMap(map, this::setT3PublicAddress, "t3PublicAddress"); |
| 36 | + loadFromMap(map, this::setNamespace, "namespace"); |
| 37 | + loadFromMap(map, this::setLoadBalancer, "loadBalancer"); |
| 38 | + loadFromMap(map, this::setLoadBalancerAppPrepath, "loadBalancerAppPrepath"); |
| 39 | + loadFromMap(map, this::setLoadBalancerVolumePath, "loadBalancerVolumePath"); |
| 40 | + loadFromMap(map, this::setJavaOptions, "javaOptions"); |
| 41 | + |
| 42 | + loadBooleanFromMap(map, this::setProductionModeEnabled, "productionModeEnabled"); |
| 43 | + loadBooleanFromMap(map, this::setExposeAdminT3Channel, "exposeAdminT3Channel"); |
| 44 | + loadBooleanFromMap(map, this::setExposeAdminNodePort, "exposeAdminNodePort"); |
| 45 | + loadBooleanFromMap(map, this::setLoadBalancerExposeAdminPort, "loadBalancerExposeAdminPort"); |
| 46 | + |
| 47 | + loadIntegerFromMap(map, this::setAdminPort, "adminPort"); |
| 48 | + loadIntegerFromMap(map, this::setConfiguredManagedServerCount, "configuredManagedServerCount"); |
| 49 | + loadIntegerFromMap(map, this::setInitialManagedServerReplicas, "initialManagedServerReplicas"); |
| 50 | + loadIntegerFromMap(map, this::setManagedServerPort, "managedServerPort"); |
| 51 | + loadIntegerFromMap(map, this::setT3ChannelPort, "t3ChannelPort"); |
| 52 | + loadIntegerFromMap(map, this::setAdminNodePort, "adminNodePort"); |
| 53 | + loadIntegerFromMap(map, this::setLoadBalancerWebPort, "loadBalancerWebPort"); |
| 54 | + loadIntegerFromMap(map, this::setLoadBalancerDashboardPort, "loadBalancerDashboardPort"); |
| 55 | + } |
| 56 | + |
| 57 | + private void setProductionModeEnabled(Boolean enabled) { |
| 58 | + if (enabled != null) { |
| 59 | + setProductionModeEnabled(enabled.toString()); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + private void setExposeAdminT3Channel(Boolean enabled) { |
| 64 | + if (enabled != null) { |
| 65 | + setExposeAdminT3Channel(enabled.toString()); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + private void setExposeAdminNodePort(Boolean enabled) { |
| 70 | + if (enabled != null) { |
| 71 | + setExposeAdminNodePort(enabled.toString()); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + private void setLoadBalancerExposeAdminPort(Boolean enabled) { |
| 76 | + if (enabled != null) { |
| 77 | + setLoadBalancerExposeAdminPort(enabled.toString()); |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + Map<String, Object> createMap() { |
| 82 | + HashMap<String, Object> map = new HashMap<>(); |
| 83 | + |
| 84 | + addStringMapEntry(map, this::getAdminServerName, "adminServerName"); |
| 85 | + addStringMapEntry(map, this::getDomainName, "domainName"); |
| 86 | + addStringMapEntry(map, this::getDomainUID, "domainUID"); |
| 87 | + addStringMapEntry(map, this::getClusterName, "clusterName"); |
| 88 | + addStringMapEntry(map, this::getClusterType, "clusterType"); |
| 89 | + addStringMapEntry(map, this::getStartupControl, "startupControl"); |
| 90 | + addStringMapEntry(map, this::getManagedServerNameBase, "managedServerNameBase"); |
| 91 | + addStringMapEntry(map, this::getWeblogicImage, "weblogicImage"); |
| 92 | + addStringMapEntry(map, this::getWeblogicDomainStorageType, "weblogicDomainStorageType"); |
| 93 | + addStringMapEntry( |
| 94 | + map, this::getWeblogicDomainStorageReclaimPolicy, "weblogicDomainStorageReclaimPolicy"); |
| 95 | + addStringMapEntry(map, this::getWeblogicDomainStorageSize, "weblogicDomainStorageSize"); |
| 96 | + addStringMapEntry(map, this::getWeblogicCredentialsSecretName, "weblogicCredentialsSecretName"); |
| 97 | + addStringMapEntry(map, this::getT3PublicAddress, "t3PublicAddress"); |
| 98 | + addStringMapEntry(map, this::getNamespace, "namespace"); |
| 99 | + addStringMapEntry(map, this::getLoadBalancer, "loadBalancer"); |
| 100 | + addStringMapEntry(map, this::getLoadBalancerAppPrepath, "loadBalancerAppPrepath"); |
| 101 | + addStringMapEntry(map, this::getLoadBalancerVolumePath, "loadBalancerVolumePath"); |
| 102 | + addStringMapEntry(map, this::getJavaOptions, "javaOptions"); |
| 103 | + |
| 104 | + addMapEntry(map, this::isProductionModeEnabled, "productionModeEnabled"); |
| 105 | + addMapEntry(map, this::isExposeAdminT3Channel, "exposeAdminT3Channel"); |
| 106 | + addMapEntry(map, this::isExposeAdminNodePort, "exposeAdminNodePort"); |
| 107 | + addMapEntry(map, this::isLoadBalancerExposeAdminPort, "loadBalancerExposeAdminPort"); |
| 108 | + |
| 109 | + addMapEntry(map, this::getAdminPortNum, "adminPort"); |
| 110 | + addMapEntry(map, this::getConfiguredManagedServerCountValue, "configuredManagedServerCount"); |
| 111 | + addMapEntry(map, this::getInitialManagedServerReplicasNum, "initialManagedServerReplicas"); |
| 112 | + addMapEntry(map, this::getManagedServerPortNum, "managedServerPort"); |
| 113 | + addMapEntry(map, this::getT3ChannelPortNum, "t3ChannelPort"); |
| 114 | + addMapEntry(map, this::getAdminNodePortNum, "adminNodePort"); |
| 115 | + addMapEntry(map, this::getLoadBalancerDashboardPortNum, "loadBalancerDashboardPort"); |
| 116 | + addMapEntry(map, this::getLoadBalancerWebPortNum, "loadBalancerWebPort"); |
| 117 | + |
| 118 | + return map; |
| 119 | + } |
| 120 | + |
| 121 | + private Boolean isProductionModeEnabled() { |
| 122 | + return MapUtils.valueOf(getProductionModeEnabled()); |
| 123 | + } |
| 124 | + |
| 125 | + private Boolean isExposeAdminT3Channel() { |
| 126 | + return MapUtils.valueOf(getExposeAdminT3Channel()); |
| 127 | + } |
| 128 | + |
| 129 | + private Boolean isExposeAdminNodePort() { |
| 130 | + return MapUtils.valueOf(getExposeAdminNodePort()); |
| 131 | + } |
| 132 | + |
| 133 | + private Boolean isLoadBalancerExposeAdminPort() { |
| 134 | + return MapUtils.valueOf(getLoadBalancerExposeAdminPort()); |
| 135 | + } |
| 136 | + |
| 137 | + private Integer getAdminPortNum() { |
| 138 | + return integerValue(getAdminPort()); |
| 139 | + } |
| 140 | + |
| 141 | + private Integer getConfiguredManagedServerCountValue() { |
| 142 | + return integerValue(getConfiguredManagedServerCount()); |
| 143 | + } |
| 144 | + |
| 145 | + private Integer getInitialManagedServerReplicasNum() { |
| 146 | + return integerValue(getInitialManagedServerReplicas()); |
| 147 | + } |
| 148 | + |
| 149 | + private Integer getManagedServerPortNum() { |
| 150 | + return integerValue(getManagedServerPort()); |
| 151 | + } |
| 152 | + |
| 153 | + private Integer getT3ChannelPortNum() { |
| 154 | + return integerValue(getT3ChannelPort()); |
| 155 | + } |
| 156 | + |
| 157 | + private Integer getAdminNodePortNum() { |
| 158 | + return integerValue(getAdminNodePort()); |
| 159 | + } |
| 160 | + |
| 161 | + private Integer getLoadBalancerWebPortNum() { |
| 162 | + return integerValue(getLoadBalancerWebPort()); |
| 163 | + } |
| 164 | + |
| 165 | + private Integer getLoadBalancerDashboardPortNum() { |
| 166 | + return integerValue(getLoadBalancerDashboardPort()); |
| 167 | + } |
| 168 | +} |
0 commit comments