cmd

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const CHECK_VERSION_INTERVAL = time.Duration(24 * time.Hour)
View Source
const CONFIG_FILE_DIR = "ivcap-cli"

Names for config dir and file - stored in the os.UserConfigDir() directory

View Source
const CONFIG_FILE_NAME = "config.yaml"
View Source
const DEF_CHUNK_SIZE = 1000000 // -1 ... no chunking
View Source
const ENV_PREFIX = "IVCAP"
View Source
const HISTORY_FILE_NAME = "history.yaml"
View Source
const MAX_NAME_COL_LEN = 30

Max characters to limit name to

View Source
const RELEASE_CHECK_URL = "https://github.com/reinventingscience/ivcap-cli/releases/latest"
View Source
const URN_PREFIX = "ivcap"
View Source
const VERSION_CHECK_FILE_NAME = "vcheck.txt"

Variables

View Source
var ACCESS_TOKEN_ENV = ENV_PREFIX + "_ACCESS_TOKEN"

Functions

func CreateAdapter

func CreateAdapter(requiresAuth bool) (adapter *adpt.Adapter)

func CreateAdapterWithTimeout

func CreateAdapterWithTimeout(requiresAuth bool, timeoutSec int) (adapter *adpt.Adapter)

Returns an HTTP adapter which will wait a max. of `timeoutSec` sec for a reply. It also pre-configures the adapter in the following way:

  • If `requiresAuth` is set, each outgoing request includes an `Authorization` header with a 'Bearer' token provided either via the `--access-token` flag, the IVCAP_ACCESS_TOKEN environment, or the AccessToken from the ActiveContext.
  • If the `path` parameter for any of the adapter calls is NOT a fully fledged URL, the URL defined in ActiveContext is automatically prefixed.
  • If the ActiveContext defines a `Host` parameter, it is also added as a `Host` HTTP header.

func Execute

func Execute(version string)

func GetConfigDir

func GetConfigDir(createIfNoExist bool) (configDir string)

func GetConfigFilePath

func GetConfigFilePath() (path string)

func GetHistory

func GetHistory(token string) (value string)

func GetServiceNameForId

func GetServiceNameForId(serviceID *string) string

func IsAuthorised

func IsAuthorised() bool

func Logger

func Logger() *log.Logger

func MakeHistory

func MakeHistory(urn *string) string

func MakeMaybeHistory

func MakeMaybeHistory(sp *string) string

Check if argument is an IVCAP urn and if it is, turn it into a history.

func NewAdapter

func NewAdapter(
	url string,
	accessToken string,
	timeoutSec int,
	headers *map[string]string,
) (*adpt.Adapter, error)

func NewTimeoutContext

func NewTimeoutContext() (ctxt context.Context)

func ParseIDToken

func ParseIDToken(tokenResponse *deviceTokenResponse, ctxt *Context, jwksURL string)

func SetContext

func SetContext(ctxt *Context, failIfNotExist bool)

func SetLogger

func SetLogger(l *log.Logger)

func WriteConfigFile

func WriteConfigFile(config *Config)

Types

type AppError

type AppError struct {
	// contains filtered or unexported fields
}

func (*AppError) Error

func (e *AppError) Error() string

type ArtifactPostResponse

type ArtifactPostResponse struct {
	// Artifact ID
	ID string `form:"id" json:"id" xml:"id"`
	// Optional name
	Name string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
	// Artifact status
	Status string `form:"status" json:"status" xml:"status"`
	// Mime-type of data
	MimeType string `form:"mime-type,omitempty" json:"mime-type,omitempty" xml:"mime-type,omitempty"`
	// Size of data
	Size int64 `form:"size,omitempty" json:"size,omitempty" xml:"size,omitempty"`
}

type AuthInfo

type AuthInfo struct {
	Version      int              `yaml:"version"`
	ProviderList AuthProviderInfo `yaml:"auth"`
}

type AuthProvider

type AuthProvider struct {
	ID       string `yaml:"id,omitempty"`
	LoginURL string `yaml:"login-url"`
	TokenURL string `yaml:"token-url"`
	CodeURL  string `yaml:"code-url"`
	JwksURL  string `yaml:"jwks-url"`
	ClientID string `yaml:"client-id"`
	// contains filtered or unexported fields
}

type AuthProviderInfo

type AuthProviderInfo struct {
	DefaultProviderId string                  `yaml:"default-provider-id"`
	AuthProviders     map[string]AuthProvider `yaml:"providers"`
}

type CaddyFaultResponse

type CaddyFaultResponse struct {
	Name      string
	Id        string
	Message   string
	Temporary bool
	Timeout   bool
	Fault     bool
}

type Config

type Config struct {
	Version       string    `yaml:"version"`
	ActiveContext string    `yaml:"active-context"`
	Contexts      []Context `yaml:"contexts"`
}

func ReadConfigFile

func ReadConfigFile(createIfNoConfig bool) (config *Config, configFile string)

type Context

type Context struct {
	ApiVersion int    `yaml:"api-version"`
	Name       string `yaml:"name"`
	URL        string `yaml:"url"`
	AccountID  string `yaml:"account-id"`
	ProviderID string `yaml:"provider-id"`
	Host       string `yaml:"host"` // set Host header if necessary

	// User Information
	AccountName     string `yaml:"account-name"`
	AccountNickName string `yaml:"account-nickname"`
	Email           string `yaml:"email"`

	// Cached Credentials
	AccessToken       string    `yaml:"access-token"`
	AccessTokenExpiry time.Time `yaml:"access-token-expiry"`
	RefreshToken      string    `yaml:"refresh-token"`
}

func GetActiveContext

func GetActiveContext() (ctxt *Context)

func GetContext

func GetContext(name string, defaultToActiveContext bool) (ctxt *Context)

type CustomIdClaims

type CustomIdClaims struct {
	Name          string   `json:"name,omitempty"`
	Nickname      string   `json:"nickname,omitempty"`
	Email         string   `json:"email,omitempty"`
	EmailVerified bool     `json:"email_verified,omitempty"`
	Avatar        string   `json:"picture,omitempty"`
	AccountID     string   `json:"acc"`
	ProviderID    string   `json:"ivcap/claims/provider,omitempty"`
	GroupIDs      []string `json:"ivcap/claims/groupIds,omitempty"`
	jwt.RegisteredClaims
}

type DeviceCode

type DeviceCode struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURL         string `json:"verification_uri"`
	VerificationURLComplete string `json:"verification_uri_complete"`
	ExpiresIn               int64  `json:"expires_in"`
	Interval                int64  `json:"interval"`
}

Jump to

Keyboard shortcuts

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