parser

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 27 Imported by: 5

Documentation

Index

Constants

View Source
const (
	CUE        = "cue"
	CYCLONEDX  = "cyclonedx"
	Dockerfile = "dockerfile"
	EDN        = "edn"
	HCL1       = "hcl1"
	HCL2       = "hcl2"
	HOCON      = "hocon"
	IGNORE     = "ignore"
	INI        = "ini"
	JSON       = "json"
	JSONNET    = "jsonnet"
	PROPERTIES = "properties"
	SPDX       = "spdx"
	TOML       = "toml"
	VCL        = "vcl"
	XML        = "xml"
	YAML       = "yaml"
	DOTENV     = "dotenv"
)

The defined parsers are the parsers that are valid for parsing files.

Variables

This section is empty.

Functions

func CombineConfigurations added in v0.22.0

func CombineConfigurations(configs map[string]interface{}) map[string]interface{}

CombineConfigurations takes the given configurations and combines them into a single configuration. The result will be a map that contains a single key with a value of Combined.

func FileSupported added in v0.22.0

func FileSupported(path string) bool

FileSupported returns true if the file at the given path is a file that can be parsed.

func Format added in v0.22.0

func Format(configurations map[string]interface{}) (string, error)

Format takes in multiple configurations input and formats the configuration to be more human readable. The key of each configuration should be its filepath.

func FormatCombined added in v0.22.0

func FormatCombined(configurations map[string]interface{}) (string, error)

FormatCombined takes in multiple configurations, combines them, and formats the configuration to be more human readable. The key of each configuration should be its filepath.

func ParseConfigurations added in v0.22.0

func ParseConfigurations(files []string) (map[string]interface{}, error)

ParseConfigurations parses and returns the configurations from the given list of files. The result will be a map where the key is the file name of the configuration.

func ParseConfigurationsAs added in v0.22.0

func ParseConfigurationsAs(files []string, parser string) (map[string]interface{}, error)

ParseConfigurationsAs parses the files as the given file type and returns the configurations given in the file list. The result will be a map where the key is the file name of the configuration.

func Parsers added in v0.22.0

func Parsers() []string

Parsers returns a list of the supported Parsers.

Types

type Parser

type Parser interface {
	Unmarshal(p []byte, v interface{}) error
}

Parser defines all of the methods that every parser definition must implement.

func New added in v0.22.0

func New(parser string) (Parser, error)

New returns a new Parser.

func NewFromPath added in v0.22.0

func NewFromPath(path string) (Parser, error)

NewFromPath returns a file parser based on the file type that exists at the given path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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