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

Add Replicas field to DeploymentParams struct #129

Merged
merged 6 commits into from
Feb 1, 2022

Conversation

dharmit
Copy link
Contributor

@dharmit dharmit commented Jan 25, 2022

What does this PR do?:

Adds Replicas field to DeploymentParams struct. This will help initialize a Deployment with Replica set to what the tooling would like to have. By default, library doesn't set it to anything at the moment.

Which issue(s) this PR fixes:

redhat-developer/odo#5347

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened.

  • Open new test/doc issues under the devfile/api repo
  • Check each criteria if:
  • There is a separate tracking issue. Add the issue link under the criteria
    or
  • test/doc updates are made as part of this PR
  • If unchecked, explain why it's not needed

How to test changes / Special notes to the reviewer:

@@ -158,6 +159,7 @@ type DeploymentParams struct {
Containers []corev1.Container
Volumes []corev1.Volume
PodSelectorLabels map[string]string
Replicas int32
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set the Replicas as a pointer, to make it optional (the nil value indicating the user does not want to set it). The 0 value on which you test below is a valid value a user would want to set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Does 145564e look good?

@@ -187,6 +187,10 @@ func GetDeployment(devfileObj parser.DevfileObj, deployParams DeploymentParams)
Spec: *getDeploymentSpec(deploySpecParams),
}

if deployParams.Replicas != nil {
deployment.Spec.Replicas = deployParams.Replicas
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this affectation should be done in getDeploymentSpec which is the dedicated function for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. That's where I first looked. But that would mean changing the signature of getDeploymentSpec. I was not sure if that would be OK. But it's an internal function, so changing signature shouldn't be a big deal.

Pushed 4a544b1. PTAL.

pkg/devfile/generator/generators.go Outdated Show resolved Hide resolved
@yangcao77
Copy link
Collaborator

the changes look good, just need to pass the ci, and I will add the label

@yangcao77
Copy link
Collaborator

/approve

@dharmit
Copy link
Contributor Author

dharmit commented Jan 31, 2022

@yangcao77 do I need to make any changes to the PR? Would go mod tidy suffice?

@yangcao77
Copy link
Collaborator

@dharmit yes, please run go mod tidy and go fmt -x ./...

@yangcao77 yangcao77 added the lgtm label Feb 1, 2022
@openshift-ci
Copy link

openshift-ci bot commented Feb 1, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dharmit, yangcao77

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yangcao77 yangcao77 merged commit 0749c7f into devfile:main Feb 1, 2022
@dharmit dharmit deleted the fix-odo-5347 branch October 11, 2022 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants