cpctl

package
v0.0.0-...-d6f7367 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const GetConfigDocument = `query GetConfig {
	config {
		yaml
		signature
	}
}
`
View Source
const GetNetnsDocument = `query GetNetns ($name: String) {
	netns(filter: {name:$name}) {
		name
		pid
	}
}
`
View Source
const GetStatusDocument = `` /* 242-byte string literal not displayed */
View Source
const SetConfigDocument = `mutation SetConfig ($input: ConfigUpdateInput!) {
	updateConfig(config: $input) {
		mutationId
	}
}
`

Variables

View Source
var DocumentOperationNames = map[string]string{
	GetConfigDocument: "GetConfig",
	SetConfigDocument: "SetConfig",
	GetNetnsDocument:  "GetNetns",
	GetStatusDocument: "GetStatus",
}
View Source
var ErrMultipleNode = fmt.Errorf("multiple running nodes found")
View Source
var ErrMultipleSSHKeys = fmt.Errorf("multiple SSH keys found; use --text to select one uniquely")
View Source
var ErrNoNode = fmt.Errorf("no running node found")
View Source
var ErrNoSSHKeys = fmt.Errorf("no SSH keys found")

Functions

func FindSocket

func FindSocket(socketNode string) (string, error)

func FindSockets

func FindSockets(socketNode string) ([]string, error)

func GenToken

func GenToken(keyFile string, keyText string, tokenDuration string) (string, error)

GenToken generates a token by either communicating with an agent, or loading the key from keyFile.

func GenTokenFromAgent

func GenTokenFromAgent(a agent.Agent, keyText string, tokenDuration string) (string, error)

GenTokenFromAgent generates a token from an already-open agent using a key matching keyText

func GetUsableKey

func GetUsableKey(a agent.Agent, keyText string) (string, error)

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type Client

type Client struct {
	Client *clientv2.Client
}

func NewClient

func NewClient(cli *http.Client, baseURL string, options *clientv2.Options, interceptors ...clientv2.RequestInterceptor) *Client

func NewSocketClient

func NewSocketClient(socketFile string, socketNode string, authToken string, proxyTo string) (*Client, error)

NewSocketClient creates a new socket client using a given auth token

func NewTokenAndSocketClient

func NewTokenAndSocketClient(socketFile string, socketNode string, keyFile string, keyText string, tokenDuration string, proxyTo string) (*Client, error)

NewTokenAndSocketClient generates a token and then uses it to create a new socket client

func (*Client) GetConfig

func (c *Client) GetConfig(ctx context.Context, interceptors ...clientv2.RequestInterceptor) (*GetConfig, error)

func (*Client) GetNetns

func (c *Client) GetNetns(ctx context.Context, name *string, interceptors ...clientv2.RequestInterceptor) (*GetNetns, error)

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, interceptors ...clientv2.RequestInterceptor) (*GetStatus, error)

func (*Client) SetConfig

func (c *Client) SetConfig(ctx context.Context, input ConfigUpdateInput, interceptors ...clientv2.RequestInterceptor) (*SetConfig, error)

type ComplexityRoot

type ComplexityRoot struct {
	ConfigResult struct {
		Signature func(childComplexity int) int
		Yaml      func(childComplexity int) int
	}

	ConfigUpdateResult struct {
		MutationID func(childComplexity int) int
	}

	Mutation struct {
		UpdateConfig func(childComplexity int, config ConfigUpdateInput) int
	}

	NetnsResult struct {
		Name func(childComplexity int) int
		Pid  func(childComplexity int) int
	}

	Query struct {
		Config func(childComplexity int) int
		Netns  func(childComplexity int, filter *NetnsFilter) int
		Status func(childComplexity int) int
	}

	Status struct {
		Addr     func(childComplexity int) int
		Global   func(childComplexity int) int
		Name     func(childComplexity int) int
		Nodes    func(childComplexity int) int
		Sessions func(childComplexity int) int
	}

	StatusGlobal struct {
		AuthorizedKeys    func(childComplexity int) int
		ConfigLastUpdated func(childComplexity int) int
		Domain            func(childComplexity int) int
		Subnet            func(childComplexity int) int
	}

	StatusNode struct {
		Addr  func(childComplexity int) int
		Conns func(childComplexity int) int
		Name  func(childComplexity int) int
	}

	StatusNodeConn struct {
		Cost   func(childComplexity int) int
		Subnet func(childComplexity int) int
	}

	StatusSession struct {
		Addr      func(childComplexity int) int
		ConnStart func(childComplexity int) int
		Connected func(childComplexity int) int
	}
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type ConfigResult

type ConfigResult struct {
	Yaml      string `json:"yaml"`
	Signature string `json:"signature"`
}

type ConfigUpdateInput

type ConfigUpdateInput struct {
	Yaml      string `json:"yaml"`
	Signature string `json:"signature"`
}

type ConfigUpdateResult

type ConfigUpdateResult struct {
	MutationID string `json:"mutationId"`
}

type DirectiveRoot

type DirectiveRoot struct {
}

type GetConfig

type GetConfig struct {
	Config GetConfig_Config "json:\"config\" graphql:\"config\""
}

func (*GetConfig) GetConfig

func (t *GetConfig) GetConfig() *GetConfig_Config

type GetConfig_Config

type GetConfig_Config struct {
	Yaml      string "json:\"yaml\" graphql:\"yaml\""
	Signature string "json:\"signature\" graphql:\"signature\""
}

func (*GetConfig_Config) GetSignature

func (t *GetConfig_Config) GetSignature() string

func (*GetConfig_Config) GetYaml

func (t *GetConfig_Config) GetYaml() string

type GetNetns

type GetNetns struct {
	Netns []*GetNetns_Netns "json:\"netns\" graphql:\"netns\""
}

func (*GetNetns) GetNetns

func (t *GetNetns) GetNetns() []*GetNetns_Netns

type GetNetns_Netns

type GetNetns_Netns struct {
	Name string "json:\"name\" graphql:\"name\""
	Pid  int    "json:\"pid\" graphql:\"pid\""
}

func (*GetNetns_Netns) GetName

func (t *GetNetns_Netns) GetName() string

func (*GetNetns_Netns) GetPid

func (t *GetNetns_Netns) GetPid() int

type GetStatus

type GetStatus struct {
	Status GetStatus_Status "json:\"status\" graphql:\"status\""
}

func (*GetStatus) GetStatus

func (t *GetStatus) GetStatus() *GetStatus_Status

type GetStatus_Status

type GetStatus_Status struct {
	Name     string                       "json:\"name\" graphql:\"name\""
	Addr     string                       "json:\"addr\" graphql:\"addr\""
	Global   GetStatus_Status_Global      "json:\"global\" graphql:\"global\""
	Nodes    []*GetStatus_Status_Nodes    "json:\"nodes\" graphql:\"nodes\""
	Sessions []*GetStatus_Status_Sessions "json:\"sessions\" graphql:\"sessions\""
}

func (*GetStatus_Status) GetAddr

func (t *GetStatus_Status) GetAddr() string

func (*GetStatus_Status) GetGlobal

func (t *GetStatus_Status) GetGlobal() *GetStatus_Status_Global

func (*GetStatus_Status) GetName

func (t *GetStatus_Status) GetName() string

func (*GetStatus_Status) GetNodes

func (t *GetStatus_Status) GetNodes() []*GetStatus_Status_Nodes

func (*GetStatus_Status) GetSessions

func (t *GetStatus_Status) GetSessions() []*GetStatus_Status_Sessions

type GetStatus_Status_Global

type GetStatus_Status_Global struct {
	Domain            string    "json:\"domain\" graphql:\"domain\""
	Subnet            string    "json:\"subnet\" graphql:\"subnet\""
	AuthorizedKeys    []string  "json:\"authorized_keys\" graphql:\"authorized_keys\""
	ConfigLastUpdated time.Time "json:\"config_last_updated\" graphql:\"config_last_updated\""
}

func (*GetStatus_Status_Global) GetAuthorizedKeys

func (t *GetStatus_Status_Global) GetAuthorizedKeys() []string

func (*GetStatus_Status_Global) GetConfigLastUpdated

func (t *GetStatus_Status_Global) GetConfigLastUpdated() *time.Time

func (*GetStatus_Status_Global) GetDomain

func (t *GetStatus_Status_Global) GetDomain() string

func (*GetStatus_Status_Global) GetSubnet

func (t *GetStatus_Status_Global) GetSubnet() string

type GetStatus_Status_Nodes

type GetStatus_Status_Nodes struct {
	Name  string                          "json:\"name\" graphql:\"name\""
	Addr  string                          "json:\"addr\" graphql:\"addr\""
	Conns []*GetStatus_Status_Nodes_Conns "json:\"conns\" graphql:\"conns\""
}

func (*GetStatus_Status_Nodes) GetAddr

func (t *GetStatus_Status_Nodes) GetAddr() string

func (*GetStatus_Status_Nodes) GetConns

func (*GetStatus_Status_Nodes) GetName

func (t *GetStatus_Status_Nodes) GetName() string

type GetStatus_Status_Nodes_Conns

type GetStatus_Status_Nodes_Conns struct {
	Subnet string  "json:\"subnet\" graphql:\"subnet\""
	Cost   float64 "json:\"cost\" graphql:\"cost\""
}

func (*GetStatus_Status_Nodes_Conns) GetCost

func (*GetStatus_Status_Nodes_Conns) GetSubnet

func (t *GetStatus_Status_Nodes_Conns) GetSubnet() string

type GetStatus_Status_Sessions

type GetStatus_Status_Sessions struct {
	Addr      string "json:\"addr\" graphql:\"addr\""
	Connected bool   "json:\"connected\" graphql:\"connected\""
	ConnStart string "json:\"conn_start\" graphql:\"conn_start\""
}

func (*GetStatus_Status_Sessions) GetAddr

func (t *GetStatus_Status_Sessions) GetAddr() string

func (*GetStatus_Status_Sessions) GetConnStart

func (t *GetStatus_Status_Sessions) GetConnStart() string

func (*GetStatus_Status_Sessions) GetConnected

func (t *GetStatus_Status_Sessions) GetConnected() bool

type MutationResolver

type MutationResolver interface {
	UpdateConfig(ctx context.Context, config ConfigUpdateInput) (*ConfigUpdateResult, error)
}

type NetnsFilter

type NetnsFilter struct {
	Name *string `json:"name,omitempty"`
}

type NetnsResult

type NetnsResult struct {
	Name string `json:"name"`
	Pid  int    `json:"pid"`
}

type QueryResolver

type QueryResolver interface {
	Netns(ctx context.Context, filter *NetnsFilter) ([]*NetnsResult, error)
	Status(ctx context.Context) (*Status, error)
	Config(ctx context.Context) (*ConfigResult, error)
}

type Resolver

type Resolver struct {
	GetConfig           func() *config.Config
	GetNetopus          func() proto.Netopus
	GetNsReg            func() *netns.Registry
	GetReconcilerStatus func() error
	UpdateNodeConfig    func([]byte, []byte) error
}

func (*Resolver) Config

func (r *Resolver) Config(_ context.Context) (*ConfigResult, error)

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

func (*Resolver) Netns

func (r *Resolver) Netns(_ context.Context, filter *NetnsFilter) ([]*NetnsResult, error)

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

func (*Resolver) Status

func (r *Resolver) Status(_ context.Context) (*Status, error)

func (*Resolver) UpdateConfig

func (r *Resolver) UpdateConfig(_ context.Context, config ConfigUpdateInput) (*ConfigUpdateResult, error)

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type Server

type Server struct {
	Resolver
	SigningMethod jwt.SigningMethod
}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, li net.Listener) error

func (*Server) ServeUnix

func (s *Server) ServeUnix(ctx context.Context, socketFile string) (net.Listener, error)

type SetConfig

type SetConfig struct {
	UpdateConfig SetConfig_UpdateConfig "json:\"updateConfig\" graphql:\"updateConfig\""
}

func (*SetConfig) GetUpdateConfig

func (t *SetConfig) GetUpdateConfig() *SetConfig_UpdateConfig

type SetConfig_UpdateConfig

type SetConfig_UpdateConfig struct {
	MutationID string "json:\"mutationId\" graphql:\"mutationId\""
}

func (*SetConfig_UpdateConfig) GetMutationID

func (t *SetConfig_UpdateConfig) GetMutationID() string

type Status

type Status struct {
	Name     string           `json:"name"`
	Addr     string           `json:"addr"`
	Global   *StatusGlobal    `json:"global"`
	Nodes    []*StatusNode    `json:"nodes"`
	Sessions []*StatusSession `json:"sessions"`
}

type StatusGlobal

type StatusGlobal struct {
	Domain            string    `json:"domain"`
	Subnet            string    `json:"subnet"`
	AuthorizedKeys    []string  `json:"authorized_keys"`
	ConfigLastUpdated time.Time `json:"config_last_updated"`
}

type StatusNode

type StatusNode struct {
	Name  string            `json:"name"`
	Addr  string            `json:"addr"`
	Conns []*StatusNodeConn `json:"conns"`
}

type StatusNodeConn

type StatusNodeConn struct {
	Subnet string  `json:"subnet"`
	Cost   float64 `json:"cost"`
}

type StatusSession

type StatusSession struct {
	Addr      string `json:"addr"`
	Connected bool   `json:"connected"`
	ConnStart string `json:"conn_start"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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