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

[v16] Machine ID: Allow Kubernetes Secret to be specified as output destination or data dir from the commandline. #44801

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/tbot/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,27 @@ func destinationFromURI(uriString string) (bot.Destination, error) {
)
}
return &DestinationMemory{}, nil
case "kubernetes-secret":
if uri.Host != "" {
return nil, trace.BadParameter(
"kubernetes-secret scheme should not be specified with host",
)
}
if uri.Path == "" {
return nil, trace.BadParameter(
"kubernetes-secret scheme should have a path specified",
)
}
// kubernetes-secret:///my-secret
// TODO(noah): Eventually we'll support namespace in the host part of
// the URI. For now, we'll default to the namespace tbot is running in.

// Path will be prefixed with '/' so we'll strip it off.
secretName := strings.TrimPrefix(uri.Path, "/")

return &DestinationKubernetesSecret{
Name: secretName,
}, nil
default:
return nil, trace.BadParameter(
"unrecognized data storage scheme",
Expand Down
13 changes: 13 additions & 0 deletions lib/tbot/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ func TestDestinationFromURI(t *testing.T) {
in: "foobar://",
wantErr: true,
},
{
in: "kubernetes-secret:///my-secret",
want: &DestinationKubernetesSecret{
Name: "my-secret",
},
},
{
in: "kubernetes-secret://my-secret",
want: &DestinationKubernetesSecret{
Name: "my-secret",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.in, func(t *testing.T) {
Expand Down
Loading