WIP: check if labels are nil before adding labels #449
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "nil_labels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For toolshed/organising#643
I tested it by playing with a local recipe, create an app instance without labels (failed to deploy initially), tried with the changes, deploy succeeded AND labels existed when I inspected the service on the swarm box 🎊
One minor comment, see what you think about it! Otherwise, very legit, tysm! 🤘
@ -89,0 +89,4 @@
func AddLabel(service composetypes.ServiceConfig, labelKey string, value string) {
if service.Deploy.Labels == nil {
service.Deploy.Labels = composetypes.Labels{}
We have an unwritten (🙈) convention to use
...version=unknown
when we don't know what the version label will be. For example:bba1640913/pkg/upstream/stack/stack.go (L113)
More examples here.
So, maybe it's an idea to manually set the same config to be "unknown"?
I think this might be important in the case of "set label" logic since other logic will try to read this label later on.
Or, maybe it's too complicated / too much assumption. I am not sure. This will set the label on the deployed containers but it won't be present on the compose config?
Thanks for this comment, it made me realize my change silences the error but doesn't really add the labels
Gonna dig deeper
On a second thought, this solution didn't really work
I did
docker service inspect <app_name>_app
and sawLabels
and was like Wohoo all goodThe labels that exist are
com.docker.stack.image
andcom.docker.stack.namespace
😥check if labels are nil before adding labelsto WIP: check if labels are nil before adding labelsTook a pass on this one!
toolshed/organising#643 (comment)
Pull request closed