Pass join token suggestedLabels to app server labels during install.sh#50720
Pass join token suggestedLabels to app server labels during install.sh#50720
Conversation
| 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.
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. |
| - name: "${APP_NAME}" | ||
| uri: "${APP_URI}" | ||
| public_addr: ${APP_PUBLIC_ADDR} | ||
| labels:{{range $index, $line := .appServerResourceLabels}} |
There was a problem hiding this comment.
Do you need a conditional here to handle the case when labels is empty?
There was a problem hiding this comment.
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.
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
| } | ||
|
|
||
| suggestedLabels := token.GetSuggestedLabels() | ||
| appServerResourceLabels, err = scripts.MarshalLabelsYAML(suggestedLabels, 6) |
There was a problem hiding this comment.
Why 6? What does it mean?
There was a problem hiding this comment.
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: devbut if labels is env: ['dev', 'prod'] yaml string is like below (with the extra space applied before the hyphen)
env:
- dev
- prodwith 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
| - name: "${APP_NAME}" | ||
| uri: "${APP_URI}" | ||
| public_addr: ${APP_PUBLIC_ADDR} | ||
| labels:{{range $index, $line := .appServerResourceLabels}} |
There was a problem hiding this comment.
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
#50720) * Allow adding app server labels from join token for install.sh * Address CRs * Reduce label yaml space, improve test
#50720) * Allow adding app server labels from join token for install.sh * Address CRs * Reduce label yaml space, improve test
* Create v2 web api endpoints and required related changes (#50472) * Pass join token suggestedLabels to app server labels during install.sh (#50720) * Allow adding app server labels from join token for install.sh * Address CRs * Reduce label yaml space, improve test * Set user provided labels for aws app access create (#50975) * Fix undefined slog
gravitational#50720) * Allow adding app server labels from join token for install.sh * Address CRs * Reduce label yaml space, improve test
part of #46976
Passes suggested labels stored from join token to app server installation
Tested, going through the
add appflow, adding labels, and running download script (UI changes will be in another PR):web ui label rendering
