Skip to content

Commit

Permalink
Revert changes to truth tables
Browse files Browse the repository at this point in the history
The team is split on style preferences here. Revert to the original
switch format and disable the relevant check.
  • Loading branch information
Andrew Lytvynov authored and awly committed May 15, 2020
1 parent 4b5cd7e commit 732dfd5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ lint:
golangci-lint run \
--disable-all \
--exclude-use-default \
--exclude='S1002: should omit comparison to bool constant' \
--skip-dirs vendor \
--uniq-by-line=false \
--max-same-issues=0 \
Expand Down
8 changes: 4 additions & 4 deletions lib/auth/trustedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster

// change state
switch {
case exists && enable:
case exists == true && enable == true:
log.Debugf("Enabling existing Trusted Cluster relationship.")

err := a.activateCertAuthority(trustedCluster)
Expand All @@ -78,7 +78,7 @@ func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster
if err != nil {
return nil, trace.Wrap(err)
}
case exists && !enable:
case exists == true && enable == false:
log.Debugf("Disabling existing Trusted Cluster relationship.")

err := a.deactivateCertAuthority(trustedCluster)
Expand All @@ -93,7 +93,7 @@ func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster
if err != nil {
return nil, trace.Wrap(err)
}
case !exists && enable:
case exists == false && enable == true:
log.Debugf("Creating enabled Trusted Cluster relationship.")

if err := a.checkLocalRoles(trustedCluster.GetRoleMap()); err != nil {
Expand All @@ -119,7 +119,7 @@ func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster
return nil, trace.Wrap(err)
}

case !exists && !enable:
case exists == false && enable == false:
log.Debugf("Creating disabled Trusted Cluster relationship.")

if err := a.checkLocalRoles(trustedCluster.GetRoleMap()); err != nil {
Expand Down
13 changes: 11 additions & 2 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,17 @@ func (rc *ResourceCommand) getCollection(client auth.ClientI) (c ResourceCollect

// UpsertVerb generates the correct string form of a verb based on the action taken
func UpsertVerb(exists bool, force bool) string {
if exists && !force {
switch {
case exists == true && force == true:
return "created"
case exists == false && force == true:
return "created"
case exists == true && force == false:
return "updated"
case exists == false && force == false:
return "created"
default:
// Unreachable, but compiler requires this.
return "unknown"
}
return "created"
}

0 comments on commit 732dfd5

Please sign in to comment.