config

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndentStyleSpace  = "space"
	IndentStyleTab    = "tab"
	CommentStyleNone  = "none"
	CommentStyleSlash = "slash"
	CommentStyleSharp = "sharp"
)

Formatting value constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands []string

func (Commands) At

func (c Commands) At(n int) string

type Config

type Config struct {
	// Root configurations
	IncludePaths []string `cli:"I,include_path" yaml:"include_paths"`
	Transforms   []string `cli:"t,transformer" yaml:"transformers"`
	Help         bool     `cli:"h,help"`
	Version      bool     `cli:"V"`
	Remote       bool     `cli:"r,remote" yaml:"remote"`
	Json         bool     `cli:"json"`
	Request      string   `cli:"request"`

	// Remote options, only provided via environment variable
	FastlyServiceID string `env:"FASTLY_SERVICE_ID"`
	FastlyApiKey    string `env:"FASTLY_API_KEY"`

	// CLI subcommands
	Commands Commands

	// Override Origin fetching URL
	OverrideBackends map[string]*OverrideBackend `yaml:"override_backends"`

	// Override resource limits
	OverrideMaxBackends int `cli:"max_backends" yaml:"max_backends"`
	OverrideMaxAcls     int `cli:"mac_acls" yaml:"max_acls"`

	// Linter configuration
	Linter *LinterConfig `yaml:"linter"`
	// Simulator configuration
	Simulator *SimulatorConfig `yaml:"simulator"`
	// Testing configuration
	Testing *TestConfig `yaml:"testing"`
	// Console configuration
	Console *ConsoleConfig `yaml:"console"`
	// Format configuration
	Format *FormatConfig `yaml:"format"`
}

func New

func New(args []string) (*Config, error)

type ConsoleConfig added in v1.6.0

type ConsoleConfig struct {
	// Initial scope string, for example, recv, pass, fetch, etc...
	Scope string `cli:"scope" default:"recv"`

	// Override Request configuration
	OverrideRequest *RequestConfig
}

Console configuration

type FormatConfig added in v1.6.0

type FormatConfig struct {
	// CLI options
	Overwrite bool `cli:"w,write" default:"false"`

	// Formatter options
	IndentWidth                int    `yaml:"indent_width" default:"2"`
	TrailingCommentWidth       int    `yaml:"trailing_comment_width" default:"2"`
	IndentStyle                string `yaml:"indent_style" default:"space"`
	LineWidth                  int    `yaml:"line_width" default:"120"`
	ExplicitStringConat        bool   `yaml:"explicit_string_concat" default:"false"`
	SortDeclarationProperty    bool   `yaml:"sort_declaration_property" default:"false"`
	AlignDeclarationProperty   bool   `yaml:"align_declaration_property" default:"false"`
	ElseIf                     bool   `yaml:"else_if" default:"false"`
	AlwaysNextLineElseIf       bool   `yaml:"always_next_line_else_if" default:"false"`
	ReturnStatementParenthesis bool   `yaml:"return_statement_parenthesis" default:"true"`
	SortDeclaration            bool   `yaml:"sort_declaration" defaul:"false"`
	AlignTrailingComment       bool   `yaml:"align_trailing_comment" default:"false"`
	CommentStyle               string `yaml:"comment_style" default:"none"`
	ShouldUseUnset             bool   `yaml:"should_use_unset" default:"false"`
	IndentCaseLabels           bool   `yaml:"indent_case_labels" default:"false"`
}

Format configuration

type LinterConfig added in v1.0.0

type LinterConfig struct {
	VerboseLevel            string              `yaml:"verbose"`
	VerboseWarning          bool                `cli:"v"`
	VerboseInfo             bool                `cli:"vv"`
	Rules                   map[string]string   `yaml:"rules"`
	EnforceSubroutineScopes map[string][]string `yaml:"enforce_subroutine_scopes"`
	IgnoreSubroutines       []string            `yaml:"ignore_subroutines"`
}

Linter configuration

type OverrideBackend added in v1.0.0

type OverrideBackend struct {
	Host      string `yaml:"host"`
	SSL       bool   `yaml:"ssl" default:"true"`
	Unhealthy bool   `yaml:"unhealthy" default:"false"`
}

type RequestConfig added in v1.0.0

type RequestConfig struct {
	RemoteIP       string            `yaml:"remote_ip" json:"remote_ip"`
	RequestHeaders map[string]string `yaml:"headers" json:"headers"`
	Path           string            `yaml:"path" json:"path"`
	UserAgent      string            `yaml:"user_agent" json:"user_agent"`
}

func LoadRequestConfig added in v1.0.0

func LoadRequestConfig(path string) (*RequestConfig, error)

func (*RequestConfig) SetRequest added in v1.0.0

func (r *RequestConfig) SetRequest(req *http.Request)

type SimulatorConfig added in v1.0.0

type SimulatorConfig struct {
	Port         int      `cli:"p,port" yaml:"port" default:"3124"`
	IsDebug      bool     `cli:"debug"` // Enable only in CLI option
	IncludePaths []string // Copy from root field

	// Override Request configuration
	OverrideRequest *RequestConfig
}

Simulator configuration

type TestConfig added in v1.0.0

type TestConfig struct {
	Timeout      int      `cli:"t,timeout" yaml:"timeout"`
	Filter       string   `cli:"f,filter" default:"*.test.vcl"`
	IncludePaths []string // Copy from root field
	OverrideHost string   `yaml:"host"`

	// Override Request configuration
	OverrideRequest *RequestConfig
}

Testing configuration

Jump to

Keyboard shortcuts

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