diff --git a/scripts/prepare b/scripts/prepare index f4fecc128..fc325fa42 100755 --- a/scripts/prepare +++ b/scripts/prepare @@ -39,38 +39,34 @@ for f in packages/*; do if [[ "${split_crds}" == "true" ]]; then ./scripts/prepare-crds ${f} fi - copied_dependencies=() - if [[ -f ${f}/charts/requirements.yaml ]]; then - repos=$(cat ${f}/charts/requirements.yaml | yq r - "dependencies.*.repository") - while IFS= read -r repo; do - if [[ ${repo} == file://* ]]; then - charts_path=${repo/file:\/\//${f}/charts/} - overlay_path=${repo/file:\/\//${f}/overlay/} - if [[ ! -d $charts_path ]] && [[ -d $overlay_path ]]; then - cp -R $overlay_path $charts_path - copied_dependencies+=("${charts_path}") - fi - fi - done < <(echo "${repos}") - fi - pwd=$(pwd) - cd ${f}/charts - helm dependency update - cd $pwd - for dep in "${copied_dependencies[@]}"; do - rm -rf $dep - done fi fi done -# if any sub-charts were prepared pull them in +# Loop through packages again and copy dependencies over +# If sub-charts existed as package.yaml they will now be vendored into parent for f in packages/*; do - if [[ ! -f ${f}/package.yaml && -f ${f}/charts/requirements.yaml ]]; then - ls ${f}/charts/requirements.yaml + if [[ -z $CHART || $CHART == $(basename -- ${f}) ]]; then + copied_dependencies=() + if [[ -f ${f}/charts/requirements.yaml ]]; then + repos=$(cat ${f}/charts/requirements.yaml | yq r - "dependencies.*.repository") + while IFS= read -r repo; do + if [[ ${repo} == file://* ]]; then + charts_path=${repo/file:\/\//${f}/charts/} + overlay_path=${repo/file:\/\//${f}/overlay/} + if [[ ! -d $charts_path ]] && [[ -d $overlay_path ]]; then + cp -R $overlay_path $charts_path + copied_dependencies+=("${charts_path}") + fi + fi + done < <(echo "${repos}") + fi pwd=$(pwd) cd ${f}/charts helm dependency update cd $pwd + for dep in "${copied_dependencies[@]}"; do + rm -rf $dep + done fi done diff --git a/scripts/prepare-crds b/scripts/prepare-crds index 9009561d7..9383de234 100755 --- a/scripts/prepare-crds +++ b/scripts/prepare-crds @@ -50,7 +50,7 @@ for crd_yaml in ${f}/charts-crd/templates/*; do crd_group=$(yq r ${crd_yaml} 'spec.group') crd_kind=$(yq r ${crd_yaml} 'spec.names.kind') crd_version=$(yq r ${crd_yaml} 'spec.version') - if test -z "$crd_version"; then + if [[ -z "$crd_version" ]]; then crd_version=$(yq r ${crd_yaml} 'spec.versions[0].name') fi crd_apis+=("${crd_group}/${crd_version}/${crd_kind}")