Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRegexCache(root *hclsyntax.Body, ctx *hcl.EvalContext) (map[string]*regexp.Regexp, hcl.Diagnostics)
- func EvaluateRegexPattern(attr *hclsyntax.Attribute, ctx *hcl.EvalContext) (string, *regexp.Regexp, hcl.Diagnostics)
- func Resolve(filename, path string) (string, error)
- func ValidateConfig(root *hclsyntax.Body, ctx *hcl.EvalContext) hcl.Diagnostics
- func ValidateSpec(body *hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics
- type AssetConfig
- type Config
- type GlobalConfig
- type InfoConfig
- type NetworkConfig
- type RootNetworkConfig
- type SiteConfig
- type SubdirectoryConfig
- type TransformConfig
Constants ¶
View Source
const Name = "grab"
View Source
const VersionMajor = 0
View Source
const VersionMinor = 1
View Source
const VersionPatch = 2
Variables ¶
View Source
var AssetSpec = &hcldec.ObjectSpec{ "name": &hcldec.BlockLabelSpec{ Index: 0, Name: "name", }, "pattern": &hcldec.AttrSpec{ Name: "pattern", Type: cty.String, Required: true, }, "capture": &hcldec.AttrSpec{ Name: "capture", Type: cty.String, Required: true, }, "find_all": &hcldec.AttrSpec{ Name: "find_all", Type: cty.Bool, Required: false, }, "network": &hcldec.BlockSpec{ TypeName: "network", Required: false, Nested: NetworkSpec, }, "transforms": &hcldec.BlockTupleSpec{ TypeName: "transform", MinItems: 0, MaxItems: 2, Nested: TransformSpec, }, }
View Source
var BuildArch = "unknown"
View Source
var BuildOS = "unknown"
View Source
var BuildType = "devel"
View Source
var CommitHash = "unknown"
View Source
var ConfigSpec = &hcldec.ObjectSpec{ "global": &hcldec.BlockSpec{ TypeName: "global", Required: true, Nested: GlobalSpec, }, "sites": &hcldec.BlockTupleSpec{ TypeName: "site", MinItems: 1, Nested: SiteSpec, }, }
View Source
var GlobalSpec = &hcldec.ObjectSpec{ "location": &hcldec.AttrSpec{ Name: "location", Required: true, Type: cty.String, }, "network": &hcldec.BlockSpec{ TypeName: "network", Required: false, Nested: RootNetworkSpec, }, }
View Source
var InfoSpec = &hcldec.ObjectSpec{ "name": &hcldec.BlockLabelSpec{ Index: 0, Name: "name", }, "pattern": &hcldec.AttrSpec{ Name: "pattern", Type: cty.String, Required: true, }, "capture": &hcldec.AttrSpec{ Name: "capture", Type: cty.String, Required: true, }, }
View Source
var NetworkSpec = &hcldec.ObjectSpec{ "inherit": &hcldec.AttrSpec{ Name: "inherit", Required: false, Type: cty.Bool, }, "timeout": &hcldec.AttrSpec{ Name: "timeout", Required: false, Type: cty.Number, }, "retries": &hcldec.AttrSpec{ Name: "retries", Required: false, Type: cty.Number, }, "headers": &hcldec.AttrSpec{ Name: "headers", Required: false, Type: cty.Map(cty.String), }, }
View Source
var RootNetworkSpec = &hcldec.ObjectSpec{ "timeout": &hcldec.AttrSpec{ Name: "timeout", Required: false, Type: cty.Number, }, "retries": &hcldec.AttrSpec{ Name: "retries", Required: false, Type: cty.Number, }, "headers": &hcldec.AttrSpec{ Name: "headers", Required: false, Type: cty.Map(cty.String), }, }
View Source
var SiteSpec = &hcldec.ObjectSpec{ "name": &hcldec.BlockLabelSpec{ Index: 0, Name: "name", }, "test": &hcldec.AttrSpec{ Name: "test", Type: cty.String, Required: true, }, "network": &hcldec.BlockSpec{ TypeName: "network", Required: false, Nested: NetworkSpec, }, "assets": &hcldec.BlockTupleSpec{ TypeName: "asset", MinItems: 0, Nested: AssetSpec, }, "infos": &hcldec.BlockTupleSpec{ TypeName: "info", MinItems: 0, Nested: InfoSpec, }, "subdirectory": &hcldec.BlockSpec{ TypeName: "subdirectory", Required: false, Nested: SubdirectorySpec, }, }
View Source
var SubdirectorySpec = &hcldec.ObjectSpec{ "pattern": &hcldec.AttrSpec{ Name: "pattern", Type: cty.String, Required: true, }, "capture": &hcldec.AttrSpec{ Name: "capture", Type: cty.String, Required: true, }, "from": &hcldec.AttrSpec{ Name: "from", Type: cty.String, Required: true, }, }
View Source
var TransformSpec = &hcldec.ObjectSpec{ "name": &hcldec.BlockLabelSpec{ Index: 0, Name: "name", }, "pattern": &hcldec.AttrSpec{ Name: "pattern", Type: cty.String, Required: true, }, "replace": &hcldec.AttrSpec{ Name: "replace", Type: cty.String, Required: true, }, }
must validate that there is only one "url" and only one "filename"
View Source
var Version = fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
Functions ¶
func BuildRegexCache ¶
func BuildRegexCache(root *hclsyntax.Body, ctx *hcl.EvalContext) (map[string]*regexp.Regexp, hcl.Diagnostics)
validate all regexp attributes - site*.test - site*.assets*.pattern - site*.assets*.transform*.pattern - site*.info*.pattern - site*.subdirectory.pattern
func EvaluateRegexPattern ¶
func ValidateConfig ¶
func ValidateSpec ¶
func ValidateSpec(body *hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics
Types ¶
type AssetConfig ¶
type AssetConfig struct { Name string `hcl:"name,label"` Pattern string `hcl:"pattern"` Capture string `hcl:"capture"` FindAll *bool `hcl:"find_all"` Network *NetworkConfig `hcl:"network,block"` Transforms []TransformConfig `hcl:"transform,block"` // computed Downloads map[string]string }
type Config ¶
type Config struct { Global GlobalConfig `hcl:"global,block"` Sites []SiteConfig `hcl:"site,block"` }
type GlobalConfig ¶
type GlobalConfig struct { Location string `hcl:"location"` Network *RootNetworkConfig `hcl:"network,block"` }
type InfoConfig ¶
type NetworkConfig ¶
type RootNetworkConfig ¶
type SiteConfig ¶
type SiteConfig struct { Name string `hcl:"name,label"` Test string `hcl:"test"` Network *NetworkConfig `hcl:"network,block"` Subdirectory *SubdirectoryConfig `hcl:"subdirectory,block"` Assets []AssetConfig `hcl:"asset,block"` Infos []InfoConfig `hcl:"info,block"` // computed URLs []string InfoMap map[string]map[string]string // location -> info -> value HasMatches bool }
type SubdirectoryConfig ¶
type TransformConfig ¶
Click to show internal directories.
Click to hide internal directories.