Skip to content

Commit

Permalink
rename the controller flag (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
kschoche authored Mar 10, 2022
1 parent fc88732 commit 5118aa0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ spec:
{{- end }}
{{- if .Values.controller.enabled }}
-create-controller-token=true \
-controller=true \
{{- end }}
{{- if .Values.apiGateway.enabled }}
Expand Down
8 changes: 4 additions & 4 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1763,24 +1763,24 @@ load _helpers
#--------------------------------------------------------------------
# controller

@test "serverACLInit/Job: -create-controller-token not set by default" {
@test "serverACLInit/Job: -controller not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("create-controller-token"))' | tee /dev/stderr)
yq '.spec.template.spec.containers[0].command | any(contains("controller"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "serverACLInit/Job: -create-controller-token set when controller.enabled=true" {
@test "serverACLInit/Job: -controller set when controller.enabled=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'controller.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("create-controller-token"))' | tee /dev/stderr)
yq '.spec.template.spec.containers[0].command | any(contains("controller"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

Expand Down
8 changes: 4 additions & 4 deletions control-plane/subcommand/server-acl-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Command struct {
flagAuthMethodHost string
flagBindingRuleSelector string

flagCreateControllerPoliciesAndBindings bool
flagController bool

flagCreateEntLicenseToken bool

Expand Down Expand Up @@ -140,8 +140,8 @@ func (c *Command) init() {
c.flags.StringVar(&c.flagBindingRuleSelector, "acl-binding-rule-selector", "",
"Selector string for connectInject ACL Binding Rule.")

c.flags.BoolVar(&c.flagCreateControllerPoliciesAndBindings, "create-controller-token", false,
"Toggle for creating acl policies and rolebindings for the controller.")
c.flags.BoolVar(&c.flagController, "controller", false,
"Toggle for configuring ACLs for the controller.")

c.flags.BoolVar(&c.flagCreateEntLicenseToken, "create-enterprise-license-token", false,
"Toggle for creating a token for the enterprise license job.")
Expand Down Expand Up @@ -727,7 +727,7 @@ func (c *Command) Run(args []string) int {
}
}

if c.flagCreateControllerPoliciesAndBindings {
if c.flagController {
rules, err := c.controllerRules()
if err != nil {
c.log.Error("Error templating controller token rules", "err", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestRun_ACLPolicyUpdates(t *testing.T) {
"-ingress-gateway-name=anothergw",
"-terminating-gateway-name=gw",
"-terminating-gateway-name=anothergw",
"-create-controller-token",
"-controller",
}
// Our second run, we're going to update from partitions and namespaces disabled to
// namespaces enabled with a single destination ns and partitions enabled.
Expand Down
8 changes: 4 additions & 4 deletions control-plane/subcommand/server-acl-init/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ func TestRun_PoliciesAndBindingRulesForACLLogin_PrimaryDatacenter(t *testing.T)
}{
{
TestName: "Controller",
TokenFlags: []string{"-create-controller-token"},
TokenFlags: []string{"-controller"},
PolicyNames: []string{"controller-policy"},
Roles: []string{resourcePrefix + "-controller-acl-role"},
},
Expand Down Expand Up @@ -2255,7 +2255,7 @@ func TestRun_PoliciesAndBindingRulesACLLogin_SecondaryDatacenter(t *testing.T) {
}{
{
TestName: "Controller",
TokenFlags: []string{"-create-controller-token"},
TokenFlags: []string{"-controller"},
PolicyNames: []string{"controller-policy-" + secondaryDatacenter},
Roles: []string{resourcePrefix + "-controller-acl-role-" + secondaryDatacenter},
GlobalAuthMethod: true,
Expand Down Expand Up @@ -2365,7 +2365,7 @@ func TestRun_ValidateLoginToken_PrimaryDatacenter(t *testing.T) {
}{
{
ComponentName: "controller",
TokenFlags: []string{"-create-controller-token"},
TokenFlags: []string{"-controller"},
Roles: []string{resourcePrefix + "-controller-acl-role"},
GlobalToken: false,
},
Expand Down Expand Up @@ -2456,7 +2456,7 @@ func TestRun_ValidateLoginToken_SecondaryDatacenter(t *testing.T) {
}{
{
ComponentName: "controller",
TokenFlags: []string{"-create-controller-token"},
TokenFlags: []string{"-controller"},
Roles: []string{resourcePrefix + "-controller-acl-role-dc2"},
GlobalAuthMethod: true,
GlobalToken: true,
Expand Down

0 comments on commit 5118aa0

Please sign in to comment.