Skip to content

Commit 12d77c9

Browse files
committed
More cleanup
Signed-off-by: doxiao <[email protected]>
1 parent df3d8ed commit 12d77c9

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

kubernetes/samples/scripts/create-weblogic-domain/create-weblogic-credentials.sh

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,48 +73,24 @@ if [ "${missingRequiredOption}" == "true" ]; then
7373
usage 1
7474
fi
7575

76-
#
77-
# Function to validate the domain secret
78-
#
79-
function validateDomainSecret {
80-
# Verify the secret exists
81-
local SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'`
82-
if [ "${SECRET}" != "1" ]; then
83-
fail "The secret ${secretName} was not found in namespace ${namespace}"
84-
fi
85-
86-
# Verify the secret contains a username
87-
SECRET=`kubectl get secret ${secretName} -n ${namespace} -o jsonpath='{.data}'| grep username: | wc | awk ' { print $1; }'`
88-
if [ "${SECRET}" != "1" ]; then
89-
fail "The domain secret ${secretName} in namespace ${namespace} does contain a username"
90-
fi
91-
92-
# Verify the secret contains a password
93-
SECRET=`kubectl get secret ${secretName} -n ${namespace} -o jsonpath='{.data}'| grep password: | wc | awk ' { print $1; }'`
94-
if [ "${SECRET}" != "1" ]; then
95-
fail "The domain secret ${secretName} in namespace ${namespace} does contain a password"
96-
fi
97-
echo "The secret ${secretName} has been successfully created in namespace ${namespace}"
98-
}
99-
100-
#
101-
# Perform the following sequence of steps to create a domain
102-
#
103-
76+
# check and see if the secret already exists
10477
result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'`
10578
if [ "${result:=Error}" != "0" ]; then
10679
fail "The secret ${secretName} already exists in namespace ${namespace}."
10780
fi
10881

82+
# create the secret
10983
kubectl -n $namespace create secret generic $secretName \
11084
--from-literal=username=$username \
11185
--from-literal=password=$password
11286

87+
# label the secret with domainUID
11388
kubectl label secret ${secretName} -n $namespace weblogic.domainUID=$domainUID weblogic.domainName=$domainUID
11489

115-
validateDomainSecret
116-
117-
echo
118-
echo Completed
119-
90+
# Verify the secret exists
91+
SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'`
92+
if [ "${SECRET}" != "1" ]; then
93+
fail "The secret ${secretName} was not found in namespace ${namespace}"
94+
fi
12095

96+
echo "The secret ${secretName} has been successfully created in namespace ${namespace}"

0 commit comments

Comments
 (0)