Documentation
¶
Index ¶
Constants ¶
View Source
const ( //CM login url CMLoginURL = "/api/login" CMVersionURL = "/api/v1/system/infra/info" CMAccessTokenExpiration = 5 * time.Minute TokenFetchFailed = "Failed to fetch token" Ok = "OK" RetryInterval = time.Duration(10) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
Credentials represent the username and password used for authentication.
type TokenManager ¶
type TokenManager struct { ServerURL string SslInsecure bool TrustedCerts string CMVersion string StatusManager statusmanager.StatusManagerInterface // contains filtered or unexported fields }
TokenManager is responsible for managing the authentication token.
func NewTokenManager ¶
func NewTokenManager(serverURL string, credentials Credentials, trustedCerts string, sslInsecure bool, statusManager statusmanager.StatusManagerInterface) *TokenManager
NewTokenManager creates a new instance of TokenManager.
func (*TokenManager) GetCMVersion ¶
func (tm *TokenManager) GetCMVersion() (string, error)
func (*TokenManager) GetToken ¶
func (tm *TokenManager) GetToken() string
GetToken returns the current valid saved token.
func (*TokenManager) Start ¶
func (tm *TokenManager) Start(stopCh chan struct{})
Start maintains valid token. It fetches a new token before expiry.
func (*TokenManager) SyncToken ¶
func (tm *TokenManager) SyncToken()
SyncToken is a helper function to fetch token and retry on failure
func (*TokenManager) SyncTokenWithoutRetry ¶
func (tm *TokenManager) SyncTokenWithoutRetry() (err error, exit bool)
SyncTokenWithoutRetry retrieves a new token from the CM.
type TokenResponse ¶
type TokenResponse struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` UserID string `json:"user_id"` }
TokenResponse represents the response received from the CM.
Click to show internal directories.
Click to hide internal directories.