grammar

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBlocks

func GetBlocks(fullString string) []curlyBlock

Types

type Model

type Model struct {
	Pipeline []*ModelPipelineEntry `"pipeline" "{" { @@ } "}"`
}

Model is the base for the entire pipeline model

func ParseJenkinsfile

func ParseJenkinsfile(jenkinsfile string) (*Model, error)

ParseJenkinsfile takes a Jenkinsfile and returns the resulting model

func ParseJenkinsfileInDirectory

func ParseJenkinsfileInDirectory(dir string) (*Model, error)

ParseJenkinsfileInDirectory looks for a Jenkinsfile in a directory and parses it

func (*Model) ToYaml

func (m *Model) ToYaml() string

ToYaml converts the Jenkinsfile model into jenkins-x.yml

type ModelAgent

type ModelAgent struct {
	Label string `"label" @String`
}

ModelAgent represents the agent block in Declarative

func (*ModelAgent) ToString

func (m *ModelAgent) ToString() string

ToString converts the model to a rough string form

type ModelEnvironmentEntry

type ModelEnvironmentEntry struct {
	Key   string                      `@Ident`
	Value *ModelEnvironmentEntryValue `"=" @@`
}

ModelEnvironmentEntry represents a `foo = bar` (or `foo = credentials("bar")` in the environment block

func (*ModelEnvironmentEntry) ToJXEnv

func (m *ModelEnvironmentEntry) ToJXEnv() []corev1.EnvVar

ToJXEnv converts to jenkins-x.yml friendly environment variables

type ModelEnvironmentEntryValue

type ModelEnvironmentEntryValue struct {
	StringValue *string `  @(String|Char)`
	Credential  *string `| "credentials" "(" @(String|Char) ")"`
}

ModelEnvironmentEntryValue represents either a string or a credentials step's value

func (*ModelEnvironmentEntryValue) ToString

func (m *ModelEnvironmentEntryValue) ToString() string

ToString converts the model to a rough string form

type ModelPipelineEntry

type ModelPipelineEntry struct {
	Agent       *ModelAgent              `"agent" "{" @@ "}"`
	Environment []*ModelEnvironmentEntry `| "environment" "{" { @@ } "}"`
	Stages      []*ModelStage            `| "stages" "{" { @@ } "}"`
	Post        []*ModelPostEntry        `| "post" "{" { @@ } "}"`
	Unsupported []*UnsupportedModelBlock `| @@`
}

ModelPipelineEntry represents the directives that can be contained within the pipeline block

type ModelPostEntry

type ModelPostEntry struct {
	Kind  string       `@Ident`
	Steps []*ModelStep `"{" { @@ } "}"`
}

ModelPostEntry represents a post condition and its steps

type ModelStage

type ModelStage struct {
	Name    string             `"stage" "(" @String ")"`
	Entries []*ModelStageEntry `"{" { @@ } "}"`
}

ModelStage represents a stage in a Jenkinsfile

type ModelStageEntry

type ModelStageEntry struct {
	Agent       *ModelAgent              `  "agent" "{" @@ "}"`
	Environment []*ModelEnvironmentEntry `| "environment" "{" { @@ } "}"`
	Steps       []*ModelStep             `| "steps" "{" { @@ } "}"`
	Post        []*ModelPostEntry        `| "post" "{" { @@ } "}"`
	When        *ModelWhen               `| "when" "{" @@ "}"`
	Unsupported []*UnsupportedModelBlock `| @@`
}

ModelStageEntry represents the various directives contained within a stage

type ModelStep

type ModelStep struct {
	Name        string          `@Ident`
	Args        []*ModelStepArg `"("? @@? { "," @@ } ")"?`
	NestedSteps []*ModelStep    `("{" { @@ } "}")*`
}

ModelStep represents either a normal step or a script block

func (*ModelStep) ToString

func (m *ModelStep) ToString() string

ToString converts the model to a rough string form

type ModelStepArg

type ModelStepArg struct {
	Unnamed *Value             `  @@`
	Named   *ModelStepNamedArg `| @@`
}

ModelStepArg represents an argument to a step

func (*ModelStepArg) ToString

func (m *ModelStepArg) ToString() string

ToString converts the model to a rough string form

type ModelStepNamedArg

type ModelStepNamedArg struct {
	Key   string `@(Ident|String|Char)`
	Value *Value `":" @@`
}

func (*ModelStepNamedArg) ToString

func (m *ModelStepNamedArg) ToString() string

ToString converts the model to a rough string form

type ModelWhen

type ModelWhen struct {
	Branch      string                   `"branch" @String`
	Unsupported []*UnsupportedModelBlock `| @@`
}

ModelWhen represents a when block - only branch is supported currently

func (*ModelWhen) ToString

func (m *ModelWhen) ToString() string

ToString converts the model to a rough string form

type UnsupportedModelBlock

type UnsupportedModelBlock struct {
	Name  string `@Ident`
	Value string `@RawString`
}

UnsupportedModelBlock represents a field that is unsupported and will cause an error.

func (*UnsupportedModelBlock) ToString

func (m *UnsupportedModelBlock) ToString() string

ToString converts the model to a rough string form

type Value

type Value struct {
	String *string  `  @(String|RawString)`
	Number *float64 `| @Float`
	Int    *int64   `| @Int`
	Bool   *bool    `| (@"true" | "false")`
}

func (*Value) ToString

func (v *Value) ToString() string

ToString converts the model to a rough string form

Jump to

Keyboard shortcuts

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