-
Notifications
You must be signed in to change notification settings - Fork 135
Adding capability to pass in args parameter to kubectl #198
Conversation
bf05c00
to
74980ba
Compare
075db0f
to
3d96226
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.
Various comments
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.
More comments.
3d96226
to
5042851
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.
more questions
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.
sorry for the delay getting back with comments.
I will update with the make variables call, but also put in an issue to replace them as that call is deprecated. |
5042851
to
f39b957
Compare
f39b957
to
e903ac6
Compare
e903ac6
to
095fbdb
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: chrislovecnm If they are not already assigned, you can assign the PR to them by writing 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 |
a5561e2
to
e07758b
Compare
/test pull-rules-k8s-e2e |
/retest |
5be5b74
to
db5c38f
Compare
51f57e5
to
8a51da1
Compare
/retest |
b466386
to
c618df5
Compare
@nlopezgi PTAL |
eba56a8
to
d627ab0
Compare
/retest |
Added kubectl_args to apply, delete, describe, create and replace kubectl commands. This PR adds a parameter to pass in arguments to kubectl. For intance a user can pass in "-v=10 --dry-run=true" to kubectl. This work is based off of @omadawn's work.
Allows for the passing in of arguments to kubectl via a cli run command Adding the capability of using $@ ie. args with kubectl commands.
- modified the java hellohttp example BUILD file to include --v=2 kubectl_args - added test for --v=2 in BUILD file - added test for passing in an argument via the cli
d627ab0
to
d7c093e
Compare
@@ -394,6 +394,16 @@ Users can "describe" their environment by running: | |||
bazel run :dev.describe | |||
``` | |||
|
|||
### kubectl Arguments Via the Command Line | |||
|
|||
The apply, create, delete, and describe commands will accept kubectl arguments passed in |
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.
nit: wrap line at 80 chars
# also tests that --help can be passed in as a cli argument | ||
check_kubectl_args() { | ||
|
||
# checking that --v=2 is passed in via kubect_arguments in |
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.
s/kubect_arguments/kubectl_args
# the java BUILD file | ||
FILE="./bazel-bin/examples/hellohttp/java/staging.apply" | ||
echo Checking kubectl args in file: "$FILE" | ||
bazel build examples/hellohttp/java:staging.apply |
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.
what a painful way to test, thanks for setting it up, but we do need some infrastructure to make this easier
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 works 😆
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.
Found in the rules_docker e2e tests that we have some sort of crude infrastructure to do some basic checks, for example, that a file contains a string:
https://github.com/bazelbuild/rules_docker/blob/master/testing/e2e.sh#L45
This checks that the output of bazel run has some flags:
https://github.com/bazelbuild/rules_docker/blob/master/testing/e2e.sh#L281
should be simpler than what you have here?
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.
what I have works ... why change it? 🤷♂️
I think we really need to FIX it 😆
@@ -172,13 +172,22 @@ def _common_impl(ctx): | |||
|
|||
kubectl_tool_info = ctx.toolchains["@io_bazel_rules_k8s//toolchains/kubectl:toolchain_type"].kubectlinfo | |||
|
|||
kubectl_args = " ".join(ctx.attr.kubectl_args or []) |
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.
Ok, so lets make this simple then, lets start w/o supporting make variable expansion and just avoid needing all this code (we can add it later if we need to).
Based off that assumption, all you need here is this line:
kubectl_args = " ".join(ctx.attr.kubectl_args)
(no need to have the or if default is set below in line 238)
and everything between lines 176-180 can go away.
and then just do
"%{kubectl_args}": kubectl_args,
in line 190 below
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.
we can add it later if we need to
Is there a reason we don't add it now? I will update the code as you recommended, just want to learn more :)
@@ -226,6 +235,7 @@ _common_attrs = { | |||
executable = True, | |||
allow_files = True, | |||
), | |||
"kubectl_args": attr.string_list(), |
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.
set this with default:
"kubectl_args": attr.string_list(default = []),
Closing cause we have #224 Coming in |
This PR adds a parameter to pass in arguments to kubectl. For instance
a user can pass in "-v=10 --dry-run=true" to kubectl. This work is
based off of @omadawn's work.
Once we have the design stabilized I will update the documentation.