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

feat: auth remove: add -b flag #711

Merged
merged 5 commits into from
Nov 10, 2023

Conversation

psturc
Copy link
Contributor

@psturc psturc commented Oct 17, 2023

Closes #710

πŸ“‘ Description

  • updated k8sgpt auth remove command to support -b flag and keep it compatible with the previous functionality, i.e. allow specifying multiple backends
  • updated README

βœ… Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

β„Ή Additional Information

Log from local verification
❯ ./bin/k8sgpt auth remove
Error: required flag(s) "backends" not set
Usage:
k8sgpt auth remove [flags]

Flags:
-b, --backends string   Backend AI providers to remove (separated by a comma)
-h, --help              help for remove

Global Flags:
    --config string        Default config file (/Users/psturc/Library/Application Support/k8sgpt/k8sgpt.yaml)
    --kubeconfig string    Path to a kubeconfig. Only required if out-of-cluster.
    --kubecontext string   Kubernetes context to use. Only required if out-of-cluster.

❯ ./bin/k8sgpt auth remove -b
Error: flag needs an argument: 'b' in -b
Usage:
k8sgpt auth remove [flags]

Flags:
-b, --backends string   Backend AI providers to remove (separated by a comma)
-h, --help              help for remove

Global Flags:
    --config string        Default config file (/Users/psturc/Library/Application Support/k8sgpt/k8sgpt.yaml)
    --kubeconfig string    Path to a kubeconfig. Only required if out-of-cluster.
    --kubecontext string   Kubernetes context to use. Only required if out-of-cluster.

❯ ./bin/k8sgpt auth remove -b ""
Error: backends must be set.
The command to remove AI backend provider(s)

Usage:
k8sgpt auth remove [flags]

Flags:
-b, --backends string   Backend AI providers to remove (separated by a comma)
-h, --help              help for remove

Global Flags:
    --config string        Default config file (/Users/psturc/Library/Application Support/k8sgpt/k8sgpt.yaml)
    --kubeconfig string    Path to a kubeconfig. Only required if out-of-cluster.
    --kubecontext string   Kubernetes context to use. Only required if out-of-cluster.

❯ ./bin/k8sgpt auth remove -b non-existing
Error: non-existing does not exist in configuration file. Please use k8sgpt auth new.

❯ cat /Users/psturc/Library/Application\ Support/k8sgpt/k8sgpt.yaml
ai:
  providers:
      - name: noopai
        model: gpt-3.5-turbo
        password: asdf
        temperature: 0.7
      - name: openai
        model: gpt-3.5-turbo
        password: asdf
        temperature: 0.7
      - name: localai
        model: gpt-3.5-turbo
        temperature: 0.7
  defaultprovider: ""
kubeconfig: ""
kubecontext: ""

❯ ./bin/k8sgpt auth remove -b localai,openai
localai deleted from the AI backend provider list
openai deleted from the AI backend provider list

❯ cat /Users/psturc/Library/Application\ Support/k8sgpt/k8sgpt.yaml
ai:
  providers:
      - name: noopai
        model: gpt-3.5-turbo
        password: asdf
        temperature: 0.7
  defaultprovider: ""
kubeconfig: ""
kubecontext: ""

❯ ./bin/k8sgpt auth remove --backends noopai
noopai deleted from the AI backend provider list

❯ cat /Users/psturc/Library/Application\ Support/k8sgpt/k8sgpt.yaml
ai:
  providers: []
  defaultprovider: ""
kubeconfig: ""
kubecontext: ""

@psturc psturc requested review from a team as code owners October 17, 2023 10:27
cmd/auth/auth.go Outdated Show resolved Hide resolved
Signed-off-by: Pavel Sturc <psturc@redhat.com>
Signed-off-by: Pavel Sturc <psturc@redhat.com>
@psturc
Copy link
Contributor Author

psturc commented Oct 24, 2023

@AlexsJones please let me know if there are more changes required for this PR.

@AlexsJones AlexsJones enabled auto-merge (squash) November 10, 2023 20:15
@AlexsJones AlexsJones merged commit 9dadd18 into k8sgpt-ai:main Nov 10, 2023
1 check passed
@psturc psturc deleted the removing-auth-add-b-flag branch November 11, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature]: Auth remove
2 participants