workflow

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	WorkflowVersion = "1.0.0"
)

Variables

View Source
var SupportedLanguagesUsageSnippets = []string{
	"go",
	"typescript",
	"python",
	"java",
	"php",
	"swift",
	"ruby",
	"csharp",
	"unity",
}

Functions

func GetTempDir

func GetTempDir() string

func SanitizeFilePath added in v1.7.2

func SanitizeFilePath(path string) string

func Save

func Save(dir string, workflow *Workflow) error

Save the workflow to the given directory, dir should generally be the root of the project, and the workflow will be saved to ${projectRoot}/.speakeasy/workflow.yaml

func SaveLockfile added in v1.11.0

func SaveLockfile(dir string, lockfile *LockFile) error

Save the workflow lockfile to the given directory, dir should generally be the root of the project, and the lockfile will be saved to ${projectRoot}/.speakeasy/workflow.lock

Types

type Auth

type Auth struct {
	Header string `yaml:"authHeader,omitempty"`
	Secret string `yaml:"authSecret,omitempty"`
}

type CodeSamples added in v1.9.0

type CodeSamples struct {
	Output        string                    `yaml:"output,omitempty"`
	Registry      *SourceRegistry           `yaml:"registry,omitempty"`
	Style         *string                   `yaml:"style,omitempty"`         // Oneof "standard", "readme" (default: standard) (see codesamples.go)
	LangOverride  *string                   `yaml:"langOverride,omitempty"`  // The value to use for the "lang" field of each codeSample (default: auto-detect)
	LabelOverride *CodeSamplesLabelOverride `yaml:"labelOverride,omitempty"` // The value to use for the "label" field of each codeSample (default: operationId)
	Blocking      *bool                     `yaml:"blocking,omitempty"`      // Default: true. If false, code samples failures will not consider the workflow as failed
}

type CodeSamplesLabelOverride added in v1.23.0

type CodeSamplesLabelOverride struct {
	FixedValue *string `yaml:"fixedValue,omitempty"`
	Omit       *bool   `yaml:"omit,omitempty"`
}

type Document

type Document struct {
	Location LocationString `yaml:"location"`
	Auth     *Auth          `yaml:",inline"`
}

func (Document) GetTempDownloadPath

func (d Document) GetTempDownloadPath(tempDir string) string

func (Document) GetTempRegistryDir added in v1.11.3

func (d Document) GetTempRegistryDir(tempDir string) string

func (Document) IsRemote

func (d Document) IsRemote() bool

func (Document) IsSpeakeasyRegistry added in v1.11.3

func (d Document) IsSpeakeasyRegistry() bool

func (Document) Validate

func (d Document) Validate() error

type FallbackCodeSamples added in v1.15.1

type FallbackCodeSamples struct {
	FallbackCodeSamplesLanguage string `yaml:"fallbackCodeSamplesLanguage,omitempty"`
}

func (FallbackCodeSamples) Validate added in v1.15.4

func (f FallbackCodeSamples) Validate() error

type FilterOperationsOptions added in v1.27.0

type FilterOperationsOptions struct {
	Operations string `yaml:"operations"` // Comma-separated list of operations to filter
	Include    *bool  `yaml:"include,omitempty"`
	Exclude    *bool  `yaml:"exclude,omitempty"`
}

func (FilterOperationsOptions) ParseOperations added in v1.27.0

func (f FilterOperationsOptions) ParseOperations() []string

type Java

type Java struct {
	OSSRHUsername     string `yaml:"ossrhUsername"`
	OSSHRPassword     string `yaml:"ossrhPassword"`
	GPGSecretKey      string `yaml:"gpgSecretKey"`
	GPGPassPhrase     string `yaml:"gpgPassPhrase"`
	UseSonatypeLegacy bool   `yaml:"useSonatypeLegacy,omitempty"`
}

type LocationString added in v1.22.0

type LocationString string

func (LocationString) Reference added in v1.22.0

func (l LocationString) Reference() string

func (LocationString) Resolve added in v1.22.0

func (l LocationString) Resolve() string

type LockFile added in v1.11.0

type LockFile struct {
	SpeakeasyVersion string                `yaml:"speakeasyVersion"`
	Sources          map[string]SourceLock `yaml:"sources"`
	Targets          map[string]TargetLock `yaml:"targets"`

	Workflow Workflow `yaml:"workflow"`
}

func LoadLockfile added in v1.11.0

func LoadLockfile(dir string) (*LockFile, error)

type MockServer added in v1.28.1

type MockServer struct {
	// When enabled, the mockserver will be started during testing.
	Enabled *bool `yaml:"enabled,omitempty"`
}

Configuration for mockserver handling during testing.

type NPM

type NPM struct {
	Token string `yaml:"token"`
}

type NormalizeOptions added in v1.29.2

type NormalizeOptions struct {
	PrefixItems *bool `yaml:"prefixItems,omitempty"`
}

type Nuget

type Nuget struct {
	APIKey string `yaml:"apiKey"`
}

type Overlay added in v1.15.1

type Overlay struct {
	FallbackCodeSamples *FallbackCodeSamples `yaml:"fallbackCodeSamples,omitempty"`
	Document            *Document            `yaml:"document,omitempty"`
}

Either FallBackCodeSamples or Document

func (Overlay) MarshalYAML added in v1.15.3

func (o Overlay) MarshalYAML() (interface{}, error)

func (*Overlay) UnmarshalYAML added in v1.15.3

func (o *Overlay) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Overlay) Validate added in v1.15.4

func (o Overlay) Validate() error

type Packagist

type Packagist struct {
	Username string `yaml:"username"`
	Token    string `yaml:"token"`
}

type Publishing

type Publishing struct {
	NPM       *NPM       `yaml:"npm,omitempty"`
	PyPi      *PyPi      `yaml:"pypi,omitempty"`
	Packagist *Packagist `yaml:"packagist,omitempty"`
	Java      *Java      `yaml:"java,omitempty"`
	RubyGems  *RubyGems  `yaml:"rubygems,omitempty"`
	Nuget     *Nuget     `yaml:"nuget,omitempty"`
	Terraform *Terraform `yaml:"terraform,omitempty"`
}

func (Publishing) IsPublished

func (p Publishing) IsPublished(target string) bool

func (Publishing) Validate

func (p Publishing) Validate(target string) error

type PyPi

type PyPi struct {
	Token string `yaml:"token"`
}

type RubyGems

type RubyGems struct {
	Token string `yaml:"token"`
}

type Source

type Source struct {
	Inputs          []Document       `yaml:"inputs"`
	Overlays        []Overlay        `yaml:"overlays,omitempty"`
	Transformations []Transformation `yaml:"transformations,omitempty"`
	Output          *string          `yaml:"output,omitempty"`
	Ruleset         *string          `yaml:"ruleset,omitempty"`
	Registry        *SourceRegistry  `yaml:"registry,omitempty"`
}

Ensure your update schema/workflow.schema.json on changes

func (Source) GetOutputLocation

func (s Source) GetOutputLocation() (string, error)

func (Source) GetTempMergeLocation

func (s Source) GetTempMergeLocation() string

func (Source) GetTempOverlayLocation

func (s Source) GetTempOverlayLocation() string

func (Source) GetTempTransformLocation added in v1.27.1

func (s Source) GetTempTransformLocation() string

func (Source) IsSingleInput added in v1.27.2

func (s Source) IsSingleInput() bool

func (Source) Validate

func (s Source) Validate() error

type SourceLock added in v1.11.0

type SourceLock struct {
	SourceNamespace      string   `yaml:"sourceNamespace,omitempty"`
	SourceRevisionDigest string   `yaml:"sourceRevisionDigest,omitempty"`
	SourceBlobDigest     string   `yaml:"sourceBlobDigest,omitempty"`
	Tags                 []string `yaml:"tags,omitempty"`
}

type SourceRegistry added in v1.13.0

type SourceRegistry struct {
	Location SourceRegistryLocation `yaml:"location"`
	Tags     []string               `yaml:"tags,omitempty"`
}

func (*SourceRegistry) ParseRegistryLocation added in v1.13.0

func (p *SourceRegistry) ParseRegistryLocation() (string, string, string, string, error)

func (*SourceRegistry) SetNamespace added in v1.13.0

func (p *SourceRegistry) SetNamespace(namespace string) error

func (SourceRegistry) Validate added in v1.13.0

func (p SourceRegistry) Validate() error

type SourceRegistryLocation added in v1.13.0

type SourceRegistryLocation string

func (SourceRegistryLocation) Namespace added in v1.13.0

func (n SourceRegistryLocation) Namespace() string

@<org>/<workspace>/<namespace_name> => <org>/<workspace>/<namespace_name>

func (SourceRegistryLocation) NamespaceName added in v1.13.0

func (n SourceRegistryLocation) NamespaceName() string

@<org>/<workspace>/<namespace_name> => <namespace_name>

func (SourceRegistryLocation) String added in v1.13.0

func (n SourceRegistryLocation) String() string

type SpeakeasyRegistryDocument added in v1.11.3

type SpeakeasyRegistryDocument struct {
	OrganizationSlug string
	WorkspaceSlug    string
	NamespaceID      string
	NamespaceName    string
	// Reference could be tag or revision hash sha256:...
	Reference string
}

func ParseSpeakeasyRegistryReference added in v1.11.3

func ParseSpeakeasyRegistryReference(location string) *SpeakeasyRegistryDocument

Parse the location to extract the namespace ID, namespace name, and reference The location should be in the format registry.speakeasyapi.dev/org/workspace/name[:tag|@sha256:digest]

type Target

type Target struct {
	Target      string       `yaml:"target"`
	Source      string       `yaml:"source"`
	Output      *string      `yaml:"output,omitempty"`
	Publishing  *Publishing  `yaml:"publish,omitempty"`
	CodeSamples *CodeSamples `yaml:"codeSamples,omitempty"`

	// Configuration for target testing. By default, target testing is disabled.
	Testing *Testing `yaml:"testing,omitempty"`
}

Ensure your update schema/workflow.schema.json on changes

func (Target) IsPublished added in v1.6.5

func (t Target) IsPublished() bool

func (Target) Validate

func (t Target) Validate(supportedLangs []string, sources map[string]Source) error

type TargetLock added in v1.11.0

type TargetLock struct {
	Source                    string `yaml:"source"`
	SourceNamespace           string `yaml:"sourceNamespace,omitempty"`
	SourceRevisionDigest      string `yaml:"sourceRevisionDigest,omitempty"`
	SourceBlobDigest          string `yaml:"sourceBlobDigest,omitempty"`
	CodeSamplesNamespace      string `yaml:"codeSamplesNamespace,omitempty"`
	CodeSamplesRevisionDigest string `yaml:"codeSamplesRevisionDigest,omitempty"`
	CodeSamplesBlobDigest     string `yaml:"codeSamplesBlobDigest,omitempty"`
}

type Terraform added in v1.14.4

type Terraform struct {
	GPGPrivateKey string `yaml:"gpgPrivateKey"`
	GPGPassPhrase string `yaml:"gpgPassPhrase"`
}

type Testing added in v1.28.1

type Testing struct {
	// When enabled, the target will be tested as part of the workflow.
	Enabled *bool `yaml:"enabled,omitempty"`

	// Configuration for mockserver handling during testing. By default, the
	// mockserver is enabled.
	MockServer *MockServer `yaml:"mockServer,omitempty"`
}

Configuration for target testing, such as `go test` for Go targets.

type Transformation added in v1.27.0

type Transformation struct {
	RemoveUnused     *bool                    `yaml:"removeUnused,omitempty"`
	FilterOperations *FilterOperationsOptions `yaml:"filterOperations,omitempty"`
	Cleanup          *bool                    `yaml:"cleanup,omitempty"`
	Format           *bool                    `yaml:"format,omitempty"`
	Normalize        *NormalizeOptions        `yaml:"normalize,omitempty"`
}

func (Transformation) Validate added in v1.27.0

func (t Transformation) Validate() error

type Version added in v1.10.1

type Version string

func (Version) String added in v1.10.1

func (v Version) String() string

type Workflow

type Workflow struct {
	Version          string            `yaml:"workflowVersion"`
	SpeakeasyVersion Version           `yaml:"speakeasyVersion,omitempty"`
	Sources          map[string]Source `yaml:"sources"`
	Targets          map[string]Target `yaml:"targets"`
}

Ensure your update schema/workflow.schema.json on changes

func Load

func Load(dir string) (*Workflow, string, error)

func (Workflow) GetTargetSource

func (w Workflow) GetTargetSource(target string) (*Source, string, error)

func (Workflow) Migrate added in v1.23.7

func (w Workflow) Migrate() Workflow

func (Workflow) MigrateNoTelemetry added in v1.23.7

func (w Workflow) MigrateNoTelemetry() Workflow

func (Workflow) Validate

func (w Workflow) Validate(supportLangs []string) error

Jump to

Keyboard shortcuts

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