-
Notifications
You must be signed in to change notification settings - Fork 300
feat: credentials framework #212
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: credentials framework #212
Conversation
func (c Credential) String() string { | ||
return c.ToolName | ||
func toolNameWithCtx(toolName, credCtx string) string { | ||
return toolName + "///" + credCtx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open for suggestions for something better than this. I need a way of combining toolName and credCtx such that it still creates a valid URL.
e418b25
to
8d03ffe
Compare
pkg/cli/gptscript.go
Outdated
Chdir string `usage:"Change current working directory" short:"C"` | ||
Daemon bool `usage:"Run tool as a daemon" local:"true" hidden:"true"` | ||
Ports string `usage:"The port range to use for ephemeral daemon ports (ex: 11000-12000)" hidden:"true"` | ||
CredentialContext string `usage:"Context name in which to store credentials" default:"default" short:"c"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use -c
. Just make it long and verbose right now. -c
might be useful for something else more important later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pkg/cli/credential.go
Outdated
} | ||
|
||
func NewCredential(root *GPTScript) *cobra.Command { | ||
c := cmd.Command(&Credential{root: root}, cobra.Command{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using the Customize interface approach to change the default cobra.Command fields. I feel like that is slightly less confusing pattern. I'm going to probably drop support for this style of passing it as a second arg.
https://github.com/gptscript-ai/gptscript/blob/main/pkg/cli/gptscript.go#L102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pkg/cli/credential.go
Outdated
|
||
type Credential struct { | ||
root *GPTScript | ||
AllContexts bool `short:"A" usage:"List credentials for all contexts" local:"true"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do -A
. Either have no short or if you really want a short value then -a
. The -A
is very kubernetes-y.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Grant Linville <[email protected]>
c2929e5
to
f383f86
Compare
(I got verbal approval from Darren to merge.) |
You can read more about it in the doc I am adding in this PR, but basically this adds a "credentials framework" so that we have an easy way to supply secret values in environment variables to tools that need them. First you need to have a credential provider tool that prints a JSON object in the following format:
{"env":{"ENV_VAR_1": "value1", "ENV_VAR_2": "value2"}}
. Then, you can reference the credential tool in a script like this:The key-value pairs of environment variables that
my-credential-tool.gpt
returns will be added to the environment for the main tool's execution.