cli

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ApplicationJSON = "application/json"
View Source
const MultipartFormData = "multipart/form-data"
View Source
const (
	Version = "v2.0.0"
)

Variables

View Source
var ErrNoConfigFile = errors.New("pangea Token doesn't exist. Run `pangea login` to setup your CLI")
View Source
var ErrUnauthorized = errors.New("unauthorized token")

Functions

func CacheSetPaths

func CacheSetPaths(paths Paths) error

func CacheSetRelease

func CacheSetRelease(r *Release) error

func CreateProfile

func CreateProfile(profileName string) error

func DeleteProfile

func DeleteProfile(profileName string) error

func GetCacheFilename

func GetCacheFilename(u string) (string, error)

func GetCacheFolder

func GetCacheFolder() (string, error)

func GetCurrentProfileName

func GetCurrentProfileName() (string, error)

func GetDaySinceEpoch

func GetDaySinceEpoch() string

func GetDefaultPangeaConfig

func GetDefaultPangeaConfig() pangea.Config

func GetLogger

func GetLogger() *log.Logger

func GetProfileTokenAndDomain

func GetProfileTokenAndDomain(profile, service string) (string, string, error)

func GetTokenAndDomain

func GetTokenAndDomain(service string) (string, string, error)

func IndentedString

func IndentedString(obj any) (string, error)

func ListProfiles

func ListProfiles() ([]string, error)

func LoadFromCache

func LoadFromCache(u string) []byte

func PrettyPrint

func PrettyPrint(obj any)

func ReadAsCSV

func ReadAsCSV(val string) ([]string, error)

func ReadStdin

func ReadStdin() string

ReadStdin reads user input from the command line

func RemoveCacheFolder

func RemoveCacheFolder() error

func RemoveCachedFileFromURL

func RemoveCachedFileFromURL(url string) error

func SaveDomain

func SaveDomain(profile, service, domain string) error

func SaveToCache

func SaveToCache(u string, data []byte) error

func SaveToken

func SaveToken(profile, service, token string) error

writeTokenToFile writes the Pangea token to the specified file

func SelectProfile

func SelectProfile(profileName string) error

Types

type CacheData

type CacheData struct {
	Paths            map[string]WorkspaceData `json:"paths"`
	VersionAvailable map[string]*Release      `json:"version_available"`
}

func LoadCacheData

func LoadCacheData() (*CacheData, error)

type Components

type Components struct {
	Schemas map[string]json.RawMessage `json:"schemas"`
}

type ConfigFile

type ConfigFile struct {
	Title    string             `mapstructure:"title"`
	Version  string             `mapstructure:"version"`
	Profile  string             `mapstructure:"profile"`
	Profiles map[string]Profile `mapstructure:"profiles"`
}

func (*ConfigFile) GetTokenAndDomain

func (cf *ConfigFile) GetTokenAndDomain(profile, service string) (string, string, error)

func (*ConfigFile) SetDomain

func (cf *ConfigFile) SetDomain(profile, service, domain string)

func (*ConfigFile) SetToken

func (cf *ConfigFile) SetToken(profile, service, token string)

type Content

type Content map[string]struct {
	Schema *Schema `json:"schema"`
}

type Discriminator

type Discriminator struct {
	PropertyName string            `json:"propertyName"`
	Mapping      map[string]Schema `json:"mapping"`
}

type OpenAPI

type OpenAPI struct {
	Status *string

	Paths      map[string]Path `json:"paths"`
	Components Components      `json:"components"`
	// contains filtered or unexported fields
}

func LoadFile

func LoadFile(fname string, url string) (*OpenAPI, error)

func LoadReader

func LoadReader(r io.Reader, url string) (*OpenAPI, error)

func LoadURL

func LoadURL(u string) (*OpenAPI, error)

func Unmarshal

func Unmarshal(s []byte) (*OpenAPI, error)

type Path

type Path struct {
	Post PathPost `json:"post"`
}

type PathPost

type PathPost struct {
	ID              string              `json:"operationId"`
	Summary         string              `json:"summary"`
	Description     string              `json:"description"`
	Tags            []string            `json:"tags"`
	RequestBody     RequestBody         `json:"requestBody"`
	Responses       map[string]Response `json:"responses"`
	XPangeaUISchema *XPangeaUISchema    `json:"x-pangea-ui-schema"`
}

type Paths

type Paths map[string]WorkspaceData

Key: path in lower case. Value: WorkspaceData

func CacheGetPaths

func CacheGetPaths() (Paths, error)

type Profile

type Profile map[string]Service

func GetCurrentProfile

func GetCurrentProfile() (*Profile, string, error)

type Properties

type Properties map[string]Property

type Property

type Property struct {
	Ref string `json:"$ref"`

	Type        json.RawMessage `json:"type"` // TODO: this can be a string or an array of strings
	Default     any             `json:"default"`
	Description string          `json:"description"`
	Format      string          `json:"format"`
	Enum        []any           `json:"enum"`
	Const       any             `json:"const"`
}

type Release

type Release struct {
	// Version is the version of the release
	Version string `json:"version"`

	// AssetURL is a URL to the uploaded file for the release
	AssetURL string `json:"asset_url"`

	// URL is a URL to release page for browsing
	URL string `json:"url"`

	// ReleaseNotes is a release notes of the release
	ReleaseNotes string `json:"release_notes"`

	// Name represents a name of the release
	Name string `json:"name"`

	// PublishedAt is the time when the release was published
	PublishedAt string `json:"published_at"`
}

Release represents a release asset for current OS and arch.

func CacheGetRelease

func CacheGetRelease() (*Release, error)

func NewRelease

func NewRelease(r *selfupdate.Release) *Release

type RequestBody

type RequestBody struct {
	Content Content `json:"content"`
}

type Response

type Response struct {
	Description string  `json:"description"`
	Content     Content `json:"content"`
}

type Schema

type Schema struct {
	Ref           string         `json:"$ref"`
	OneOf         []Schema       `json:"oneOf"`
	AnyOf         []Schema       `json:"anyOf"`
	Discriminator *Discriminator `json:"discriminator"`

	Title       string     `json:"title"`
	Description string     `json:"description"`
	Required    []string   `json:"required"`
	Properties  Properties `json:"properties"`
}

type Service

type Service struct {
	Domain string `mapstructure:"domain"`
	Token  string `mapstructure:"token"`
}

type VersionAvailable

type VersionAvailable map[string]Release

Key: DaySinceEpoch. Value: Version available

type WorkspaceData

type WorkspaceData struct {
	Remote string `json:"remote"`
}

type XPangeaUISchema

type XPangeaUISchema struct {
	IsConfiguration *bool `json:"isConfiguration"`
}

Jump to

Keyboard shortcuts

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