file

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

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

Variables

This section is empty.

Functions

func Get

func Get(fileContent *Content, opt RenderConfig) (*utils.KongRawState, error)

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

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.

Types

type Content

type Content struct {
	FormatVersion string `json:"_format_version,omitempty" yaml:"_format_version,omitempty"`
	Info          *Info  `json:"_info,omitempty" yaml:"_info,omitempty"`
	Workspace     string `json:"_workspace,omitempty" yaml:"_workspace,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"`

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

Content represents a serialized Kong state.

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.

type FCACertificate

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

FCACertificate represents a Kong CACertificate.

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.

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.

type FPlugin

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

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

FPlugin represents a plugin in Kong.

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 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.

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.

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 FTarget

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

FTarget represents a Kong Target.

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.

type Format

type Format string

Format is a file format for Kong's configuration.

type Info

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

Info contains meta-data of the file.

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
}

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