...

Package state

Overview ▾

Package state gives access to the state of the odo process stored in a local file The state of an instance is stored in a file .odo/devstate.${PID}.json. For compatibility with previous versions of odo, the `devstate.json` file contains the state of the first instance of odo.

type Client

type Client interface {
    // Init creates a devstate file for the process
    Init(ctx context.Context) error

    // SetForwardedPorts sets the forwarded ports in the state file and saves it to the file, updating the metadata
    SetForwardedPorts(ctx context.Context, fwPorts []api.ForwardedPort) error

    // GetForwardedPorts returns the ports forwarded by the current odo dev session
    GetForwardedPorts(ctx context.Context) ([]api.ForwardedPort, error)

    // SaveExit resets the state file to indicate odo is not running
    SaveExit(ctx context.Context) error

    // SetAPIServerPort sets the port where API server is listening in the state file and saves it to the file, updating the metadata
    SetAPIServerPort(ctx context.Context, port int) error

    // GetAPIServerPorts returns the port where the API servers are listening, possibly per platform.
    GetAPIServerPorts(ctx context.Context) ([]api.DevControlPlane, error)

    GetOrphanFiles(ctx context.Context) ([]string, error)
}

type Content

type Content struct {
    // PID is the ID of the process to which the state belongs
    PID int `json:"pid"`
    // Platform indicates on which platform the session works
    Platform string `json:"platform"`
    // ForwardedPorts are the ports forwarded during odo dev session
    ForwardedPorts []api.ForwardedPort `json:"forwardedPorts"`
    APIServerPort  int                 `json:"apiServerPort,omitempty"`
}

type ErrAlreadyRunningOnPlatform

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

func NewErrAlreadyRunningOnPlatform

func NewErrAlreadyRunningOnPlatform(platform string, pid int) ErrAlreadyRunningOnPlatform

func (ErrAlreadyRunningOnPlatform) Error

func (e ErrAlreadyRunningOnPlatform) Error() string

type State

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

func NewStateClient

func NewStateClient(fs filesystem.Filesystem, system system.System) *State

func (*State) GetAPIServerPorts

func (o *State) GetAPIServerPorts(ctx context.Context) ([]api.DevControlPlane, error)

func (*State) GetForwardedPorts

func (o *State) GetForwardedPorts(ctx context.Context) ([]api.ForwardedPort, error)

func (*State) GetOrphanFiles

func (o *State) GetOrphanFiles(ctx context.Context) ([]string, error)

func (*State) Init

func (o *State) Init(ctx context.Context) error

func (*State) SaveExit

func (o *State) SaveExit(ctx context.Context) error

func (*State) SetAPIServerPort

func (o *State) SetAPIServerPort(ctx context.Context, port int) error

func (*State) SetForwardedPorts

func (o *State) SetForwardedPorts(ctx context.Context, fwPorts []api.ForwardedPort) error