-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add token list/delete endpoints #42402
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,7 +127,8 @@ type ProvisionToken interface { | |||||
GetJoinMethod() JoinMethod | ||||||
// GetBotName returns the BotName field which must be set for joining bots. | ||||||
GetBotName() string | ||||||
|
||||||
// IsStatic returns true if the token is statically configured | ||||||
IsStatic() bool | ||||||
// GetSuggestedLabels returns the set of labels that the resource should add when adding itself to the cluster | ||||||
GetSuggestedLabels() Labels | ||||||
|
||||||
|
@@ -394,6 +395,11 @@ func (p *ProvisionTokenV2) GetJoinMethod() JoinMethod { | |||||
return p.Spec.JoinMethod | ||||||
} | ||||||
|
||||||
// IsStatic returns true if the token is statically configured | ||||||
func (p *ProvisionTokenV2) IsStatic() bool { | ||||||
return p.Origin() == OriginConfigFile | ||||||
} | ||||||
|
||||||
// GetBotName returns the BotName field which must be set for joining bots. | ||||||
func (p *ProvisionTokenV2) GetBotName() string { | ||||||
return p.Spec.BotName | ||||||
|
@@ -535,14 +541,16 @@ func ProvisionTokensToV1(in []ProvisionToken) []ProvisionTokenV1 { | |||||
return out | ||||||
} | ||||||
|
||||||
// ProvisionTokensFromV1 converts V1 provision tokens to resource list | ||||||
func ProvisionTokensFromV1(in []ProvisionTokenV1) []ProvisionToken { | ||||||
// ProvisionTokensFromStatic converts static tokens to resource list | ||||||
func ProvisionTokensFromStatic(in []ProvisionTokenV1) []ProvisionToken { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added this method to replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's fine, but it would be better if we changed it at its creation instead of when converting to something else. teleport/api/types/statictokens.go Line 41 in 67a3d64
teleport/lib/config/fileconf.go Line 950 in 67a3d64
|
||||||
if in == nil { | ||||||
return nil | ||||||
} | ||||||
out := make([]ProvisionToken, len(in)) | ||||||
for i := range in { | ||||||
out[i] = in[i].V2() | ||||||
tok := in[i].V2() | ||||||
tok.SetOrigin(OriginConfigFile) | ||||||
out[i] = tok | ||||||
} | ||||||
return out | ||||||
} | ||||||
|
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.
Ok, I added the
IsStatic
method but I am not relying on the time anymore (it seemed fickle to me from the start). When we fetch static tokens, we create a newProvisionToken
from the available static tokens. I've just set their origin toOriginConfiguration
instead of being nil and nowIsStatic
just checks ifOrigin() == OriginConfiguration
. It seems to be more correct and resilient this way. Let me know what you think