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

Helm module refactors #6

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

rafal-lal
Copy link
Collaborator

UNTESTED

  • Restructure logging:

    • Add scopes with .for() method
    • Change .info logs to be informative feedback as to what is happening
    • Scope logs to .info and .debug categories more accurately
    • Delete many lines of unnecessary .info and .debug logs
    • Completely delete developer logs like random arguments or words
  • Change signatures of methods corresponding to helm operations (pull,
    install...) from accepting cli strings to accepting arguments (from
    which cli commands are built).

    Helm module has a place in this codebase as layer of abstraction over
    helm binary only when providing api that can be used declaratively.
    It doesn't have much sense when many of the methods are accepting
    complete cli commands, it defeats the purpose of this module (testsuite
    could just use Process.run in place of method calls) and makes calls
    to those methods completely unconsistent throughout the codebase.

  • Simplify methods without changing logic wherever possible

  • Delete module methods related to helm v2 support

  • Delete prints to stdout_ from module (moved to main cnti_testsuite) -
    there are still prints in utils.cr marked as TODO.

  • Run official crystal-lang autoformatter

  • Delete unused constants from top of the file

- Restructure logging:
  * Add scopes with .for() method
  * Change .info logs to be informative feedback as to what is happening
  * Scope logs to .info and .debug categories more accurately
  * Delete many lines of unnecessary .info and .debug logs
  * Completely delete developer logs like random arguments or words
- Change signatures of methods corresponding to helm operations (pull,
  install...) from accepting cli strings to accepting arguments (from
  which cli commands are built).

  Helm module has a place in this codebase as layer of abstraction over
  helm binary only when providing api that can be used declaratively.
  It doesn't have much sense when many of the methods are accepting
  complete cli commands, it defeats the purpose of this module (testsuite
  could just use Process.run in place of method calls) and makes calls
  to those methods completely unconsistent throughout the codebase.
- Simplify methods without changing logic wherever possible
- Delete module methods related to helm v2 support
- Delete prints to stdout_ from module (moved to main cnti_testsuite) -
  there are still prints in utils.cr marked as TODO.
- Run official crystal-lang autoformatter
- Delete unused constants from top of the file

Signed-off-by: Rafal Lal <[email protected]>
- Do other formatting operations as breaking long lines etc
- Update according to changes in Helm module

Signed-off-by: Rafal Lal <[email protected]>
module ShellCmd
def self.run(cmd, log_prefix, force_output=false)
Log.info { "#{log_prefix} command: #{cmd}" }
module ShellCMD
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for renaming ShellCmd to ShellCMD? If this is to be done, the kubectl_client shard and the main testsuite repo also make use of a similar module which should be renamed in the future to retain conformity.


Helm::ShellCmd.run("ls -alR #{helm_chart}", "before generate")
Helm::ShellCmd.run("ls -alR cnfs", "before generate")
# TODO: do we need to log those 'ls' commands?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to tell, this function is no longer utilized in testsuite.

Comment on lines +230 to +236
if (resp[:output] + resp[:error]) =~ /WARNING: Kubernetes configuration file is/
return {true, "For this version of helm you must set your K8s config file permissions to chmod 700"}
end
rescue ex
stdout_failure("Please use newer version of helm")
true

return {false, nil}
rescue
return {true, "Please use newer version of helm"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a better solution than returning tuples? Could they at least be named?

@svteb
Copy link

svteb commented Feb 10, 2025

Additionally, we prefer that pull requests be limited to one commit, so consider squashing/rebasing them when you are done.

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 this pull request may close these issues.

2 participants