utils

package
v0.0.0-...-c4fe937 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 20 * time.Second

Variables

This section is empty.

Functions

func ConfigInstance

func ConfigInstance() interface{}

func GetConfig

func GetConfig(connection *plugin.Connection) crcConfig

GetConfig :: retrieve and cast connection config from query data

func GetConsoleDotClient

func GetConsoleDotClient(_ context.Context, d *plugin.QueryData, timeout time.Duration) (*http.Client, error)

GetConsoleDotClient returns an HTTP client with SSO authentication for the console.redhat.com APIs

func LogErrorUsingSteampipeLogger

func LogErrorUsingSteampipeLogger(ctx context.Context, table, errType string, err error)

LogErrorUsingSteampipeLogger logs an error using the steampipe logger

func MakeAPIRequest

func MakeAPIRequest(ctx context.Context, d *plugin.QueryData, method, endpoint string, body interface{}, timeout time.Duration) (*http.Response, error)

MakeAPIRequest makes an API request to the specified endpoint

Types

type SSOClient

type SSOClient struct {
	ClientID     string
	ClientSecret string
	Token        string
	TokenURL     string
	TokenExpiry  time.Time
	sync.Mutex
	Transport http.RoundTripper
}

SSOClient struct to hold SSO credentials and token

func NewSSOClient

func NewSSOClient(clientID, clientSecret, tokenURL string) *SSOClient

NewSSOClient creates a new SSOClient

func (*SSOClient) RoundTrip

func (c *SSOClient) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

TokenResponse struct to unmarshal the token response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL