config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	SSH       SSHConfig `json:"ssh"`
	Interface string    `json:"interface"`
}

Config represents the data structure of our user provided json configuration

type ConfigService

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

nolint:revive ConfigService is an implementation of the config.Service interface

func NewConfigService

func NewConfigService(repo Repo) *ConfigService

NewConfigService returns a new instance of ConfigService

func (*ConfigService) Create

func (s *ConfigService) Create(conf *Config) (*Config, error)

Create creates a new config

func (*ConfigService) Delete

func (s *ConfigService) Delete(id string) error

Delete deletes a config

func (*ConfigService) Get

func (s *ConfigService) Get(id string) (*Config, error)

Get returns a config by id

func (*ConfigService) GetAll

func (s *ConfigService) GetAll() ([]*Config, error)

GetAll returns all stored configs

func (*ConfigService) GetByInterface added in v1.2.0

func (s *ConfigService) GetByInterface(ifaceName string) (*Config, error)

GetByInterface returns config associated with given interface name

func (*ConfigService) Update

func (s *ConfigService) Update(conf *Config) (*Config, error)

Update updates an existing config

type Configs added in v1.0.0

type Configs struct {
	Configs []*Config `json:"configs"`
}

Configs represents our collection of json configs

type JSONRepo added in v1.0.0

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

JSONRepo is our repo implementation for json

func NewJSONRepo added in v1.0.0

func NewJSONRepo(configPath string, defaultConfig Config) (*JSONRepo, error)

NewJSONRepo returns a new ops repo for flat yaml file

func (*JSONRepo) Create added in v1.0.0

func (r *JSONRepo) Create(conf *Config) (*Config, error)

Create creates a new config in db

func (*JSONRepo) Delete added in v1.0.0

func (r *JSONRepo) Delete(id string) error

Delete deletes a config from db

func (*JSONRepo) Get added in v1.0.0

func (r *JSONRepo) Get(id string) (*Config, error)

Get returns a config from the db

func (*JSONRepo) GetAll added in v1.0.0

func (r *JSONRepo) GetAll() ([]*Config, error)

GetAll returns all configs in db

func (*JSONRepo) GetByInterface added in v1.2.0

func (r *JSONRepo) GetByInterface(ifaceName string) (*Config, error)

GetByInterface returns config associated with specific interface name

func (*JSONRepo) Update added in v1.0.0

func (r *JSONRepo) Update(conf *Config) (*Config, error)

Update updates a config in db

type Repo

type Repo interface {
	Get(id string) (*Config, error)
	GetAll() ([]*Config, error)
	GetByInterface(ifaceName string) (*Config, error)
	Create(conf *Config) (*Config, error)
	Update(conf *Config) (*Config, error)
	Delete(id string) error
}

Repo interface representing access to stored configs

type SSHConfig

type SSHConfig struct {
	User      string        `json:"user"`
	Identity  string        `json:"identity"`
	Port      string        `json:"port"`
	Overrides []SSHOverride `json:"overrides"`
}

SSHConfig represents the config needed to ssh to servers

type SSHOverride

type SSHOverride struct {
	Target   string `json:"target"`
	User     string `json:"user"`
	Identity string `json:"identity"`
	Port     string `json:"port"`
}

SSHOverride represents the config needed to override ssh config for a single target

type Service

type Service interface {
	Get(id string) (*Config, error)
	GetAll() ([]*Config, error)
	GetByInterface(ifaceName string) (*Config, error)
	Create(conf *Config) (*Config, error)
	Update(conf *Config) (*Config, error)
	Delete(id string) error
}

Service interface for manipulating configurations

Jump to

Keyboard shortcuts

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