Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break down cloud tool #451

Closed
spbnick opened this issue Mar 10, 2023 · 1 comment · Fixed by #488
Closed

Break down cloud tool #451

spbnick opened this issue Mar 10, 2023 · 1 comment · Fixed by #488

Comments

@spbnick
Copy link
Collaborator

spbnick commented Mar 10, 2023

The cloud tool's source code is a single file 2312 lines long, which is shameful, and makes it hard to read, navigate, and maintain.

Break it down into smaller modules (.sh include files). Put modules into the kcidb directory. Group functions and variables by prefix, and put them into correspondingly-named files. E.g. all functions and variables with prefix psql_/PSQL_ should go into a file named kcidb/psql.sh, and so on.

The original cloud file must add the directory it's located in in front of the PATH environment variable (following its syntax, i.e. using the : path separator), and then include the modules using the . (source) command. E.g. like this:

export PATH="$(dirname "$(realpath "$0")")/kcidb:$PATH"

. psql.sh

Each module file should start with a short description of its contents, and should have anti-recursive inclusion protection around its code and definitions. E.g. the kcidb/psql.sh file should have:

# PostgreSQL database deployment definitions and management

if [ -z "${_PSQL_SH+set}" ]; then
declare _PSQL_SH=

# Code and definitions go here

fi # _PSQL_SH

Various definitions reused by multiple files, that are too few for a separate module, should go into kcidb/misc.sh, but don't have to have a misc_ prefix added to their names.

@spbnick
Copy link
Collaborator Author

spbnick commented Aug 7, 2023

Ah, this is for kcidb, not kcidb-io.

@spbnick spbnick transferred this issue from kernelci/kcidb-io Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant