smolnar82 opened a new pull request #114: KNOX-1816 - Optionally added shellcheck validation to our build and fixed issues shellcheck already found URL: https://github.com/apache/knox/pull/114 ## What changes were proposed in this pull request? [Shellcheck](https://www.shellcheck.net/) is a very useful tool that helps developers to avoid common pitfalls with their bash scripts. The following changes were made: 1. optionally added shellcheck validation to knox build in these sub-projects: - gateway-release - gateway-release-common - gateway-shell-release To activate this feature the command should include `-Dshellcheck=true` (by default this is turned off). **Note:** since there is no official Maven plugin for shellcheck you need to install the tool manually first. According to its [Github readme](https://github.com/koalaman/shellcheck#travis-ci) Travis CI comes with built-in shellcheck so it should be safe to include that flag in our TravisCI build. 2. I fixed our shell scripts to conform shellcheck ## How was this patch tested? Built the project with and without the new flag (I made an error on purpose in some of the scripts to see if the build actually fails): ``` $ mvn -DskipTests -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Drat.skip -Dshellcheck=true -Ppackage,release package [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:29 min [INFO] Finished at: 2019-07-12T10:30:46+02:00 [INFO] Final Memory: 146M/1618M [INFO] ------------------------------------------------------------------------ ``` Additionally, I deployed Knox locally and tested if the scripts are working as expected: ``` ################ ## gateway.sh ## ################ $ bin/gateway.sh Usage: bin/gateway.sh {start|stop|status|clean} $ bin/gateway.sh status Gateway is running with PID 24139. $ bin/gateway.sh stop Stopping Gateway with PID 24139 succeeded. $ bin/gateway.sh stop Gateway is not running. $ bin/gateway.sh clean Removed the Gateway PID file. Removed the Gateway OUT file. Removed the Gateway ERR file. $ bin/gateway.sh start Starting Gateway succeeded with PID 24841. $ bin/gateway.sh start Gateway is already running with PID 24841. $ bin/gateway.sh clean Can't clean files. Gateway is running with PID 24841. $ bin/gateway.sh status Gateway is running with PID 24841. $ bin/gateway.sh stop Stopping Gateway with PID 24841 succeeded. ``` ``` ############# ## ldap.sh ## ############# $ bin/ldap.sh Usage: bin/ldap.sh {start|stop|status|clean} $ bin/ldap.sh status LDAP is not running. No PID file found. $ bin/ldap.sh stop LDAP is not running. $ bin/ldap.sh clean Removed the LDAP PID file. Removed the LDAP OUT file. Removed the LDAP ERR file. $ bin/ldap.sh start Starting LDAP succeeded with PID 25045. $ bin/ldap.sh start LDAP is already running with PID 25045. $ bin/ldap.sh clean Can't clean files. LDAP is running with PID 25045. $ bin/ldap.sh status LDAP is running with PID 25045. $ bin/ldap.sh stop Stopping LDAP with PID 25045 succeeded. $ bin/ldap.sh stop LDAP is not running. ``` ``` ################## ## knoxshell.sh ## ################## $ bin/knoxshell.sh help Apache Knox Client Shell The client shell facility provide a CLI for establishing and managing Apache Knox Sessions and executing the Apache Knox groovy-based DSL scripts. It may also be used to enter an interactive shell where groovy-based DSL and groovy code may be entered and executed in realtime. knoxshell usage: knoxshell.sh [[buildTrustStore <knox-gateway-url>|init <topology-url>|list|destroy|help] | [<script-file-name>]] ---------------------------------------------------------- buildTrustStore <knox-gateway-url> - downloads the given gateway server's public certificate and builds a trust store to be used by KnoxShell example: knoxshell.sh buildTrustStore https://localhost:8443/ init <topology-url> - requests a session from the knox token service at the url example: knoxshell.sh init https://localhost:8443/gateway/sandbox list - lists the details of the cached knox session token example: knoxshell.sh list destroy - removes the cached knox session token example: knoxshell.sh destroy <script-file-name> - executes the groovy script file example: knoxshell.sh ~/bin/ls.groovy $ bin/knoxshell.sh buildTrustStore https://localhost:8443 Opening connection to localhost:8443... Starting SSL handshake... Gateway server's certificate is exported into /Users/smolnar/gateway-client-trust.jks ``` ``` ################ ## knoxcli.sh ## ################ $ bin/knoxcli.sh KnoxCLI {cmd} [options] [--help] [version] [create-master [--force] [--master mastersecret] [--generate]] [create-cert [--force] [--hostname h]] [export-cert [--type PEM|JKS|JCEKS|PKCS12]] [create-alias aliasname [--cluster clustername] [ (--value v) | (--generate) ]] [delete-alias aliasname [--cluster clustername]] [list-alias [--cluster clustername]] [redeploy [--cluster clustername]] [list-topologies] [validate-topology [--cluster clustername] | [--path "path/to/file"]] [user-auth-test [--cluster clustername] [--u username] [--p password] [--g]] [system-user-auth-test [--cluster clustername] [--d]] [service-test [--u username] [--p password] [--cluster clustername] [--hostname name] [--port port]] [list-registry-clients] [list-provider-configs --registry-client name] [upload-provider-config providerConfigFile --registry-client name [--entry-name entryName]] [list-descriptors --registry-client name] [upload-descriptor descriptorFile --registry-client name [--entry-name entryName]] [delete-provider-config providerConfig --registry-client name] [delete-descriptor descriptor --registry-client name] [get-registry-acl entry --registry-client name] =============================================================================== version Displays Knox version information. =============================================================================== create-master [--force] [--master mastersecret] [--generate] ... =============================================================================== delete-descriptor descriptor --registry-client name Deletes a simple descriptor from the specified remote registry. =============================================================================== $ bin/knoxcli.sh version Apache Knox: 1.4.0-SNAPSHOT (77f0c515a9948b860668b6efea16d6879e166a78) ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
