config

package module
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 15 Imported by: 2

README

sdk-gen-config

Documentation

Index

Constants

View Source
const (
	Version = v2

	GithubWritePermission = "write"

	// Constants to be used as keys in the config files
	Languages                        = "languages"
	Mode                             = "mode"
	GithubAccessToken                = "github_access_token"
	SpeakeasyApiKey                  = "speakeasy_api_key"
	SpeakeasyServerURL               = "speakeasy_server_url"
	OpenAPIDocAuthHeader             = "openapi_doc_auth_header"
	OpenAPIDocAuthToken              = "openapi_doc_auth_token"
	OpenAPIDocs                      = "openapi_docs"
	DefaultGithubTokenSecretName     = "GITHUB_TOKEN"
	DefaultSpeakeasyAPIKeySecretName = "SPEAKEASY_API_KEY"
)

Variables

View Source
var ErrFailedUpgrade = errors.New("failed to upgrade config")

Functions

func FindConfigFile added in v1.10.0

func FindConfigFile(dir string, fileSystem FS) (*workspace.FindWorkspaceResult, error)

func FormatGithubSecret added in v1.14.8

func FormatGithubSecret(secret string) string

func FormatGithubSecretName added in v1.14.8

func FormatGithubSecretName(name string) string

func GetConfigChecksum added in v1.5.0

func GetConfigChecksum(dir string, opts ...Option) (string, error)

func GetTemplateVersion added in v1.6.1

func GetTemplateVersion(dir, target string, opts ...Option) (string, error)

func SaveConfig added in v1.5.0

func SaveConfig(dir string, cfg *Configuration, opts ...Option) error

func SaveLockFile added in v1.5.0

func SaveLockFile(dir string, lf *LockFile, opts ...Option) error

Types

type Auth added in v1.7.3

type Auth struct {
	OAuth2ClientCredentialsEnabled bool `yaml:"oAuth2ClientCredentialsEnabled"`
}

type Config

type Config struct {
	Config     *Configuration
	ConfigPath string
	LockFile   *LockFile
}

func Load

func Load(dir string, opts ...Option) (*Config, error)

type Configuration added in v1.5.0

type Configuration struct {
	ConfigVersion string                    `yaml:"configVersion"`
	Generation    Generation                `yaml:"generation"`
	Languages     map[string]LanguageConfig `yaml:",inline"`
	New           map[string]bool           `yaml:"-"`
}

func GetDefaultConfig

func GetDefaultConfig(newSDK bool, getLangDefaultFunc GetLanguageDefaultFunc, langs map[string]bool) (*Configuration, error)

func (*Configuration) GetGenerationFieldsMap added in v1.5.0

func (c *Configuration) GetGenerationFieldsMap() (map[string]any, error)

type DevContainers added in v0.8.2

type DevContainers struct {
	Enabled bool `yaml:"enabled"`
	// This can be a local path or a remote URL
	SchemaPath           string         `yaml:"schemaPath"`
	AdditionalProperties map[string]any `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

type FS added in v1.10.0

type FS interface {
	fs.ReadFileFS
	fs.StatFS
	WriteFile(name string, data []byte, perm os.FileMode) error
}

type Fixes added in v1.4.0

type Fixes struct {
	NameResolutionDec2023                bool           `yaml:"nameResolutionDec2023"`
	ParameterOrderingFeb2024             bool           `yaml:"parameterOrderingFeb2024"`
	RequestResponseComponentNamesFeb2024 bool           `yaml:"requestResponseComponentNamesFeb2024"`
	AdditionalProperties                 map[string]any `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

type Force added in v0.4.2

type Force struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
	Default     bool   `yaml:"default"`
}

type GenerateOn added in v0.4.2

type GenerateOn struct {
	WorkflowDispatch WorkflowDispatch `yaml:"workflow_dispatch"`
	Schedule         []Schedule       `yaml:"schedule,omitempty"`
}

type GenerateWorkflow added in v0.4.2

type GenerateWorkflow struct {
	Name        string      `yaml:"name"`
	Permissions Permissions `yaml:"permissions,omitempty"`
	On          GenerateOn  `yaml:"on"`
	Jobs        Jobs        `yaml:"jobs"`
}

func DefaultGenerationFile added in v1.14.8

func DefaultGenerationFile() *GenerateWorkflow

type Generation

type Generation struct {
	DevContainers               *DevContainers `yaml:"devContainers,omitempty"`
	BaseServerURL               string         `yaml:"baseServerUrl,omitempty"`
	SDKClassName                string         `yaml:"sdkClassName,omitempty"`
	MaintainOpenAPIOrder        bool           `yaml:"maintainOpenAPIOrder,omitempty"`
	UsageSnippets               *UsageSnippets `yaml:"usageSnippets,omitempty"`
	UseClassNamesForArrayFields bool           `yaml:"useClassNamesForArrayFields,omitempty"`
	Fixes                       *Fixes         `yaml:"fixes,omitempty"`
	Auth                        *Auth          `yaml:"auth,omitempty"`

	AdditionalProperties map[string]any `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

type GetLanguageDefaultFunc

type GetLanguageDefaultFunc func(string, bool) (*LanguageConfig, error)

type Inputs added in v0.4.2

type Inputs struct {
	Force               Force                `yaml:"force"`
	PushCodeSamplesOnly *PushCodeSamplesOnly `yaml:"push_code_samples_only,omitempty"`
	SetVersion          *SetVersion          `yaml:"set_version,omitempty"`
	Target              *Target              `yaml:"target,omitempty"`
}

type Job added in v0.4.2

type Job struct {
	Uses    string            `yaml:"uses"`
	With    map[string]any    `yaml:"with,omitempty"`
	Secrets map[string]string `yaml:"secrets,omitempty"`
}

type Jobs added in v0.4.2

type Jobs struct {
	Generate Job `yaml:"generate,omitempty"`
	Publish  Job `yaml:"publish,omitempty"`
	Tag      Job `yaml:"tag,omitempty"`
}

type LanguageConfig

type LanguageConfig struct {
	Version string         `yaml:"version"`
	Cfg     map[string]any `yaml:",inline"`
}

type LockFile added in v1.5.0

type LockFile struct {
	LockVersion          string                       `yaml:"lockVersion"`
	ID                   string                       `yaml:"id"`
	Management           Management                   `yaml:"management"`
	Features             map[string]map[string]string `yaml:"features,omitempty"`
	GeneratedFiles       []string                     `yaml:"generatedFiles,omitempty"`
	AdditionalProperties map[string]any               `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

func NewLockFile added in v1.5.0

func NewLockFile() *LockFile

type Management

type Management struct {
	DocChecksum          string         `yaml:"docChecksum,omitempty"`
	DocVersion           string         `yaml:"docVersion,omitempty"`
	SpeakeasyVersion     string         `yaml:"speakeasyVersion,omitempty"`
	GenerationVersion    string         `yaml:"generationVersion,omitempty"`
	ReleaseVersion       string         `yaml:"releaseVersion,omitempty"`
	ConfigChecksum       string         `yaml:"configChecksum,omitempty"`
	RepoURL              string         `yaml:"repoURL,omitempty"`
	RepoSubDirectory     string         `yaml:"repoSubDirectory,omitempty"`
	InstallationURL      string         `yaml:"installationURL,omitempty"`
	Published            bool           `yaml:"published,omitempty"`
	AdditionalProperties map[string]any `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

type Option

type Option func(*options)

func WithDontWrite added in v1.10.0

func WithDontWrite() Option

func WithFileSystem added in v1.10.0

func WithFileSystem(fs FS) Option

func WithLanguageDefaultFunc

func WithLanguageDefaultFunc(f GetLanguageDefaultFunc) Option

func WithLanguages added in v0.0.4

func WithLanguages(langs ...string) Option

func WithTransformerFunc added in v0.8.4

func WithTransformerFunc(f TransformerFunc) Option

func WithUpgradeFunc added in v0.0.2

func WithUpgradeFunc(f UpgradeFunc) Option

func WithValidateFunc added in v1.16.0

func WithValidateFunc(f ValidateFunc) Option

type OptionalPropertyRenderingOption added in v1.2.0

type OptionalPropertyRenderingOption string
const (
	OptionalPropertyRenderingOptionAlways      OptionalPropertyRenderingOption = "always"
	OptionalPropertyRenderingOptionNever       OptionalPropertyRenderingOption = "never"
	OptionalPropertyRenderingOptionWithExample OptionalPropertyRenderingOption = "withExample"
)

type Permissions added in v0.4.2

type Permissions struct {
	Checks       string `yaml:"checks,omitempty"`
	Contents     string `yaml:"contents,omitempty"`
	PullRequests string `yaml:"pull-requests,omitempty"`
	Statuses     string `yaml:"statuses,omitempty"`
}

type PublishOn added in v0.4.2

type PublishOn struct {
	Push Push `yaml:"push"`
}

type PublishWorkflow added in v0.4.2

type PublishWorkflow struct {
	Name        string      `yaml:"name"`
	Permissions Permissions `yaml:"permissions,omitempty"`
	On          PublishOn   `yaml:"on"`
	Jobs        Jobs        `yaml:"jobs"`
}

type Push added in v0.4.2

type Push struct {
	Branches []string `yaml:"branches"`
	Paths    []string `yaml:"paths"`
}

type PushCodeSamplesOnly added in v1.14.11

type PushCodeSamplesOnly struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
	Default     bool   `yaml:"default"`
}

type SDKGenConfigField added in v1.0.0

type SDKGenConfigField struct {
	Name                  string  `yaml:"name" json:"name"`
	Required              bool    `yaml:"required" json:"required"`
	RequiredForPublishing *bool   `yaml:"requiredForPublishing,omitempty" json:"required_for_publishing,omitempty"`
	DefaultValue          *any    `yaml:"defaultValue,omitempty" json:"default_value,omitempty"`
	Description           *string `yaml:"description,omitempty" json:"description,omitempty"`
	Language              *string `yaml:"language,omitempty" json:"language,omitempty"`
	SecretName            *string `yaml:"secretName,omitempty" json:"secret_name,omitempty"`
	ValidationRegex       *string `yaml:"validationRegex,omitempty" json:"validation_regex,omitempty"`
	ValidationMessage     *string `yaml:"validationMessage,omitempty" json:"validation_message,omitempty"`
	TestValue             *any    `yaml:"testValue,omitempty" json:"test_value,omitempty"`
}

func GetGenerationDefaults added in v1.0.0

func GetGenerationDefaults(newSDK bool) []SDKGenConfigField

type Schedule added in v0.4.2

type Schedule struct {
	Cron string `yaml:"cron"`
}

type SetVersion added in v1.14.12

type SetVersion struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
}

type TagOn added in v1.14.11

type TagOn struct {
	Push             Push                    `yaml:"push"`
	WorkflowDispatch WorkflowDispatchTagging `yaml:"workflow_dispatch"`
}

type TaggingWorkflow added in v1.14.11

type TaggingWorkflow struct {
	Name        string      `yaml:"name"`
	Permissions Permissions `yaml:"permissions,omitempty"`
	On          TagOn       `yaml:"on"`
	Jobs        Jobs        `yaml:"jobs"`
}

type Target added in v1.15.0

type Target struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
}

type TransformerFunc added in v0.8.4

type TransformerFunc func(*Config) (*Config, error)

type UpgradeFunc

type UpgradeFunc func(target, template, oldVersion, newVersion string, cfg map[string]any) (map[string]any, error)

type UsageSnippets added in v1.2.0

type UsageSnippets struct {
	OptionalPropertyRendering OptionalPropertyRenderingOption `yaml:"optionalPropertyRendering"`
	AdditionalProperties      map[string]any                  `yaml:",inline"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
}

type ValidateFunc added in v1.16.0

type ValidateFunc func(Config) error

type WorkflowDispatch added in v0.4.2

type WorkflowDispatch struct {
	Inputs Inputs `yaml:"inputs"`
}

type WorkflowDispatchTagging added in v1.14.11

type WorkflowDispatchTagging struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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