#!/usr/bin/env bash # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # CHART_HOME=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/../.. && pwd) cd ${CHART_HOME} usage() { cat < /dev/null 2>&1 if [ $? -ne 0 ]; then echo "error: failed to get namespace '${namespace}'" echo "please check that this namespace exists, or use the '-c' option to create it" exit 1 fi extra_opts="" if [[ "${symmetric}" == "true" ]]; then extra_opts="${extra_opts} -s" fi if [[ "${local}" == "true" ]]; then extra_opts="${extra_opts} -l" fi echo "generate the token keys for the pulsar cluster" >&2 new_k8s_object ${CHART_HOME}/scripts/pulsar/generate_token_secret_key.sh -n ${namespace} -k ${release} ${extra_opts} echo "generate the tokens for the super-users: ${pulsar_superusers}" >&2 IFS=', ' read -r -a superusers <<< "$pulsar_superusers" for user in "${superusers[@]}" do echo "generate the token for $user" >&2 new_k8s_object ${CHART_HOME}/scripts/pulsar/generate_token.sh -n ${namespace} -k ${release} -r ${user} ${extra_opts} done echo "-------------------------------------" >&2 echo >&2 echo "The jwt token secret keys are generated under:" >&2 if [[ "${symmetric}" == "true" ]]; then echo " - '${release}-token-symmetric-key'" >&2 else echo " - '${release}-token-asymmetric-key'" >&2 fi echo >&2 echo "The jwt tokens for superusers are generated and stored as below:" >&2 for user in "${superusers[@]}" do echo " - '${user}':secret('${release}-token-${user}')" >&2 done echo >&2