blob: 3c43d80588dc03cf41bdf05086f2ef8530fd1be9 [file] [log] [blame]
Luca Prete8ae13c22018-11-06 16:06:58 -08001#!/usr/bin/env bash
2
3# Copyright 2018-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy
7# of the License at:
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17# copy-ssh-keys.sh - Adds ssh keys to nodes given as parameters to the script,
18# after removing them from the ~/.ssh/known_hosts file on the local system.
19#
20# This script should be run interactively as it will prompt for input, and only
21# invoked once, so as not to add multiple copies of the SSH key to the remote
22# system.
23
24#############################################################
25# #
26# Returns a list of images given a list of helm charts #
27# #
28#############################################################
29
30output=""
31for chart in "$@";
32do
Luca Pretea0ddeda2018-12-19 15:56:52 -080033
34 if [[ "${chart}" =~ "etcd-cluster" ]]; then
Luca Prete8ae13c22018-11-06 16:06:58 -080035 # shellcheck disable=SC1117
36 output+=$(helm template "${chart}" | grep "busyboxImage:\|version:\|repository:" | sed 's/busyboxImage://g' | sed 's/version://g'| sed 's/repository://g' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d \" | awk '(NR%2){print$0p}{p=":"$0}')
37 # shellcheck disable=SC1117
38 output+="\n"
39 else
40 output+=$(helm template "${chart}" | grep "image:" | sed 's/image://g' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d \")
41 # shellcheck disable=SC1117
42 output+="\n"
43 fi
44done
45
46echo -e "${output}" | sort | uniq | sed '/^\s*$/d'