-
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
Pass join token suggestedLabels to app server labels during install.sh #50720
Conversation
lib/web/join_tokens.go
Outdated
var buf bytes.Buffer | ||
// If app install mode is requested but parameters are blank for some reason, | ||
// we need to return an error. | ||
var appServerResourceLabels []string |
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.
Suggestion: move this declaration up so that the comment about app install mode stays next to the code that checks settings.appInstallMode
.
var buf bytes.Buffer | |
// If app install mode is requested but parameters are blank for some reason, | |
// we need to return an error. | |
var appServerResourceLabels []string | |
var buf bytes.Buffer, appServerResourceLabels []string | |
// If app install mode is requested but parameters are blank for some reason, | |
// we need to return an error. |
@@ -463,6 +463,9 @@ app_service: | |||
- name: "${APP_NAME}" | |||
uri: "${APP_URI}" | |||
public_addr: ${APP_PUBLIC_ADDR} | |||
labels:{{range $index, $line := .appServerResourceLabels}} |
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.
Do you need a conditional here to handle the case when labels is empty?
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.
we don't have to, this is valid labels:
(no values), i also tested it without adding labels to double check
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.
Some day (🤞) I will convert this script to go (the same thing we did for Server Auto Discovery scripts), and it will be much simpler to do these things
lib/web/join_tokens.go
Outdated
@@ -637,6 +638,12 @@ func getJoinScript(ctx context.Context, settings scriptSettings, m nodeAPIGetter | |||
if !appURIPattern.MatchString(settings.appURI) { | |||
return "", trace.BadParameter("appURI %q contains invalid characters", settings.appURI) | |||
} | |||
|
|||
suggestedLabels := token.GetSuggestedLabels() | |||
appServerResourceLabels, err = scripts.MarshalLabelsYAML(suggestedLabels, 6) |
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.
Why 6? What does it mean?
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.
its extra space to add with yaml list, but only applies when there are multi values for a key
so if labels is only env: ['dev']
yaml string is like below and the number doesn't have any affect (like this part of the code won't run)
env: dev
but if labels is env: ['dev', 'prod']
yaml string is like below (with the extra space applied before the hyphen)
env:
- dev
- prod
with that said though... this number won't get used because we prevent the web UI user from adding multi values for a key (the script will error out if you let it)
4d48a07
to
9253787
Compare
@@ -463,6 +463,9 @@ app_service: | |||
- name: "${APP_NAME}" | |||
uri: "${APP_URI}" | |||
public_addr: ${APP_PUBLIC_ADDR} | |||
labels:{{range $index, $line := .appServerResourceLabels}} |
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.
Some day (🤞) I will convert this script to go (the same thing we did for Server Auto Discovery scripts), and it will be much simpler to do these things
9253787
to
2a4e548
Compare
part of #46976
Passes suggested labels stored from join token to app server installation
Tested, going through the
add app
flow, adding labels, and running download script (UI changes will be in another PR):web ui label rendering