2525__logger = PlatformLogger ('wlsdeploy.tool.util' )
2626
2727# substitution keys used in the templates
28+ ADDITIONAL_SECRET_NAME = 'additionalSecretName'
29+ ADDITIONAL_SECRETS = 'additionalSecrets'
2830CLUSTER_NAME = 'clusterName'
2931CLUSTERS = 'clusters'
3032DATABASE_CREDENTIALS = 'databaseCredentials'
3638DOMAIN_TYPE = 'domainType'
3739DOMAIN_UID = 'domainUid'
3840DS_URL = 'url'
41+ HAS_ADDITIONAL_SECRETS = 'hasAdditionalSecrets'
3942HAS_CLUSTERS = 'hasClusters'
4043HAS_DATABASES = 'hasDatabases'
4144REPLICAS = 'replicas'
4245WEBLOGIC_CREDENTIALS_SECRET = 'webLogicCredentialsSecret'
4346
4447
45- def create_additional_output (model , model_context , aliases , exception_type ):
48+ def create_additional_output (model , model_context , aliases , credential_injector , exception_type ):
4649 """
4750 Create and write additional output for the configured target type.
4851 :param model: Model object, used to derive some values in the output
4952 :param model_context: used to determine location and content for the output
5053 :param aliases: used to derive secret names
54+ :param credential_injector: used to identify secrets
5155 :param exception_type: the type of exception to throw if needed
5256 """
5357
5458 # -output_dir argument was previously verified
5559 output_dir = model_context .get_output_dir ()
5660
5761 # all current output types use this hash, and process a set of template files
58- template_hash = _build_template_hash (model , model_context , aliases )
62+ template_hash = _build_template_hash (model , model_context , aliases , credential_injector )
5963
6064 file_names = model_context .get_target_configuration ().get_additional_output_types ()
6165 for file_name in file_names :
@@ -84,12 +88,13 @@ def _create_file(template_name, template_hash, model_context, output_dir, except
8488 file_template_helper .create_file_from_file (template_path , template_hash , output_file , exception_type )
8589
8690
87- def _build_template_hash (model , model_context , aliases ):
91+ def _build_template_hash (model , model_context , aliases , credential_injector ):
8892 """
8993 Create a dictionary of substitution values to apply to the templates.
9094 :param model: Model object used to derive values
9195 :param model_context: used to determine domain type
9296 :param aliases: used to derive folder names
97+ :param credential_injector: used to identify secrets
9398 :return: the hash dictionary
9499 """
95100 template_hash = dict ()
@@ -107,9 +112,13 @@ def _build_template_hash(model, model_context, aliases):
107112 template_hash [DOMAIN_NAME ] = domain_uid
108113 template_hash [DOMAIN_PREFIX ] = domain_uid
109114
115+ # secrets that should not be included in secrets section
116+ declared_secrets = []
117+
110118 # admin credential
111119
112120 admin_secret = domain_uid + target_configuration_helper .WEBLOGIC_CREDENTIALS_SECRET_SUFFIX
121+ declared_secrets .append (admin_secret )
113122 template_hash [WEBLOGIC_CREDENTIALS_SECRET ] = admin_secret
114123
115124 # configuration / model
@@ -165,4 +174,26 @@ def _build_template_hash(model, model_context, aliases):
165174 template_hash [DATABASES ] = databases
166175 template_hash [HAS_DATABASES ] = len (databases ) != 0
167176
177+ # additional secrets - exclude admin
178+
179+ additional_secrets = []
180+
181+ # combine user/password properties to get a single list
182+ secrets = []
183+ for property_name in credential_injector .get_variable_cache ():
184+ halves = property_name .split (':' , 1 )
185+ name = halves [0 ]
186+ if name not in secrets :
187+ secrets .append (name )
188+
189+ for secret in secrets :
190+ secrets_hash = dict ()
191+ qualified_name = domain_uid + "-" + secret
192+ if qualified_name not in declared_secrets :
193+ secrets_hash [ADDITIONAL_SECRET_NAME ] = qualified_name
194+ additional_secrets .append (secrets_hash )
195+
196+ template_hash [ADDITIONAL_SECRETS ] = additional_secrets
197+ template_hash [HAS_ADDITIONAL_SECRETS ] = len (additional_secrets ) != 0
198+
168199 return template_hash
0 commit comments