Skip to content

Commit

Permalink
Adds build script & info about building the client
Browse files Browse the repository at this point in the history
  • Loading branch information
telday committed May 6, 2021
1 parent 91e4272 commit 5a38998
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# org the new repo will be in. GitHub automatically applies the correct version.

# Uncomment the appropriate team line to automatically tag the owning team on PRs
# * @cyberark/community-and-integrations-team @conjurinc/community-and-integrations-team @conjurdemos/community-and-integrations-team
# * @cyberark/conjur-core-team @conjurinc/conjur-core-team @conjurdemos/conjur-core-team
* @cyberark/community-and-integrations-team @conjurinc/community-and-integrations-team @conjurdemos/community-and-integrations-team

# Changes to .trivyignore require Security Architect approval
.trivyignore @cyberark/security-architects @conjurinc/security-architects @conjurdemos/security-architects
Expand Down
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/new-project.md

This file was deleted.

29 changes: 0 additions & 29 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ section when releasing the client after a refresh.
* Stands up a new instance of Conjur in a Docker environment, compiles the
client, and runs the tests with Maven.

`bin/build`
* Used to compile & build a jar archive for the client.
* Outputs the compiled version to `client/target`

`bin/refresh_client`
* Used to update the client with new changes to the OpenAPI Specification.
* Pulls down the latest version of the spec and regenerates the client.
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Conjur Generated Java Client
An API client for Conjur written in Java and generated by the [OpenApi](https://github.com/cyberark/conjur-openapi-spec) specification

Find [more from CyberArk](https://github.com/cyberark).

## Certification level

{Community}
![](https://img.shields.io/badge/Certification%20Level-Community-28A745?link=https://github.com/cyberark/community/blob/master/Conjur/conventions/certification-levels.md)

This repo is a **Community** level project. It's a community contributed project that **is not reviewed or supported
Expand All @@ -23,11 +24,6 @@ its own version allows changes to be made to the client outside of updates to th
| :-----------------: | :----------------: |
| 1.x.x | 5.1.1 |

## Usage instructions

TODO: add details for how to use your project. Examples can be quite nice here. You should have
a high level overview of the benefit of your project and its main use cases.

## Contributing

We welcome contributions of all kinds to this repository. For instructions on how to get started and descriptions
Expand Down
10 changes: 10 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

# Run from top-level dir
cd "$(dirname "$0")/.." || (echo "Could not cd to parent dir"; exit 1)
source bin/util

./bin/test_integration $@ --jar

announce "Output available in ./client/target"
6 changes: 4 additions & 2 deletions bin/get_conjur_admin_key
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env bash

# Run from top-level dir
cd "$(dirname "$0")/.." || (echo "Could not cd to parent dir"; exit 1)
source ./bin/util

admin_api_key=$(get_conjur_admin_api_key)
export CONJUR_AUTHN_API_KEY=$admin_api_key
admin_api_key="$(get_conjur_admin_api_key)"
export CONJUR_AUTHN_API_KEY="$admin_api_key"

echo "Conjur admin api key $admin_api_key"

Expand Down
6 changes: 5 additions & 1 deletion bin/refresh_client
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/env bash
set -e

# Run from top-level dir
cd "$(dirname "$0")/.." || (echo "Could not cd to parent dir"; exit 1)

source bin/util
mkdir -p client

generator_version="v4.3.1"
GENERATOR_IMAGE="openapitools/openapi-generator-cli:$generator_version"

git clone -b java-secrets-test https://github.com/cyberark/conjur-openapi-spec.git
git clone https://github.com/cyberark/conjur-openapi-spec.git
pushd conjur-openapi-spec

./bin/transform --oss
Expand Down
3 changes: 3 additions & 0 deletions bin/start_conjur
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

# Run from top-level dir
cd "$(dirname "$0")/.." || (echo "Could not cd to parent dir"; exit 1)

cleanup() {
echo "Cleaning up..."
docker-compose rm --stop --force -v
Expand Down
43 changes: 28 additions & 15 deletions bin/test_integration
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/usr/bin/env bash
set -e

# Run from top-level dir
cd "$(dirname "$0")/.." || (echo "Could not cd to parent dir"; exit 1)

source bin/util

no_regen_client=0
no_rebuild_conjur=0
regen_client=true
rebuild_conjur=true
major_java_version=8
install=""

if [ "$(tty)" == "not a tty" ]; then
copy_prefix="sudo"
Expand All @@ -24,13 +30,13 @@ setup_keycloak(){
docker-compose exec -T conjur bash -c "/policy/oidc/fetchCertificate"
}

conjur_container_alive(){
conjur_container_down(){
if [ -z `docker-compose ps -q conjur` ]; then
echo 1
true
elif [ -z `docker ps -q --no-trunc | grep $(docker-compose ps -q conjur)` ]; then
echo 1
true
else
echo 0
false
fi
}

Expand All @@ -47,18 +53,18 @@ print_help(){
echo -e "\tThe --no-regen-client flag will prevent the client from re-generating before tests run"
echo
echo -e "\tThe -d flag will turn on debug mode for the integration test runs"
echo
echo -e "\tThe --jar flag will test then build the project outputing to client/target"
echo
echo -e "\tThe -j or --java-version flag allows you yo specify a specific java version used to compile/test the project"
}

run_java_tests(){
if [ $no_regen_client -eq 0 ]; then
if [ "$regen_client" = true ]; then
announce "Generating Java Client"
bin/refresh_client -l java
fi

# Overwrite the autogenerated tests with the manually written tests
#$copy_prefix rm -rf ./client/src/test/java/org/conjur/sdk/**/*
#$copy_prefix cp -r ./test/integration/* ./client/src/test/java/org/conjur/sdk/api

docker run --rm --network conjur-sdk-java \
-v ${PWD}/client:/client \
-v ${PWD}/test/config:/config \
Expand All @@ -70,7 +76,7 @@ run_java_tests(){
-e CONJUR_CERT_FILE=/https/ca.crt \
--env-file .env \
-w /client \
maven:3-openjdk-15 bash -c "mvn test"
maven:3-openjdk-$major_java_version bash -c "mvn test $install"
}

while test $# -gt 0
Expand All @@ -86,18 +92,25 @@ do
exit 0
;;
--no-rebuild-conjur)
no_rebuild_conjur=1
rebuild_conjur=false
;;
--no-regen-client)
no_regen_client=1
regen_client=false
;;
-j|--java-version)
major_java_version=$1
shift
;;
--jar)
install="install"
;;
*)
break
;;
esac
done

if [ $no_rebuild_conjur -eq 0 ] || [ "$(conjur_container_alive)" = "1" ]; then
if [ "$rebuild_conjur" = true ] || conjur_container_down; then
announce "Starting Conjur Container"
bin/start_conjur
fi
Expand Down
4 changes: 2 additions & 2 deletions bin/util
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function get_banner(){
}

function announce() {
banner=$(get_banner $@)
banner="$(get_banner $@)"
echo -e "\e[0;32m$banner"
echo -e "$@"
echo -e "$banner\e[m"
}

function get_conjur_admin_api_key(){
admin_api_key=$(docker-compose exec -T conjur conjurctl role retrieve-key dev:user:admin | tr -d '\r')
admin_api_key="$(docker-compose exec -T conjur conjurctl role retrieve-key dev:user:admin | tr -d '\r')"
echo $admin_api_key
}

0 comments on commit 5a38998

Please sign in to comment.