Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

✨ Add the --context option #427

Merged
merged 2 commits into from
Jun 28, 2022
Merged

✨ Add the --context option #427

merged 2 commits into from
Jun 28, 2022

Conversation

jerr
Copy link
Contributor

@jerr jerr commented May 23, 2022

Description

As for kubectl command line tool, the option -c/--context is added to specify a context. The -c flag is therefore no longer used to specify. the kubeconfig path.

Type of change
  • New feature ✨
  • This change requires a documentation update 📖
  • Breaking changes ⚠️
How Has This Been Tested?
  • Added unit test in kubeaudit_test.go to test invalid context name
  • Instead of specify a context with the kubectl cluster-info --context <CONTEXT> command I ran a kubeaudit limits with the --context <CLUSTER> flag.
  • The help information is updated.
    $ ./kubeaudit --help                                        
    Kubeaudit audits Kubernetes clusters for common security controls.
    
    ...
    
    Flags:
      -c, --context string       The name of the kubeconfig context to use
      -e, --exitcode int         Exit code to use if there are results with severity of "error". Conventionally, 0 is used for success and all non-zero codes for an error. (default 2)
      -p, --format string        The output format to use (one of "pretty", "logrus", "json") (default "pretty")
      -h, --help                 help for kubeaudit
      -g, --includegenerated     Include generated resources in scan  (eg. pods generated by deployments).
          --kubeconfig string    Path to local Kubernetes config file. Only used in local mode (default is $HOME/.kube/config)
      -f, --manifest string      Path to the yaml configuration to audit. Only used in manifest mode.
      -m, --minseverity string   Set the lowest severity level to report (one of "error", "warning", "info") (default "info")
      -n, --namespace string     Only audit resources in the specified namespace. Not currently supported in manifest mode.
    
Checklist:
  • I have 🎩 my changes (A 🎩 specifically includes pulling down changes, setting them up, and manually testing the changed features and potential side effects to make sure nothing is broken)
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The test coverage did not decrease
  • I have signed the appropriate Contributor License Agreement

@ghost ghost added core readme labels May 23, 2022
Copy link
Contributor

@genevieveluyt genevieveluyt left a comment

Choose a reason for hiding this comment

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

Change looks good! I would like to isolate it to its own release though, after the dependency updates

@jerr jerr force-pushed the add_context_option branch from fb5db4d to 426a8af Compare June 7, 2022 13:17
@jerr
Copy link
Contributor Author

jerr commented Jun 7, 2022

👆 rebased on the main branch to fix tests in CI (with KinD 1.20 nodes)

@jerr jerr force-pushed the add_context_option branch from 426a8af to 1ee267c Compare June 8, 2022 21:59
@jerr
Copy link
Contributor Author

jerr commented Jun 8, 2022

👆 rebased on the main branch to use the dynamic client

genevieveluyt
genevieveluyt previously approved these changes Jun 9, 2022
@jerr jerr merged commit 7eaf685 into main Jun 28, 2022
@jerr jerr deleted the add_context_option branch June 28, 2022 06:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants