Skip to content
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

Unsupported keys per provider #324

Merged
merged 6 commits into from
Dec 21, 2016

Conversation

rtnpro
Copy link
Contributor

@rtnpro rtnpro commented Dec 5, 2016

Separate unsupported keys based on provider.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 6, 2016
@rtnpro
Copy link
Contributor Author

rtnpro commented Dec 6, 2016

#206 is blocked on this.

@sebgoa
Copy link
Contributor

sebgoa commented Dec 7, 2016

Can we have unit tests for this, please ?

@kadel
Copy link
Member

kadel commented Dec 7, 2016

@sebgoa for sure. It is not going to be merged without it.

@kadel kadel self-assigned this Dec 8, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling fcb8352 on rtnpro:unsupported-keys-per-provider into ** on kubernetes-incubator:master**.


// KomposeObject holds the generic struct of Kompose transformation
type KomposeObject struct {
ServiceConfigs map[string]ServiceConfig
// name of the loader that was created KomposeObject
LoadedFrom string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transformer need to know origin format in order to tell user what tag is not supported in origin format. They can have different names.
for example environment variables. are called environment in compose,Env in bundle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this explanation in code comment can help!

User string `compose:"user",bundle:"User"`
VolumesFrom []string `compose:"volumes_from",bundle:""`
ServiceType string `compose:"kompose.service.type",bundle:""`
Build string `compose:"build",bundle:""`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are tags needed for ServiceConfig ? Is this for structs?

Copy link
Member

@kadel kadel Dec 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we know from what element those values loaded by loader. (more in my reply to LoadedFrom)

Plus in future we can use this to automatically generate docs explaining transformation.

}
}

if counter, ok := unsupportedKey[f.Name()]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we can get this as the first check in this for loop for _, f := range s.Fields(), then it will save a lot of processing that happens before coming here? Similarly in other checkUnsupportedKey?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this particular check decides if that particular key is supported or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically It could be moved there, I kept it in the same order as it was before.

I wouldn't say a lot of processing as happening before. It is all just simple checks. Plus it is not like there will ever be hundreds of keys.
But I updated it anyway ;-) Plus I changed int counter in unsuportedKeys to bool.
Because all we need is to know if there already was that key or not ;-)

// this check if field is Slice, and then it checks its size
if field := val.FieldByName(f.Name()); field.Kind() == reflect.Slice {
if field.Len() == 0 {
// array is empty it doesn't metter if it is in unsupportedKey or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/metter/matter/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// this check if field is Slice, and then it checks its size
if field := val.FieldByName(f.Name()); field.Kind() == reflect.Slice {
if field.Len() == 0 {
// array is empty it doesn't metter if it is in unsupportedKey or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/metter/matter/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// this check if field is Slice, and then it checks its size
if field := val.FieldByName(f.Name()); field.Kind() == reflect.Slice {
if field.Len() == 0 {
// array is empty it doesn't metter if it is in unsupportedKey or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/metter/matter/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e1d88f7 on rtnpro:unsupported-keys-per-provider into ** on kubernetes-incubator:master**.

@kadel kadel force-pushed the unsupported-keys-per-provider branch 2 times, most recently from ed74bd2 to 1e5d5e3 Compare December 12, 2016 16:33
@coveralls
Copy link

Coverage Status

Coverage increased (+3.2%) to 38.242% when pulling 1e5d5e3 on rtnpro:unsupported-keys-per-provider into 04a3131 on kubernetes-incubator:master.

@surajssd
Copy link
Member

@ngtuna your say here will be appreciated!

@kadel kadel force-pushed the unsupported-keys-per-provider branch from 1e5d5e3 to 2e40f45 Compare December 15, 2016 18:34
@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 38.005% when pulling 2e40f45 on rtnpro:unsupported-keys-per-provider into 78845d3 on kubernetes-incubator:master.

@rtnpro rtnpro force-pushed the unsupported-keys-per-provider branch from 2e40f45 to e3ef748 Compare December 20, 2016 06:55
@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 39.184% when pulling e3ef748 on rtnpro:unsupported-keys-per-provider into c485a87 on kubernetes-incubator:master.

@rtnpro rtnpro force-pushed the unsupported-keys-per-provider branch from e3ef748 to 3419ae7 Compare December 20, 2016 11:28
@coveralls
Copy link

Coverage Status

Coverage increased (+2.006%) to 40.492% when pulling 3419ae7 on rtnpro:unsupported-keys-per-provider into c485a87 on kubernetes-incubator:master.

@rtnpro
Copy link
Contributor Author

rtnpro commented Dec 20, 2016

@surajssd rebased and ready for merging.

@surajssd
Copy link
Member

@rtnpro @kadel Thanks 👍

@surajssd surajssd merged commit 48e3ba8 into kubernetes:master Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. review needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants