fix: Jira init broken due to authtype value (#694)
This commit is contained in:
parent
54cec0a650
commit
e2f453382e
|
@ -77,7 +77,7 @@ func NewCmdRoot() *cobra.Command {
|
|||
return
|
||||
}
|
||||
|
||||
// mtls doesn't need Jira API Token
|
||||
// mTLS doesn't need Jira API Token.
|
||||
if viper.GetString("auth_type") != string(jira.AuthTypeMTLS) {
|
||||
checkForJiraToken(viper.GetString("server"), viper.GetString("login"))
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ type issueTypeFieldConf struct {
|
|||
}
|
||||
}
|
||||
|
||||
// MTLS authtype specific config.
|
||||
// JiraCLIMTLSConfig is an authtype specific config.
|
||||
type JiraCLIMTLSConfig struct {
|
||||
CaCert string
|
||||
ClientCert string
|
||||
|
@ -232,7 +232,7 @@ func (c *JiraCLIConfigGenerator) configureLocalAuthType() error {
|
|||
}
|
||||
}
|
||||
|
||||
if authType == strings.ToLower(jira.AuthTypeMTLS.String()) {
|
||||
if authType == jira.AuthTypeMTLS.String() {
|
||||
c.value.authType = jira.AuthTypeMTLS
|
||||
} else {
|
||||
c.value.authType = jira.AuthTypeBasic
|
||||
|
|
|
@ -96,7 +96,7 @@ func (e Errors) String() string {
|
|||
// Header is a key, value pair for request headers.
|
||||
type Header map[string]string
|
||||
|
||||
// MTLS authtype specific config.
|
||||
// MTLSConfig is MTLS authtype specific config.
|
||||
type MTLSConfig struct {
|
||||
CaCert string
|
||||
ClientCert string
|
||||
|
@ -261,9 +261,12 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body []by
|
|||
req.Header.Set(k, v)
|
||||
}
|
||||
|
||||
if c.authType == AuthTypeBearer {
|
||||
// When need to compare using `String()` here, it is used to handle cases where the
|
||||
// authentication type might be empty, ensuring it defaults to the appropriate value.
|
||||
switch c.authType.String() {
|
||||
case string(AuthTypeBearer):
|
||||
req.Header.Add("Authorization", "Bearer "+c.token)
|
||||
} else if c.authType == AuthTypeBasic {
|
||||
case string(AuthTypeBasic):
|
||||
req.SetBasicAuth(c.login, c.token)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue