pkg

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#d8292f"))
View Source
var SuccessStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#2d9f44"))
View Source
var WarningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#fcba19"))

Functions

func AppId

func AppId(length int) string

func ArgumentsSliceToString

func ArgumentsSliceToString(args []string, separator string) string

func Checkmark

func Checkmark() string

func ClientCredentialLogin

func ClientCredentialLogin(tokenEndpoint string, clientId string, clientSecret string) error

func ClientCredentialsLogin

func ClientCredentialsLogin(ctx *AppContext, clientId string, clientSecret string) error

func DeviceLogin

func DeviceLogin(ctx *AppContext) error

func Indeterminate

func Indeterminate() string

func KebabCase

func KebabCase(str string) string

func LookupKind

func LookupKind(data []byte) string

func NewSpinner

func NewSpinner() *spinner.Spinner

func NewTemplate

func NewTemplate() *template.Template

func PrintError

func PrintError(output string) string

func PrintSuccess

func PrintSuccess(output string) string

func PrintWarning

func PrintWarning(output string) string

func RefreshToken

func RefreshToken(ctx *AppContext) error

func SaveConfig

func SaveConfig(data *TokenResponse) error

func SplitYAML

func SplitYAML(resources []byte) ([][]byte, error)

func StartCase

func StartCase(str string) string

Define a custom function to capitalize the first letter of a string.

func Times

func Times() string

Types

type ApiErrorResponse

type ApiErrorResponse struct {
	Error        string `json:"error"`
	ErrorMessage string `json:"error_description"`
	Message      string `json:"message"`
	Details      struct {
		Item struct {
			Message string `json:"message"`
		} `json:"d0"`
	} `json:"details"`
}

API error parsing

func (*ApiErrorResponse) GetError

func (e *ApiErrorResponse) GetError() error

type ApiResponse

type ApiResponse[T any] struct {
	StatusCode int
	Data       T
}

type AppContext

type AppContext struct {
	ApiHost    string
	ApiKey     string
	Auth       AuthDetails
	AppVersion int
	ClientId   string
	Cwd        string
	Host       string
	Namespace  string
	Scheme     string
	Version    string
}

func (*AppContext) CreateUrl

func (a *AppContext) CreateUrl(path string, params interface{}) (string, error)

type AuthDetails

type AuthDetails struct {
	Token string
}

type DeviceData

type DeviceData struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationUri         string `json:"verification_uri"`
	VerificationUriComplete string `json:"verification_uri_complete"`
}

type FS

type FS struct{}

func (*FS) Stat

func (*FS) Stat(name string) (os.FileInfo, error)

func (*FS) WriteFile

func (*FS) WriteFile(name string, data []byte, perm os.FileMode) error

type NewApi

type NewApi[T any] struct {
	Request *http.Request
	// contains filtered or unexported fields
}

func NewApiDelete

func NewApiDelete[T any](ctx *AppContext, url string) (*NewApi[T], error)

func NewApiGet

func NewApiGet[T any](ctx *AppContext, url string) (*NewApi[T], error)

Convience methods

func NewApiPost

func NewApiPost[T any](ctx *AppContext, url string, body io.Reader) (*NewApi[T], error)

func NewApiPut

func NewApiPut[T any](ctx *AppContext, url string, body io.Reader) (*NewApi[T], error)

func (*NewApi[T]) Do

func (m *NewApi[T]) Do() (ApiResponse[T], error)

func (*NewApi[T]) New

func (m *NewApi[T]) New() (*NewApi[T], error)

Using the std `http.NewRequest` pattern, `New` instaniates a request

type OpenApi

type OpenApi struct {
	Components struct {
		SecuritySchemes struct {
			OpenId struct {
				OpenIdConnectUrl string `yaml:"openIdConnectUrl"`
			} `yaml:"openid"`
			Oauth2 struct {
				Flows struct {
					ClientCredentials struct {
						TokenUrl string `yaml:"tokenUrl"`
					} `yaml:"clientCredentials"`
				} `yaml:"flows"`
			} `yaml:"oauth2"`
		} `yaml:"securitySchemes"`
	} `yaml:"components"`
}

type T

type T struct {
	Kind string `yaml:"kind"`
}

type TokenRequestError

type TokenRequestError struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int16  `json:"expires_in"`
	RefreshExpiresIn int32  `json:"refresh_expires_in"`
	RefreshToken     string `json:"refresh_token"`
	TokenType        string `json:"token_type"`
	SessionState     string `json:"session_state"`
	Scope            string `json:"scope"`
}

type WellKnownConfig

type WellKnownConfig struct {
	ClientCredentials           string `json:"client_credentials"`
	TokenEndpoint               string `json:"token_endpoint"`
	DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
}

Jump to

Keyboard shortcuts

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