config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeProjectConfiguration

func DecodeProjectConfiguration(settingsMap map[string]interface{}) error

DecodeProjectConfiguration for decoding the project configuration from viper.AllSettings()

func InitializeConfiguration

func InitializeConfiguration(cfgFile string, overwrite bool)

InitializeConfiguration for initializing the configuration file.

func UpdateConfiguration

func UpdateConfiguration(cfgFile string, configuration Configuration, overwrite bool) error

UpdateConfiguration For updating the configuration.

func UpdateProject

func UpdateProject(cfgFile string, project Project) error

UpdateProject for adding or modifying the project

Types

type Configuration

type Configuration struct {
	ServeConfig    Serve     `yaml:"serve" json:"serve"`
	ProjectConfigs []Project `yaml:"projects,omitempty" json:"projects,omitempty"`
}

Configuration for whole configuration file

type Hook added in v0.5.0

type Hook struct {
	FilePath string `yaml:"file_path" json:"file_path"`                   // path to file to be executed
	MaxArgs  int    `yaml:"max_args,omitempty" json:"max_args,omitempty"` // For limiting number of arguments

}

Hook is a new struct for replacing PreHook and PostHook

func NewHooks added in v0.5.0

func NewHooks(hooks ...string) []Hook

NewHooks for getting a new []Hook to be assigned to project.Hooks

type Project

type Project struct {
	Name          string        `yaml:"name" json:"name"`
	UUID          string        `yaml:"uuid" json:"uuid"`
	WorkDir       string        `yaml:"work_dir" json:"work_dir"`
	PostHook      string        `yaml:"post_hook,omitempty" json:"post_hook,omitempty"`
	PostHookArgs  []string      `yaml:"post_hook_args,omitempty" json:"post_hook_args,omitempty"`
	PreHook       string        `yaml:"pre_hook,omitempty" json:"pre_hook,omitempty"`
	PreHookArgs   []string      `yaml:"pre_hook_args,omitempty" json:"pre_hook_args,omitempty"`
	ErrorHook     string        `yaml:"error_hook,omitempty" json:"error_hook,omitempty"`
	ErrorHookArgs []string      `yaml:"error_hook_args,omitempty" json:"error_hook_args,omitempty"`
	Secret        string        `yaml:"secret" json:"secret"`
	Tokens        []TokenDetail `yaml:"tokens" json:"tokens"`
	Hooks         []Hook        `yaml:"hooks,omitempty" json:"hooks,omitempty"`
	MaxArgs       int           `yaml:"max_args,omitempty" json:"max_args,omitempty"`
}

Project for all projects configurations

func FindProject

func FindProject(name, projectUUID string) (Project, error)

FindProject for finding the Project from StoredProjects

func FindProjectWithUUID

func FindProjectWithUUID(projectUUID string) (Project, error)

FindProjectWithUUID for finding the Project from StoredProjects

func NewProject

func NewProject(ipCIDRs ...string) Project

NewProject For creating new Project

func (*Project) ExecuteHooks added in v0.7.1

func (project *Project) ExecuteHooks(args ...string)

ExecuteHooks for executing hooks one after another

func (*Project) GetHash

func (project *Project) GetHash(index int) string

GetHash for getting hash for given token with index

func (*Project) ValidateProjectConfiguration

func (project *Project) ValidateProjectConfiguration() error

ValidateProjectConfiguration for validating. TODO

func (*Project) ValidateToken

func (project *Project) ValidateToken(clientIP string, tokenHash string) bool

ValidateToken is a Project function to check if the token is valid.

type Serve

type Serve struct {
	Host string `yaml:"host" json:"host"`
	Port int    `yaml:"port" json:"port"`
}

Serve for server (listener) related configurations

var (
	// StoredProjects Contains the latest stored projects
	StoredProjects []Project

	// StoredServe Contains the latest stored serve details
	StoredServe Serve
)

type TokenDetail

type TokenDetail struct {
	Token              string `yaml:"token" json:"token"`
	WhitelistedNetwork string `yaml:"whitelistnet" json:"whitelistnet"` // CIDR notation
	Name               string `yaml:"name" json:"name"`
}

TokenDetail is for allowing multiple ips to access same repository with different tokens

func NewToken

func NewToken(whitelistCIDR string) TokenDetail

NewToken For creating new Token

Jump to

Keyboard shortcuts

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