Introductory blog post: https://www.conjur.org/blog/stop-bashing-bash/
_______________ _______________
.' .' .|
.' .' .' |
.'_______________.'______________ .' |
| ___ _____ ___ || ___ _____ ___ | |
||_=_|__=__|_=_||||_=_|__=__|_=_|| |
______||_____===_____||||_____===_____|| | __________
.' ||_____===_____||||_____===_____|| .' .'|
.' ||_____===_____||||_____===_____|| .' .' |
.'___________|_______________||_______________|.'__________.' |
|.----------.|.-----___-----.||.-----___-----.|| |_____.----------.
|] |||_____________||||_____________||| .' [ |
|| ||.-----___-----.||.-----___-----.||.' | |
|| |||_____________||||_____________|||==========| |
|| ||.-----___-----.||.-----___-----.|| |_____| |
|] o|||_____________||||_____________||| .' [ 'o|
|| ||.-----___-----.||.-----___-----.||.' | |
|| ||| ||||_____________|||==========| |
|| ||| |||.-----___-----.|| |_____| |
|] ||| |||| ||| .' [ |
||__________|||_____________||||_____________|||.'________|__________|
''----------'''------------------------------'''----------''
(o)LGB (o)
The place to store functions that are used in pipelines for multiple repos.
Please add whatever is useful to you, but keep it tidy so its still useful to everyone else :)
TL;DR: Ready for use, but needs expansion.
The functions in this repo are tested and ready for use, but certain libs are pretty much place holders (eg logging). Those need further contributions before they provide a comprehensive solution.
See the license file
Add bash-lib into your project in the way that best fits your workflow. The only requirement is that you pin the version of bash-lib that you use. This is important so that changes to bash-lib do not have the power to break all projects that use bash-lib. Your project can then test updates to bash-lib and roll forward periodically.
Options:
Once you have bash-lib cloned in your project, you source two things:
bash-lib/init
. This ensures submodules are initalised and sets the BASH_LIB_DIR env var to the absolute path to the bash-lib dir. This makes it easy to source libraries from other scripts.${BASH_LIB_DIR}/lib-name/lib
for any libraries you are interested in.You are now ready to use bash-lib functions :)
The /init
script sets up everything required to use the library, most
importantly the BASH_LIB_DIR
variable which gives the absolute path to the root
of the library and should be used for sourcing the modules.
The repo is organized into libraries, each library is a directory that has a lib file. Sourcing the lib for a library should expose all the functions that library offers. The lib file may source or reference other supporting files within it's directory.
.
├── libname
│ ├── lib
│ └── supporting-file
├── init # init script, source this first
├── run-tests # top level test script, executes all tests
├── secrets.yml # secrets required for executing tests
├── test-utils
│ ├── bats # git subtree
│ ├── bats-assert-1 # git subtree
│ ├── bats-support # git subtree
│ ├── lib
│ └── tap2junit
└── tests-for-this-repo
├── filehandling.bats
├── fixtures #
│ └── libname # Dir containing test fixtures for a library
├── tap2junit
├── libname.bats # contains tests for libname/lib
├── python-lint # supporting files for python lint
├── run-bats-tests # script to run bats tests
├── run-gitleaks # script to check for leaked secrets
└── run-python-lint # script to run python lint
Library | Description | Functions |
---|---|---|
filehandling | Functions relating to file and path handling |
|
git | Git helpers |
|
github | Github Related Functions |
|
helpers | Bash scripting helpers |
|
k8s | Utils for connecting to K8s |
|
logging | Helpers related to logging. |
|
Ruby | Helpers related to ruby infrastructure |
|
test-utils | Helpers for executing tests |
|
For further information on contributing, style & testing, please see CONTRIBUTING.md