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

chore: added a mechanism to have specific syntax per OS on custom logic #36

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ LABEL org.opencontainers.image.authors="Adrian Riobo <ariobolo@redhat.com>"

RUN microdnf install -y openssh-clients sshpass zip jq

COPY lib/* entrypoint.sh /usr/local/bin/
COPY lib/common/* lib/os/ entrypoint.sh /usr/local/bin/

ENTRYPOINT ["entrypoint.sh"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION ?= 0.0.5
VERSION ?= 0.0.6
CONTAINER_MANAGER ?= podman
IMG ?= quay.io/rhqp/deliverest:v${VERSION}

Expand Down
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

# Import libs
source remote.sh
source /usr/local/bin/remote.sh
source /usr/local/bin/${OS}/os.sh

# Default values
TARGET_CLEANUP="${TARGET_CLEANUP:-"true"}"
Expand Down Expand Up @@ -57,5 +58,7 @@ if [[ ! -z "${TARGET_RESULTS+x}" ]]; then
fi

if [ "${TARGET_CLEANUP:-}" = "true" ]; then
$(ssh_cmd "rm -r ${TARGET_FOLDER}")
# This will create the cmd based on OS env with the right syntax
cmd="$(remove_folder ${TARGET_FOLDER})"
$(ssh_cmd ${cmd})
fi
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions lib/os/darwin/os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# This lib includes common functions with specific syntax for darwin

# #1 folder name to be removed
remove_folder () {
echo "rm -r ${1}"
}
8 changes: 8 additions & 0 deletions lib/os/linux/os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# This lib includes common functions with specific syntax for linux

# #1 folder name to be removed
remove_folder () {
echo "rm -r ${1}"
}
4 changes: 4 additions & 0 deletions lib/os/os
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file represents the interface os should comply with

# This will return syntax remove a folder
remove_folder($1 folder name) string
9 changes: 9 additions & 0 deletions lib/os/windows/os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# This lib includes common functions with specific syntax for windows

# #1 folder name to be removed
remove_folder () {
echo "Remove-Item \"${1}\" -Recurse -Force"
}