Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Helm] Add logic to define BUILD_PATH based on '_service' file #945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion build-recipe-helm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ recipe_prepare_helm() {
}

recipe_build_helm() {
BUILD_PATH=
if [ -d "$BUILD_ROOT/$TOPDIR/BUILD/_service" ]; then
# get the packaging file name
FILENAME=$(cat $BUILD_ROOT/$TOPDIR/BUILD/_service | xmllint --xpath 'string(//param[@name="filename"])' -)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can not create a check that _service is a directory and afterwards reading it as an XML file.

also the "cat" command is quite pointless, you could add the file name to xmllint directly.

But what worries me most is that there should not be a source file in the BUILD directory at all, no?

# get specified path
EXTRACT=$(cat $BUILD_ROOT/$TOPDIR/BUILD/_service| xmllint --xpath 'string(//param[@name="extract"])' -)
# define $BUILD_PATH
if [ -z "$EXTRACT" ]; then
BUILD_PATH="$FILENAME/"
else
BUILD_PATH="$FILENAME/$(dirname "$EXTRACT")"
fi
fi
cd "$BUILD_ROOT$TOPDIR/BUILD"
mkdir -p "$BUILD_ROOT$TOPDIR/HELM"
chown "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR/HELM"
Expand All @@ -73,7 +86,7 @@ recipe_build_helm() {
# avoid packaging sources services and changes files (also include content from _helmignore)
chroot $BUILD_ROOT su -c "(cd $TOPDIR/BUILD; [ -f _helmignore ] && mv -f _helmignore .helmignore; echo -e '/*.changes\n/_*\n' >> .helmignore; )" - $BUILD_USER || cleanup_and_exit 1
# create chart
chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && helm package -d $TOPDIR/HELM ." - $BUILD_USER || cleanup_and_exit 1
chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD/$BUILD_PATH && helm package -d $TOPDIR/HELM ." - $BUILD_USER || cleanup_and_exit 1
test -f "$BUILD_ROOT$TOPDIR/HELM/$nameversion.tgz" || cleanup_and_exit 1 "helm package command did not create $nameversion.tgz"
# extract generated Chart.yaml file
tar -xOf "$BUILD_ROOT$TOPDIR/HELM/$nameversion.tgz" -- "$name/Chart.yaml" > "$BUILD_ROOT$TOPDIR/HELM/Chart.yaml"
Expand Down