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
WINC-949: Rename powershellVariablesInCommand #1352
Conversation
Skipping CI for Draft Pull Request. |
/test build |
/test lint |
/approve cancel |
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
thanks for doing this ⚡
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.
Thanks for working on this, @sebsoto. Please address my comments.
pkg/services/services.go
Outdated
Priority: 1, | ||
Bootstrap: true, | ||
Dependencies: []string{windows.ContainerdServiceName}, | ||
PowershellPreScripts: powershellVars, |
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.
Now this looks a bit odd. Why would PowershellPreScripts
be referred to as powershellVars
pkg/daemon/controller/controller.go
Outdated
} | ||
if psVar.Name != "" { | ||
vars[psVar.Name] = strings.TrimSpace(out) | ||
if psVar.VariableName != "" { |
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.
Now this variable is stuttering because this is no longer a psVar
.
Name string `json:"name"` | ||
// Path is the location of a PowerShell script whose output is the value of the variable | ||
// PowershellPreScript describes a PowerShell script to be ran and an optional variable to be populated | ||
type PowershellPreScript struct { |
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 are thinking about PowerShellPostScript
shouldn't this be generic?
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.
PowerShellPostScript would just need to be a []string, as there wouldn't be any variables to replace, given it runs after the service.
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.
Would this also be the case for arbitrary scripts that we were going to introduce instead of always having scripts associated with a service? While there might not be variables to replace there either do you think the struct could be reused with other members added to it?
994b1ca
to
f630791
Compare
pkg/servicescm/servicescm.go
Outdated
type PowershellPreScript struct { | ||
// VariableName is the name of a variable which should be replaced by the output of the script. An empty value will | ||
// cause no variable replacement to occur, but the script will still be ran. | ||
VariableName string `json:"variableName"` |
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.
Do we need to add omitempty
?
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.
Yes, I think so. In addition, would be nice to add a unit test to cover this scenario, where a PowershellPreScript
gets created without VariableName
.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aravindhp 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 |
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, just a few suggestions.
@@ -67,9 +67,7 @@ func containerdConfiguration(debug bool) servicescm.Service { | |||
Name: windows.ContainerdServiceName, | |||
Command: containerdServiceCmd, | |||
NodeVariablesInCommand: nil, | |||
PowershellVariablesInCommand: []servicescm.PowershellCmdArg{{ | |||
// Name is left blank as we just want this script to execute, without any service command replacements |
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.
It may be helpful to keep the comment.
pkg/servicescm/servicescm.go
Outdated
type PowershellPreScript struct { | ||
// VariableName is the name of a variable which should be replaced by the output of the script. An empty value will | ||
// cause no variable replacement to occur, but the script will still be ran. | ||
VariableName string `json:"variableName"` |
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.
Yes, I think so. In addition, would be nice to add a unit test to cover this scenario, where a PowershellPreScript
gets created without VariableName
.
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
LGTM from my end
Renames powershellVariablesInCommand to powershellPreScripts to remove the implicit requirement of a variable to replace, which is not always necessary. Also renames powershellVaraiblesInCommand.Name, to VariableName, to be more clear about the purpose of the field with the new naming.
f630791
to
c4ec11c
Compare
/test aws-e2e-operator |
/test gcp-e2e-operator |
/lgtm |
/retest-required |
/retest-required |
/cherry-pick release-4.12 |
@sebsoto: once the present PR merges, I will cherry-pick it on top of release-4.12 in a new PR and assign it to you. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@sebsoto: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@sebsoto: #1352 failed to apply on top of branch "release-4.12":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherry-pick release-4.12 |
@mansikulkarni96: new pull request created: #1436 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Renames powershellVariablesInCommand to powershellPreScripts to remove the implicit requirement of a variable to replace, which is not always necessary. Also renames powershellVaraiblesInCommand.Name, to VariableName, to be more clear about the purpose of the field with the new naming.