Skip to content

Commit

Permalink
Allow deployment of stable Conjur version
Browse files Browse the repository at this point in the history
  • Loading branch information
john-odonnell committed Dec 10, 2021
1 parent 6430257 commit 59cccf2
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api_contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: actions/checkout@v2

- name: run api contract test script
run: ./bin/test_api_contract
run: ./bin/test_api_contract -g
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v2

- name: run integration test script
run: ./bin/test_integration -l python
run: ./bin/test_integration -g -l python

dot-net:
runs-on: ubuntu-latest
Expand All @@ -26,4 +26,4 @@ jobs:
uses: actions/checkout@v2

- name: run integration test script
run: ./bin/test_integration -l csharp-netcore
run: ./bin/test_integration -g -l csharp-netcore
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
stage('Enterprise Integration Tests') {
steps {
script {
sh "./bin/test_integration -e -l python"
sh "./bin/test_integration -e -g -l python"
}
}
}
Expand All @@ -21,7 +21,7 @@ pipeline {
steps {
script {
ccCoverage.dockerPrep()
sh './bin/test_integration -l python'
sh './bin/test_integration -g -l python'
}
}

Expand Down
2 changes: 1 addition & 1 deletion bin/generate_postman_collection
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cmd="python3 examples/postman/postman_env_setup.py"
arg=""

if [[ local_env -eq 1 ]]; then
ensure_conjur_up
ensure_conjur_up latest

export CONJUR_AUTHN_API_KEY="$(docker-compose exec conjur conjurctl role retrieve-key dev:user:admin | tr -d '\r')"

Expand Down
36 changes: 36 additions & 0 deletions bin/start_conjur
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
#!/usr/bin/env bash
source bin/util

print_help() {
cat << EOF
This script starts Conjur Open Source in a docker-compose environment.
USAGE
./bin/start_conjur [options]
OPTIONS
-h|--help Print help message.
-e|--edge Start the edge version of Conjur Open Source, which represents
the most recent, unreleased version of Conjur.
By default, the latest stable version of Conjur is used.
EOF
}

conjur_tag=""

while test $# -gt 0
do
param=$1
shift
case "$param" in
-h|--help)
print_help
exit 0
;;
-s|--stable)
conjur_tag="edge"
;;
*)
break
;;
esac
done

cleanup() {
echo "Cleaning up..."
docker-compose rm --stop --force -v
Expand All @@ -23,6 +58,7 @@ echo "Building services..."
docker-compose build pg conjur conjur-https

# Start Conjur server
export CONJUR_OPEN_SOURCE_IMAGE_TAG="${conjur_tag:-$CONJUR_OPEN_SOURCE_IMAGE_TAG}"
echo "Starting Conjur..."
docker-compose up -d conjur conjur-https
docker-compose exec -T conjur conjurctl wait
7 changes: 7 additions & 0 deletions bin/test_api_contract
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
source bin/util

endpoint_flag=""
conjur_tag="latest"

while test $# -gt 0; do
case "$1" in
Expand All @@ -16,6 +17,7 @@ while test $# -gt 0; do
echo
echo "-h, --help show help"
echo "-e, --endpoint <path> test endpoints starting with the given path"
echo "-g, --edge test against the edge version of Conjur Open Source"
exit 0
;;
-e|--endpoint)
Expand All @@ -27,6 +29,10 @@ while test $# -gt 0; do
fi
shift
;;
-g|--edge)
conjur_tag="edge"
shift
;;
*)
break
;;
Expand All @@ -35,6 +41,7 @@ done

if [[ -z "$(docker-compose ps -q)" ]]; then
announce "Environment not found. Spinning up..."
export CONJUR_OPEN_SOURCE_IMAGE_TAG="$conjur_tag"
./bin/start_conjur 1> /dev/null
echo
fi
Expand Down
13 changes: 10 additions & 3 deletions bin/test_integration
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ OPTIONS
This option does not maintaing Conjur Enterprise.
WARNING: may cause failing test cases.
--no-regen-client Prevent the script from re-generating the client library.
-g|--edge Runs tests against the edge version of Conjur Open Source.
WARNING: may cause failing test cases.
-t|--test <test> Runs a given test in a client test suite.
EOF
}
Expand All @@ -42,6 +44,7 @@ enterprise=0
appliance="oss"
enterprise_params=""
docker_network="openapi-spec"
conjur_open_source_tag="latest"

no_regen_client=0
no_rebuid_conjur=0
Expand Down Expand Up @@ -87,6 +90,9 @@ do
--no-regen-client)
no_regen_client=1
;;
-g|--edge)
conjur_open_source_tag="edge"
;;
-t|--test)
test="$1"
shift
Expand Down Expand Up @@ -197,11 +203,12 @@ if [[ $no_rebuild_conjur -eq 0 ||
( $(conjur_alive) -eq 1 && $enterprise -eq 0 ) ||
( $(enterprise_alive) -eq 1 && $enterprise -eq 1 ) ]]; then
if [[ $enterprise -eq 0 ]]; then
announce "Starting Conjur OSS"
bin/start_conjur
announce "Starting Conjur OSS"
export CONJUR_OPEN_SOURCE_IMAGE_TAG="$conjur_open_source_tag"
bin/start_conjur
else
announce "Starting Conjur Enterprise"
bin/start_enterprise
bin/start_enterprise

pushd ./test/dap-intro
# Create the parameter to import volumes from the Enterprise container so we have its certificates
Expand Down
12 changes: 11 additions & 1 deletion bin/util
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ function ensure_client_is_generated(){
}

function ensure_conjur_up(){
desired_tag="$1"
export CONJUR_OPEN_SOURCE_IMAGE_TAG="$desired_tag"
if [ -z $(docker-compose ps -q conjur) ]; then
announce "Starting Conjur container"
./bin/start_conjur
else
announce "Conjur already up!"
docker ps | grep openapi | grep cyberark/conjur | grep $desired_tag &> /dev/null
desired_tag_deployed="$?"
if [[ "$desired_tag_deployed" == "0" ]]; then
announce "Conjur already up!"
else
announce "Conjur not deployed with tag $desired_tag. Re-deploying..."
./bin/stop
./bin/start_conjur
fi
fi
}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
POSTGRES_HOST_AUTH_METHOD: trust

conjur:
image: cyberark/conjur:edge
image: cyberark/conjur:${CONJUR_OPEN_SOURCE_IMAGE_TAG:-latest}
command: server -a dev -f /policy/policy.yaml
environment:
CONJUR_DATA_KEY: 'OyXV68Mip14xj33huGaQKewmmS+gKtDlp6ECZ2iATpU='
Expand Down
2 changes: 1 addition & 1 deletion examples/kong/start
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fi

announce "Making requests to Conjur through Kong Gateway"

ensure_conjur_up
ensure_conjur_up latest
sleep 10

admin_api_key="$(docker-compose exec -T conjur conjurctl role retrieve-key dev:user:admin | tr -d '\r')"
Expand Down
4 changes: 2 additions & 2 deletions examples/python/start
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

source ./bin/util

ensure_client_is_generated python conjur
ensure_conjur_up
ensure_client_is_generated python oss
ensure_conjur_up latest

export CONJUR_ADMIN_API_KEY=$(get_conjur_admin_api_key)

Expand Down
4 changes: 2 additions & 2 deletions examples/ruby/start
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

source ./bin/util

ensure_client_is_generated ruby conjur
ensure_conjur_up
ensure_client_is_generated ruby oss
ensure_conjur_up latest

# Remove the gem if it is already built so we dont create a gemfile
# which contains itself when we build
Expand Down

0 comments on commit 59cccf2

Please sign in to comment.