@@ -247,7 +247,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
247247 "private-key-path" ,
248248 "" ,
249249 "" ,
250- fmt . Sprintf ( "To be used in conjunction with --client-id. The path to the private key file for the service account." ) ,
250+ "To be used in conjunction with --client-id. The path to the private key file for the service account." ,
251251 )
252252 c .PersistentFlags ().BoolVarP (
253253 & cfg .OneShot ,
@@ -531,8 +531,8 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
531531 // Validation of `venafi-cloud.upload_path`.
532532 {
533533 var uploadPath string
534- switch {
535- case res . TLSPKMode == VenafiCloudKeypair :
534+ switch res . TLSPKMode { // nolint:exhaustive
535+ case VenafiCloudKeypair :
536536 if cfg .VenafiCloud == nil || cfg .VenafiCloud .UploadPath == "" {
537537 errs = multierror .Append (errs , fmt .Errorf ("the venafi-cloud.upload_path field is required when using the %s mode" , res .TLSPKMode ))
538538 break // Skip to the end of the switch statement.
@@ -544,7 +544,7 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
544544 }
545545
546546 uploadPath = cfg .VenafiCloud .UploadPath
547- case res . TLSPKMode == VenafiCloudVenafiConnection :
547+ case VenafiCloudVenafiConnection :
548548 // The venafi-cloud.upload_path was initially meant to let users
549549 // configure HTTP proxies, but it has never been used since HTTP
550550 // proxies don't rewrite paths. Thus, we've disabled the ability to
@@ -577,18 +577,18 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
577577 if res .TLSPKMode != Off {
578578 var clusterID string
579579 var organizationID string // Only used by the old jetstack-secure mode.
580- switch {
581- case res . TLSPKMode == VenafiCloudKeypair :
580+ switch res . TLSPKMode { // nolint:exhaustive
581+ case VenafiCloudKeypair :
582582 if cfg .ClusterID == "" {
583583 errs = multierror .Append (errs , fmt .Errorf ("cluster_id is required in %s mode" , res .TLSPKMode ))
584584 }
585585 clusterID = cfg .ClusterID
586- case res . TLSPKMode == VenafiCloudVenafiConnection :
586+ case VenafiCloudVenafiConnection :
587587 if cfg .ClusterID == "" {
588588 errs = multierror .Append (errs , fmt .Errorf ("cluster_id is required in %s mode" , res .TLSPKMode ))
589589 }
590590 clusterID = cfg .ClusterID
591- case res . TLSPKMode == JetstackSecureOAuth || res . TLSPKMode == JetstackSecureAPIToken :
591+ case JetstackSecureOAuth , JetstackSecureAPIToken :
592592 if cfg .OrganizationID == "" {
593593 errs = multierror .Append (errs , fmt .Errorf ("organization_id is required" ))
594594 }
@@ -637,7 +637,7 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
637637 }
638638
639639 // Validation of --install-namespace.
640- var installNS string = flags .InstallNS
640+ installNS : = flags .InstallNS
641641 if flags .InstallNS == "" {
642642 var err error
643643 installNS , err = getInClusterNamespace ()
@@ -650,7 +650,7 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
650650 // Validation of --venafi-connection and --venafi-connection-namespace.
651651 if res .TLSPKMode == VenafiCloudVenafiConnection {
652652 res .VenConnName = flags .VenConnName
653- var venConnNS string = flags .VenConnNS
653+ venConnNS : = flags .VenConnNS
654654 if flags .VenConnNS == "" {
655655 venConnNS = installNS
656656 }
@@ -714,8 +714,8 @@ func validateCredsAndCreateClient(log logr.Logger, flagCredentialsPath, flagClie
714714
715715 var preflightClient client.Client
716716 metadata := & api.AgentMetadata {Version : version .PreflightVersion , ClusterID : cfg .ClusterID }
717- switch {
718- case cfg . TLSPKMode == JetstackSecureOAuth :
717+ switch cfg . TLSPKMode {
718+ case JetstackSecureOAuth :
719719 // Note that there are no command line flags to configure the
720720 // JetstackSecureOAuth mode.
721721 credsBytes , err := readCredentialsFile (flagCredentialsPath )
@@ -734,7 +734,7 @@ func validateCredsAndCreateClient(log logr.Logger, flagCredentialsPath, flagClie
734734 if err != nil {
735735 errs = multierror .Append (errs , err )
736736 }
737- case cfg . TLSPKMode == VenafiCloudKeypair :
737+ case VenafiCloudKeypair :
738738 var creds client.Credentials
739739
740740 if flagClientID != "" && flagCredentialsPath != "" {
@@ -777,7 +777,7 @@ func validateCredsAndCreateClient(log logr.Logger, flagCredentialsPath, flagClie
777777 if err != nil {
778778 errs = multierror .Append (errs , err )
779779 }
780- case cfg . TLSPKMode == VenafiCloudVenafiConnection :
780+ case VenafiCloudVenafiConnection :
781781 var restCfg * rest.Config
782782 restCfg , err := kubeconfig .LoadRESTConfig ("" )
783783 if err != nil {
@@ -789,13 +789,13 @@ func validateCredsAndCreateClient(log logr.Logger, flagCredentialsPath, flagClie
789789 if err != nil {
790790 errs = multierror .Append (errs , err )
791791 }
792- case cfg . TLSPKMode == JetstackSecureAPIToken :
792+ case JetstackSecureAPIToken :
793793 var err error
794794 preflightClient , err = client .NewAPITokenClient (metadata , flagAPIToken , cfg .Server )
795795 if err != nil {
796796 errs = multierror .Append (errs , err )
797797 }
798- case cfg . TLSPKMode == Off :
798+ case Off :
799799 // No client needed in this mode.
800800 default :
801801 panic (fmt .Errorf ("programmer mistake: auth mode not implemented: %s" , cfg .TLSPKMode ))
0 commit comments