Skip to content

Commit

Permalink
chore: added a mechanism to have specific syntax per OS on custom logic
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo committed Apr 15, 2024
1 parent 92ee60a commit 0dada37
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 4 deletions.
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 <[email protected]>"

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"
}

0 comments on commit 0dada37

Please sign in to comment.