contextmanager

package
v0.0.0-...-84fb89b Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFilename = ".uptimectl.yaml"
)

Variables

View Source
var (
	ErrContextNotFound = errors.New("context not found")
)
View Source
var (
	OrganisationFlag string
)

Functions

func APIEndpoint

func APIEndpoint() string

func AddOrMergeContext

func AddOrMergeContext(context Context) error

func BetteruptimeToken

func BetteruptimeToken() string

func Init

func Init()

func Load

func Load() error

func NewConfigFileContextManager

func NewConfigFileContextManager(filename string) *configFileContextManager

func Organisation

func Organisation() string

func Save

func Save() error

func SetCurrentContext

func SetCurrentContext(name string) error

Types

type API

type API struct {
	URL string `yaml:"url"`
}

type APIs

type APIs struct {
	Name string `yaml:"name"`
	API  API    `yaml:"api"`
}

type Config

type Config struct {
	ConfigVersion  string        `yaml:"configVersion"`
	Contexts       []ContextRefs `yaml:"contexts"`
	CurrentContext string        `yaml:"current-context"`
	APIs           []APIs        `yaml:"apis"`
	Users          []Users       `yaml:"users"`
}

type Context

type Context struct {
	Name         string
	Organisation string
	API          APIs
	User         Users
}

func CurrentContext

func CurrentContext() Context

type ContextManager

type ContextManager interface {
	CurrentContext() Context
	HasCurrentContext() bool
	SetCurrentContext(name string) error
	AddOrMergeContext(context Context) error

	RenameAPI(oldName, newName string) error
	RenameContext(oldName, newName string) error
	RenameUser(oldName, newName string) error

	Load() error
	Save() error
	Config() Config
}

func GlobalContextManager

func GlobalContextManager() ContextManager

type ContextRef

type ContextRef struct {
	API          string `yaml:"api"`
	User         string `yaml:"user"`
	Organisation string `yaml:"organisation"`
}

type ContextRefs

type ContextRefs struct {
	Name    string     `yaml:"name"`
	Context ContextRef `yaml:"context"`
}

type User

type User struct {
	BetterUptimeToken string `yaml:"token"`
}

type Users

type Users struct {
	Name string `yaml:"name"`
	User User   `yaml:"user"`
}

Jump to

Keyboard shortcuts

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