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

Added support for group_add key #739

Merged
merged 1 commit into from
Aug 11, 2017
Merged

Conversation

surajnarwade
Copy link
Contributor

No description provided.

@kompose-bot
Copy link
Collaborator

@surajnarwade, thank you for the pull request! We'll ping some people to review your PR. @surajssd and @containscafeine, please review this.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 2, 2017
@kompose-bot kompose-bot requested review from concaf and surajssd August 2, 2017 10:09
@surajnarwade surajnarwade changed the title Added support for group_add key [WIP] Added support for group_add key Aug 2, 2017
for _, i := range composeServiceConfig.GroupAdd {
j, err := strconv.Atoi(i)
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

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

needs to use errors.new for this

@@ -103,8 +103,11 @@ func (k *Kubernetes) CheckUnsupportedKey(komposeObject *kobject.KomposeObject, u
}

// InitPodSpec creates the pod specification
func (k *Kubernetes) InitPodSpec(name string, image string) api.PodSpec {
func (k *Kubernetes) InitPodSpec(name string, image string, groupadd []int64) api.PodSpec {
Copy link
Member

@cdrage cdrage Aug 2, 2017

Choose a reason for hiding this comment

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

no need to add groupadd here, we can add this to k8sutils.go, having it in kubernetes.go / openshift.go will make InitPodSpec messy with multiple input variables.

Have a look at how we transform the Kubernetes artifacts in k8sutils.go

@@ -113,7 +113,8 @@
"resources": {}
}
],
"restartPolicy": "Always"
"restartPolicy": "Always",
"securityContext": {}
Copy link
Member

Choose a reason for hiding this comment

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

all of the tests add securityContext, we should have an if statement in the code that ONLY adds securityContext if it's been supplied. no need for blank resources like this.

@surajnarwade surajnarwade force-pushed the group_add branch 2 times, most recently from a321210 to aad3b25 Compare August 4, 2017 05:32
@surajnarwade surajnarwade changed the title [WIP] Added support for group_add key Added support for group_add key Aug 4, 2017
@surajnarwade
Copy link
Contributor Author

I have updated PR with suggested changes, @cdrage @surajssd needs review on it

Copy link
Contributor

@concaf concaf left a comment

Choose a reason for hiding this comment

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

A couple of nits, and maybe add a failing test for both providers, and this is good to go.
Great work, @surajnarwade 🎉

for _, i := range composeServiceConfig.GroupAdd {
j, err := strconv.Atoi(i)
if err != nil {
return kobject.KomposeObject{}, errors.Wrap(err, "Unable to get group_add key")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: start the error with lowercase

@@ -264,6 +264,16 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
serviceConfig.MemLimit = composeServiceConfig.MemLimit
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
serviceConfig.StopGracePeriod = composeServiceConfig.StopGracePeriod
var t2 []int64
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what does t2 mean? How about a more explanatory variable name?

# kubernetes test
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/group-add/output-k8s.json"
# openshift test
convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/group-add/output-os.json"

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a failing test for both the providers? Makes the tests more robust.

Copy link
Contributor

@concaf concaf left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

Forget v3 support though, they've added a new key called config that configured uid / guid...

Other than two comments that suggest some changes, LGTM.

@@ -4,7 +4,7 @@ services:
postgresql:
image: swordphilic/postgresql
ports:
- "$DB_PORT"
- $DB_PORT
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 changed? Please revert back to with quotes.

@@ -264,6 +264,16 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
serviceConfig.MemLimit = composeServiceConfig.MemLimit
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
serviceConfig.StopGracePeriod = composeServiceConfig.StopGracePeriod
var groupAdd []int64
Copy link
Member

Choose a reason for hiding this comment

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

Please add spacing, newline here as well as a newline below (after serviceConfig.GroupAdd = groupAdd).

Since this is a range, perhaps it may be better to make this into a separate function?

Also add a small comment please :)

@cdrage
Copy link
Member

cdrage commented Aug 8, 2017

Please add a description to your commit as well as update this original PR description.

@surajnarwade surajnarwade force-pushed the group_add branch 3 times, most recently from 483b750 to d2d76cc Compare August 10, 2017 06:23
This PR will add support for `group_add` key which will map to
supplemental group in pod security context.
@surajnarwade
Copy link
Contributor Author

@cdrage updated with suggested changes

@cdrage
Copy link
Member

cdrage commented Aug 10, 2017

Awesome! This is great. Changes are good. Thanks @surajnarwade for the hard work.

@cdrage cdrage merged commit 214cb48 into kubernetes:master Aug 11, 2017
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants