file

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSON is JSON file format.
	JSON = "JSON"
	// YAML if YAML file format.
	YAML = "YAML"
)

Variables

View Source
var (
	// ErrorTransformFalseNotSupported indicates that no transform mode is not supported
	ErrorTransformFalseNotSupported = fmt.Errorf("_transform: false is not supported")
	// ErrorFilenameEmpty indicates that you must provide a filename
	ErrorFilenameEmpty = fmt.Errorf("filename cannot be empty")
)

Functions

func Get

func Get(ctx context.Context, fileContent *Content, opt RenderConfig, dumpConfig dump.Config, wsClient *kong.Client) (
	*utils.KongRawState, error,
)

Get process the fileContent and renders a RawState. IDs of entities are matches based on currentState.

func GetForKonnect added in v1.5.0

func GetForKonnect(ctx context.Context, fileContent *Content,
	opt RenderConfig, client *kong.Client,
) (*utils.KongRawState, *utils.KonnectRawState, error)

GetForKonnect processes the fileContent and renders a RawState and KonnectRawState

func KongStateToFile

func KongStateToFile(kongState *state.KongState, config WriteConfig) error

KongStateToFile writes a state object to file with filename. It will omit timestamps and IDs while writing.

func KonnectStateToFile added in v1.5.0

func KonnectStateToFile(kongState *state.KongState, config WriteConfig) error

func WriteContentToFile added in v1.7.0

func WriteContentToFile(content *Content, filename string, format Format) error

Types

type Content

type Content struct {
	FormatVersion string   `json:"_format_version,omitempty" yaml:"_format_version,omitempty"`
	Transform     *bool    `json:"_transform,omitempty" yaml:"_transform,omitempty"`
	Info          *Info    `json:"_info,omitempty" yaml:"_info,omitempty"`
	Workspace     string   `json:"_workspace,omitempty" yaml:"_workspace,omitempty"`
	Konnect       *Konnect `json:"_konnect,omitempty" yaml:"_konnect,omitempty"`

	Services       []FService       `json:"services,omitempty" yaml:",omitempty"`
	Routes         []FRoute         `json:"routes,omitempty" yaml:",omitempty"`
	Consumers      []FConsumer      `json:"consumers,omitempty" yaml:",omitempty"`
	Plugins        []FPlugin        `json:"plugins,omitempty" yaml:",omitempty"`
	Upstreams      []FUpstream      `json:"upstreams,omitempty" yaml:",omitempty"`
	Certificates   []FCertificate   `json:"certificates,omitempty" yaml:",omitempty"`
	CACertificates []FCACertificate `json:"ca_certificates,omitempty" yaml:"ca_certificates,omitempty"`

	RBACRoles []FRBACRole `json:"rbac_roles,omitempty" yaml:"rbac_roles,omitempty"`

	PluginConfigs map[string]kong.Configuration `json:"_plugin_configs,omitempty" yaml:"_plugin_configs,omitempty"`

	ServicePackages []FServicePackage `json:"service_packages,omitempty" yaml:"service_packages,omitempty"`
}

Content represents a serialized Kong state. +k8s:deepcopy-gen=true

func GetContentFromFiles

func GetContentFromFiles(filenames []string) (*Content, error)

GetContentFromFiles reads in a file with a slice of filenames and constructs a state. If filename is `-`, then it will read from os.Stdin. If filename represents a directory, it will traverse the tree rooted at filename, read all the files with .yaml, .yml and .json extensions and generate a content after a merge of the content from all the files.

It will return an error if the file representation is invalid or if there is any error during processing.

func (*Content) DeepCopy added in v1.7.0

func (in *Content) DeepCopy() *Content

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Content.

func (*Content) DeepCopyInto added in v1.7.0

func (in *Content) DeepCopyInto(out *Content)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Content) PopulateDocumentContent added in v1.7.0

func (c Content) PopulateDocumentContent(filenames []string) error

PopulateDocumentContent updates the Documents contained within a Content with the contents of their files on disk. Document files are stored at <root>/ServicePackage.Name/Document.Path and <root>/ServicePackage.Name/ServiceVersion.Version/Document.Path, where <root> is the directory containing the first state file.

func (Content) StripLocalDocumentPath added in v1.7.0

func (c Content) StripLocalDocumentPath()

StripLocalDocumentPath removes local path information from a target state document, returning the base path with a prepended slash. These path values match typical path values for documents created in the Konnect GUI, whereas path values in decK state files are local relative paths with service package and service version directories.

type FCACertificate

type FCACertificate struct {
	kong.CACertificate `yaml:",inline,omitempty"`
}

FCACertificate represents a Kong CACertificate. +k8s:deepcopy-gen=true

func (*FCACertificate) DeepCopy added in v1.7.0

func (in *FCACertificate) DeepCopy() *FCACertificate

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FCACertificate.

func (*FCACertificate) DeepCopyInto added in v1.7.0

func (in *FCACertificate) DeepCopyInto(out *FCACertificate)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FCertificate

type FCertificate struct {
	ID        *string    `json:"id,omitempty" yaml:"id,omitempty"`
	Cert      *string    `json:"cert,omitempty" yaml:"cert,omitempty"`
	Key       *string    `json:"key,omitempty" yaml:"key,omitempty"`
	CreatedAt *int64     `json:"created_at,omitempty" yaml:"created_at,omitempty"`
	Tags      []*string  `json:"tags,omitempty" yaml:"tags,omitempty"`
	SNIs      []kong.SNI `json:"snis,omitempty" yaml:"snis,omitempty"`
}

FCertificate represents a Kong Certificate. +k8s:deepcopy-gen=true

func (*FCertificate) DeepCopy added in v1.7.0

func (in *FCertificate) DeepCopy() *FCertificate

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FCertificate.

func (*FCertificate) DeepCopyInto added in v1.7.0

func (in *FCertificate) DeepCopyInto(out *FCertificate)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FConsumer

type FConsumer struct {
	kong.Consumer `yaml:",inline,omitempty"`
	Plugins       []*FPlugin               `json:"plugins,omitempty" yaml:",omitempty"`
	KeyAuths      []*kong.KeyAuth          `json:"keyauth_credentials,omitempty" yaml:"keyauth_credentials,omitempty"`
	HMACAuths     []*kong.HMACAuth         `json:"hmacauth_credentials,omitempty" yaml:"hmacauth_credentials,omitempty"`
	JWTAuths      []*kong.JWTAuth          `json:"jwt_secrets,omitempty" yaml:"jwt_secrets,omitempty"`
	BasicAuths    []*kong.BasicAuth        `json:"basicauth_credentials,omitempty" yaml:"basicauth_credentials,omitempty"`
	Oauth2Creds   []*kong.Oauth2Credential `json:"oauth2_credentials,omitempty" yaml:"oauth2_credentials,omitempty"`
	ACLGroups     []*kong.ACLGroup         `json:"acls,omitempty" yaml:"acls,omitempty"`
	MTLSAuths     []*kong.MTLSAuth         `json:"mtls_auth_credentials,omitempty" yaml:"mtls_auth_credentials,omitempty"`
}

FConsumer represents a consumer in Kong. +k8s:deepcopy-gen=true

func (*FConsumer) DeepCopy added in v1.7.0

func (in *FConsumer) DeepCopy() *FConsumer

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FConsumer.

func (*FConsumer) DeepCopyInto added in v1.7.0

func (in *FConsumer) DeepCopyInto(out *FConsumer)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FDocument added in v1.7.0

type FDocument struct {
	ID        *string `json:"id,omitempty" yaml:"id,omitempty"`
	Path      *string `json:"path,omitempty" yaml:"path,omitempty"`
	Published *bool   `json:"published,omitempty" yaml:"published,omitempty"`
	Content   *string `json:"-" yaml:"-"`
}

FDocument represents a document in Konnect. The type has been duplicated because the documents are altered before they are exported to the state file for better user experience. +k8s:deepcopy-gen=true

func (*FDocument) DeepCopy added in v1.7.0

func (in *FDocument) DeepCopy() *FDocument

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FDocument.

func (*FDocument) DeepCopyInto added in v1.7.0

func (in *FDocument) DeepCopyInto(out *FDocument)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FPlugin

type FPlugin struct {
	kong.Plugin `yaml:",inline,omitempty"`

	ConfigSource *string `json:"_config,omitempty" yaml:"_config,omitempty"`
}

FPlugin represents a plugin in Kong. +k8s:deepcopy-gen=true

func (*FPlugin) DeepCopy added in v1.7.0

func (in *FPlugin) DeepCopy() *FPlugin

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FPlugin.

func (*FPlugin) DeepCopyInto added in v1.7.0

func (in *FPlugin) DeepCopyInto(out *FPlugin)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (FPlugin) MarshalJSON

func (p FPlugin) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshal method to handle foreign references.

func (FPlugin) MarshalYAML

func (p FPlugin) MarshalYAML() (interface{}, error)

MarshalYAML is a custom marshal method to handle foreign references.

func (*FPlugin) UnmarshalJSON

func (p *FPlugin) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom marshal method to handle foreign references.

func (*FPlugin) UnmarshalYAML

func (p *FPlugin) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is a custom marshal method to handle foreign references.

type FRBACEndpointPermission added in v1.5.0

type FRBACEndpointPermission struct {
	kong.RBACEndpointPermission `yaml:",inline,omitempty"`
}

FRBACEndpointPermission is a wrapper type for RBACEndpointPermission. +k8s:deepcopy-gen=true

func (*FRBACEndpointPermission) DeepCopy added in v1.7.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FRBACEndpointPermission.

func (*FRBACEndpointPermission) DeepCopyInto added in v1.7.0

func (in *FRBACEndpointPermission) DeepCopyInto(out *FRBACEndpointPermission)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (FRBACEndpointPermission) MarshalJSON added in v1.12.0

func (frbac FRBACEndpointPermission) MarshalJSON() ([]byte, error)

type FRBACRole added in v1.5.0

type FRBACRole struct {
	kong.RBACRole       `yaml:",inline,omitempty"`
	EndpointPermissions []*FRBACEndpointPermission `json:"endpoint_permissions,omitempty" yaml:"endpoint_permissions,omitempty"` //nolint
}

FRBACRole represents an RBACRole in Kong +k8s:deepcopy-gen=true

func (*FRBACRole) DeepCopy added in v1.7.0

func (in *FRBACRole) DeepCopy() *FRBACRole

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FRBACRole.

func (*FRBACRole) DeepCopyInto added in v1.7.0

func (in *FRBACRole) DeepCopyInto(out *FRBACRole)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FRoute

type FRoute struct {
	kong.Route `yaml:",inline,omitempty"`
	Plugins    []*FPlugin `json:"plugins,omitempty" yaml:",omitempty"`
}

FRoute represents a Kong Route and it's associated plugins. +k8s:deepcopy-gen=true

func (*FRoute) DeepCopy added in v1.7.0

func (in *FRoute) DeepCopy() *FRoute

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FRoute.

func (*FRoute) DeepCopyInto added in v1.7.0

func (in *FRoute) DeepCopyInto(out *FRoute)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FService

type FService struct {
	kong.Service
	Routes  []*FRoute  `json:"routes,omitempty" yaml:",omitempty"`
	Plugins []*FPlugin `json:"plugins,omitempty" yaml:",omitempty"`

	// sugar property
	URL *string `json:"url,omitempty" yaml:",omitempty"`
}

FService represents a Kong Service and it's associated routes and plugins. +k8s:deepcopy-gen=true

func (*FService) DeepCopy added in v1.7.0

func (in *FService) DeepCopy() *FService

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FService.

func (*FService) DeepCopyInto added in v1.7.0

func (in *FService) DeepCopyInto(out *FService)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (FService) MarshalJSON

func (s FService) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshal method to handle foreign references.

func (FService) MarshalYAML

func (s FService) MarshalYAML() (interface{}, error)

MarshalYAML is a custom marshal to handle SNI.

func (*FService) UnmarshalJSON

func (s *FService) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom marshal method to handle foreign references.

func (*FService) UnmarshalYAML

func (s *FService) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is a custom marshal method to handle foreign references.

type FServicePackage added in v1.5.0

type FServicePackage struct {
	ID          *string           `json:"id,omitempty" yaml:"id,omitempty"`
	Name        *string           `json:"name,omitempty" yaml:"name,omitempty"`
	Description *string           `json:"description,omitempty" yaml:"description,omitempty"`
	Versions    []FServiceVersion `json:"versions,omitempty" yaml:"versions,omitempty"`
	Document    *FDocument        `json:"document,omitempty" yaml:"document,omitempty"`
}

FServicePackage represents a Service package and its associated entities. +k8s:deepcopy-gen=true

func (*FServicePackage) DeepCopy added in v1.7.0

func (in *FServicePackage) DeepCopy() *FServicePackage

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FServicePackage.

func (*FServicePackage) DeepCopyInto added in v1.7.0

func (in *FServicePackage) DeepCopyInto(out *FServicePackage)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FServiceVersion added in v1.5.0

type FServiceVersion struct {
	ID             *string         `json:"id,omitempty" yaml:"id,omitempty"`
	Version        *string         `json:"version,omitempty" yaml:"version,omitempty"`
	Implementation *Implementation `json:"implementation,omitempty" yaml:"implementation,omitempty"`
	Document       *FDocument      `json:"document,omitempty" yaml:"document,omitempty"`
}

FServiceVersion represents a Service version in Konnect. The type is duplicated because only a single document is exported in file while the API allows for multiple documents. +k8s:deepcopy-gen=true

func (*FServiceVersion) DeepCopy added in v1.7.0

func (in *FServiceVersion) DeepCopy() *FServiceVersion

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FServiceVersion.

func (*FServiceVersion) DeepCopyInto added in v1.7.0

func (in *FServiceVersion) DeepCopyInto(out *FServiceVersion)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FTarget

type FTarget struct {
	kong.Target `yaml:",inline,omitempty"`
}

FTarget represents a Kong Target. +k8s:deepcopy-gen=true

func (*FTarget) DeepCopy added in v1.7.0

func (in *FTarget) DeepCopy() *FTarget

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FTarget.

func (*FTarget) DeepCopyInto added in v1.7.0

func (in *FTarget) DeepCopyInto(out *FTarget)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FUpstream

type FUpstream struct {
	kong.Upstream `yaml:",inline,omitempty"`
	Targets       []*FTarget `json:"targets,omitempty" yaml:",omitempty"`
}

FUpstream represents a Kong Upstream and it's associated targets. +k8s:deepcopy-gen=true

func (*FUpstream) DeepCopy added in v1.7.0

func (in *FUpstream) DeepCopy() *FUpstream

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FUpstream.

func (*FUpstream) DeepCopyInto added in v1.7.0

func (in *FUpstream) DeepCopyInto(out *FUpstream)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Format

type Format string

Format is a file format for Kong's configuration.

type Implementation added in v1.5.0

type Implementation struct {
	Type string `json:"type,omitempty" yaml:"type,omitempty"`
	Kong *Kong  `json:"kong,omitempty" yaml:"kong,omitempty"`
}

Implementation represents an implementation of a Service version in Konnect. +k8s:deepcopy-gen=true

func (*Implementation) DeepCopy added in v1.7.0

func (in *Implementation) DeepCopy() *Implementation

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Implementation.

func (*Implementation) DeepCopyInto added in v1.7.0

func (in *Implementation) DeepCopyInto(out *Implementation)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Info

type Info struct {
	SelectorTags []string     `json:"select_tags,omitempty" yaml:"select_tags,omitempty"`
	Defaults     KongDefaults `json:"defaults,omitempty" yaml:"defaults,omitempty"`
}

Info contains meta-data of the file. +k8s:deepcopy-gen=true

func (*Info) DeepCopy added in v1.7.0

func (in *Info) DeepCopy() *Info

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Info.

func (*Info) DeepCopyInto added in v1.7.0

func (in *Info) DeepCopyInto(out *Info)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Kong added in v1.5.0

type Kong struct {
	Service *FService `json:"service,omitempty" yaml:"service,omitempty"`
}

Kong represents Kong implementation of a Service in Konnect. +k8s:deepcopy-gen=true

func (*Kong) DeepCopy added in v1.7.0

func (in *Kong) DeepCopy() *Kong

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Kong.

func (*Kong) DeepCopyInto added in v1.7.0

func (in *Kong) DeepCopyInto(out *Kong)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type KongDefaults added in v1.8.0

type KongDefaults struct {
	Service  *kong.Service  `json:"service,omitempty" yaml:"service,omitempty"`
	Route    *kong.Route    `json:"route,omitempty" yaml:"route,omitempty"`
	Upstream *kong.Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"`
	Target   *kong.Target   `json:"target,omitempty" yaml:"target,omitempty"`
}

KongDefaults represents default values that are filled in for entities with corresponding missing properties. +k8s:deepcopy-gen=true

func (*KongDefaults) DeepCopy added in v1.8.0

func (in *KongDefaults) DeepCopy() *KongDefaults

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KongDefaults.

func (*KongDefaults) DeepCopyInto added in v1.8.0

func (in *KongDefaults) DeepCopyInto(out *KongDefaults)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Konnect added in v1.12.0

type Konnect struct {
	RuntimeGroupName string `json:"runtime_group_name,omitempty" yaml:"runtime_group_name,omitempty"`
}

Konnect contains configuration specific to Konnect. +k8s:deepcopy-gen=true

func (*Konnect) DeepCopy added in v1.12.0

func (in *Konnect) DeepCopy() *Konnect

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Konnect.

func (*Konnect) DeepCopyInto added in v1.12.0

func (in *Konnect) DeepCopyInto(out *Konnect)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RenderConfig

type RenderConfig struct {
	CurrentState *state.KongState
	KongVersion  semver.Version
}

RenderConfig contains necessary information to render a correct KongConfig from a file.

type WriteConfig

type WriteConfig struct {
	Workspace        string
	SelectTags       []string
	Filename         string
	FileFormat       Format
	WithID           bool
	RuntimeGroupName string
}

WriteConfig holds settings to use to write the state file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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