-
Notifications
You must be signed in to change notification settings - Fork 735
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
Propagate underscore into valid name #509
Conversation
8d81b48
to
afa0240
Compare
We shouldn't do this in every place where name is used. Than you have to do it only once, and you can be sure that it will be correct in every place after that. |
b244494
to
94e6c7f
Compare
94e6c7f
to
dea681c
Compare
@@ -637,7 +637,7 @@ func (k *Kubernetes) Deploy(komposeObject kobject.KomposeObject, opt kobject.Con | |||
if !opt.EmptyVols { | |||
pvcStr = " and PersistentVolumeClaims " | |||
} | |||
fmt.Println("We are going to create Kubernetes Deployments, Services" + pvcStr + "for your Dockerized application. \n" + | |||
fmt.Println("\nWe are going to create Kubernetes Deployments, Services" + pvcStr + "for your Dockerized application. \n" + |
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.
Remove the \n
This may be a good opportunity to change this into a log.Info instead of a Println.
pkg/loader/compose/compose.go
Outdated
@@ -374,7 +374,10 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { | |||
serviceConfig.Tty = composeServiceConfig.Tty | |||
serviceConfig.MemLimit = composeServiceConfig.MemLimit | |||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs | |||
komposeObject.ServiceConfigs[name] = serviceConfig | |||
komposeObject.ServiceConfigs[normalizeServiceNames(name)] = serviceConfig | |||
if !reflect.DeepEqual(komposeObject.ServiceConfigs[normalizeServiceNames(name)], komposeObject.ServiceConfigs[name]) { |
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.
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.
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.
@procrypt ah, makes sense!
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.
That reflect seems little bit too much :-(
Can same think be done a bit easier without reflect and more readable?
Why compere whole struct? Comparing just names should be enough no?
4354b4f
to
8d1f4bd
Compare
pkg/loader/compose/compose.go
Outdated
komposeObject.ServiceConfigs[name] = serviceConfig | ||
komposeObject.ServiceConfigs[normalizeServiceNames(name)] = serviceConfig | ||
if !reflect.DeepEqual(komposeObject.ServiceConfigs[normalizeServiceNames(name)], komposeObject.ServiceConfigs[name]) { | ||
log.Infof("Service name in docker-compose has been changed from %c%s%c to %c%s%c", '"', name, '"', '"', normalizeServiceNames(name), '"') |
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.
if you want to print "
in the output then you can use format specifier %q
and get the same result, so you don't need to do the hack currently done!
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.
This might help https://golang.org/pkg/fmt/
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.
@surajssd Thanks 👍
8d1f4bd
to
d5aa4c8
Compare
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.
LGTM
faa8091
to
fdb4878
Compare
@kadel Updated 😉 |
pkg/loader/compose/compose.go
Outdated
@@ -374,7 +374,10 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { | |||
serviceConfig.Tty = composeServiceConfig.Tty | |||
serviceConfig.MemLimit = composeServiceConfig.MemLimit | |||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs | |||
komposeObject.ServiceConfigs[name] = serviceConfig | |||
komposeObject.ServiceConfigs[normalizeServiceNames(name)] = serviceConfig | |||
if komposeObject.ServiceConfigs[normalizeServiceNames(name)].Image != komposeObject.ServiceConfigs[name].Image { |
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.
This confuses me a lot.
Why are you comparing Images?
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.
@kadel I didn't see that sorry, I have updated the PR.
Now we can provide service name with "_" in docker-compose files and they will by converted as "-" in the generated artifacts by kompose eg, if the service name in docker-compose file is "foo_bar" then it will be converted into "foo-bar" in the generated artifacts
fdb4878
to
6e0b934
Compare
Excited for this to get in so can properly use kompose :) Thanks so much! |
Just beware that in some cases this also renames dns name that points to renamed service. In some cases this can break communication between services :-( |
@@ -637,7 +637,7 @@ func (k *Kubernetes) Deploy(komposeObject kobject.KomposeObject, opt kobject.Con | |||
if !opt.EmptyVols { | |||
pvcStr = " and PersistentVolumeClaims " | |||
} | |||
fmt.Println("We are going to create Kubernetes Deployments, Services" + pvcStr + "for your Dockerized application. \n" + | |||
log.Info("We are going to create Kubernetes Deployments, Services" + pvcStr + "for your Dockerized application. " + |
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.
IIRC It was purposefully kept as Println
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.
@surajssd Why?
Now we can provide service name with
_
in docker-compose files and they will by converted as-
in the generated artifacts by kompose eg, if the service name in docker-compose file is "foo_bar" then it will be converted into "foo-bar" in the generated artifacts.docker-compose.yml
containing_
in service name.docker-compose.yml
without_
in service name.cc: @kadel @cdrage
Fixes: #420