Documentation ¶
Index ¶
- Constants
- Variables
- func AddExtToFilename(filename, ext string) string
- func CallGetAll(obj interface{}) (reflect.Value, error)
- func CleanAddress(address string) string
- func CleanKongVersion(version string) (string, error)
- func ConfigFilesInDir(dir string) ([]string, error)
- func Confirm(message string) (bool, error)
- func ConfirmFileOverwrite(filename string, ext string, assumeYes bool) (bool, error)
- func Empty(s *string) bool
- func FilenameToName(filename string) string
- func GetConsumerGroupReference(c kong.ConsumerGroup) *kong.ConsumerGroup
- func GetConsumerReference(c kong.Consumer) *kong.Consumer
- func GetKongClient(opt KongClientConfig) (*kong.Client, error)
- func GetKonnectClient(httpClient *http.Client, config KonnectConfig) (*konnect.Client, error)
- func GetRouteReference(r kong.Route) *kong.Route
- func GetServiceReference(s kong.Service) *kong.Service
- func HTTPClient() *http.Client
- func HTTPClientWithTLSConfig(opt TLSConfig) (*http.Client, error)
- func HasPathsWithRegex300AndAbove(route kong.Route) bool
- func IsPathRegexLike(path string) bool
- func MergeTags(obj interface{}, tags []string) error
- func MustMergeTags(obj interface{}, tags []string)
- func MustRemoveTags(obj interface{}, tags []string)
- func NameToFilename(name string) string
- func ParseKongVersion(version string) (semver.Version, error)
- func PrintRouteRegexWarning(unsupportedRoutes []string)
- func RemoveDuplicates(slice *[]string)
- func RemoveTags(obj interface{}, tags []string) error
- func SendAnalytics(cmd, deckVersion, kongVersion, mode string) error
- func UUID() string
- func WorkspaceExists(ctx context.Context, client *kong.Client) (bool, error)
- func ZeroOutField(obj interface{}, field string)
- func ZeroOutID(obj interface{}, altName *string, withID bool)
- func ZeroOutTimestamps(obj interface{})
- type AtomicInt32Counter
- type Defaulter
- type DefaulterOpts
- type ErrArray
- type KongClientConfig
- type KongRawState
- type KonnectConfig
- type KonnectRawState
- type TLSConfig
Constants ¶
const (
// ImplementationTypeKongGateway indicates an implementation backed by Kong Gateway.
ImplementationTypeKongGateway = "kong-gateway"
)
Variables ¶
var ( Kong140Version = semver.MustParse("1.4.0") Kong300Version = semver.MustParse("3.0.0") Kong340Version = semver.MustParse("3.4.0") )
var ErrorConsumerGroupUpgrade = errors.New(
"a rate-limiting-advanced plugin with config.consumer_groups\n" +
"and/or config.enforce_consumer_groups was found. Please use Consumer Groups scoped\n" +
"Plugins when running against Kong Enterprise 3.4.0 and above.\n\n" +
"Check https://docs.konghq.com/gateway/latest/kong-enterprise/consumer-groups/ for more information",
)
var UpgradeMessage = "Please upgrade your configuration to account for 3.0\n" +
"breaking changes using the following command:\n\n" +
"deck convert --from kong-gateway-2.x --to kong-gateway-3.x\n\n" +
"This command performs the following changes:\n" +
" - upgrade the `_format_version` value to `3.0`\n" +
" - add the `~` prefix to all routes' paths containing a regex-pattern\n\n" +
"These changes may not be correct or exhaustive enough.\n" +
"It is strongly recommended to perform a manual audit\n" +
"of the updated configuration file before applying\n" +
"the configuration in production. Incorrect changes will result in\n" +
"unintended traffic routing by Kong Gateway.\n\n" +
"For more information about this and related changes,\n" +
"please visit: https://docs.konghq.com/deck/latest/3.0-upgrade\n\n"
Functions ¶
func AddExtToFilename ¶
func CallGetAll ¶
func CleanAddress ¶
CleanAddress removes trailling / from a URL.
func CleanKongVersion ¶
CleanKongVersion takes a version of Kong and returns back a string in the form of `/major.minor` version. There are various dashes and dots and other descriptors in Kong version strings, which has often created confusion in code and incorrect parsing, and hence this function does not return the patch version (on which shouldn't rely on anyways).
func ConfigFilesInDir ¶
ConfigFilesInDir traverses the directory rooted at dir and returns all the files with a case-insensitive extension of `yml` or `yaml`.
func Confirm ¶
Confirm prompts a user for a confirmation with message and returns true with no error if input is "yes" or "y" (case-insensitive), otherwise false.
func ConfirmFileOverwrite ¶
ConfirmFileOverwrite is a helper function to determine whether or not the program should truncate and overwrite a file given its name and extension. If the file doesn't already exist in the filesystem, then this will return true, otherwise it will prompt the user for confirmation.
func FilenameToName ¶
FilenameToName (partially) reverses NameToFilename, replacing all URL-encoded path separator characters with the path separator character. It does not re-add a leading separator, because there is no way to know if that separator was included originally, and only some names (document paths) typically include one.
func GetConsumerGroupReference ¶
func GetConsumerGroupReference(c kong.ConsumerGroup) *kong.ConsumerGroup
GetConsumerGroupReference returns a name+ID only copy of the input consumer-group, for use in references from other objects
func GetConsumerReference ¶
GetConsumerReference returns a username+ID only copy of the input consumer, for use in references from other objects
func GetKongClient ¶
func GetKongClient(opt KongClientConfig) (*kong.Client, error)
GetKongClient returns a Kong client
func GetKonnectClient ¶
func GetRouteReference ¶
GetRouteReference returns a name+ID only copy of the input route, for use in references from other objects
func GetServiceReference ¶
GetServiceReference returns a name+ID only copy of the input service, for use in references from other objects
func HTTPClient ¶
HTTPClient returns a new Go stdlib's net/http.Client with sane default timeouts.
func HTTPClientWithTLSConfig ¶ added in v1.5.0
func HasPathsWithRegex300AndAbove ¶
HasPathsWithRegex300AndAbove checks routes' paths format and returns true if these math a regex-pattern without a '~' prefix.
func IsPathRegexLike ¶
IsPathRegexLike checks if a path string contains a regex pattern.
func MustMergeTags ¶
func MustMergeTags(obj interface{}, tags []string)
MustMergeTags is same as MergeTags but panics if there is an error.
func MustRemoveTags ¶
func MustRemoveTags(obj interface{}, tags []string)
MustRemoveTags is same as RemoveTags but panics if there is an error.
func NameToFilename ¶
NameToFilename clears path separators from strings. Some entity names in Kong and Konnect allow path directory separators. Some decK operations write files using entity names, which is not compatible with names that contain path separators. NameToFilename strips leading separator characters and replaces other instances of the separator with its URL-encoded representation.
func ParseKongVersion ¶
ParseKongVersion takes a version string from the Gateway and turns it into a semver-compliant version to be used for comparison across the code.
func PrintRouteRegexWarning ¶
func PrintRouteRegexWarning(unsupportedRoutes []string)
PrintRouteRegexWarning prints out a warning about 3.x routes' path usage.
func RemoveDuplicates ¶
func RemoveDuplicates(slice *[]string)
RemoveDuplicates removes duplicated elements from a slice.
func RemoveTags ¶
RemoveTags removes tags from the Tags in obj.
func SendAnalytics ¶
func ZeroOutField ¶
func ZeroOutField(obj interface{}, field string)
func ZeroOutTimestamps ¶
func ZeroOutTimestamps(obj interface{})
Types ¶
type AtomicInt32Counter ¶
type AtomicInt32Counter struct {
// contains filtered or unexported fields
}
func (*AtomicInt32Counter) Count ¶
func (a *AtomicInt32Counter) Count() int32
func (*AtomicInt32Counter) Increment ¶
func (a *AtomicInt32Counter) Increment(delta int32)
type Defaulter ¶
type Defaulter struct {
// contains filtered or unexported fields
}
Defaulter registers types and fills in struct fields with default values.
func GetDefaulter ¶
func GetDefaulter(ctx context.Context, opts DefaulterOpts) (*Defaulter, error)
GetDefaulter returns a Defaulter object to be used to set defaults on Kong entities. The order of precedence is as follow, from higher to lower:
1. values set in the state file 2. values set in the {_info: defaults:} object in the state file 3. hardcoded defaults under utils/constants.go (Konnect-only)
func NewDefaulter ¶
func NewDefaulter() *Defaulter
NewDefaulter initializes a Defaulter with empty entities.
func (*Defaulter) MustSet ¶
func (d *Defaulter) MustSet(arg interface{})
MustSet is like Set but panics if there is an error.
type DefaulterOpts ¶
type ErrArray ¶
type ErrArray struct {
Errors []error
}
ErrArray holds an array of errors.
type KongClientConfig ¶
type KongClientConfig struct { Address string Workspace string Debug bool SkipWorkspaceCrud bool Headers []string HTTPClient *http.Client Timeout int CookieJarPath string // whether or not the client should retry on 429s Retryable bool TLSConfig TLSConfig }
KongClientConfig holds config details to use to talk to a Kong server.
func (*KongClientConfig) ForWorkspace ¶
func (kc *KongClientConfig) ForWorkspace(name string) KongClientConfig
ForWorkspace returns a copy of KongClientConfig that produces a KongClient for the workspace specified by argument.
type KongRawState ¶
type KongRawState struct { Services []*kong.Service Routes []*kong.Route Plugins []*kong.Plugin Upstreams []*kong.Upstream Targets []*kong.Target Certificates []*kong.Certificate SNIs []*kong.SNI CACertificates []*kong.CACertificate Consumers []*kong.Consumer ConsumerGroups []*kong.ConsumerGroupObject CustomEntities []*custom.Entity Vaults []*kong.Vault KeyAuths []*kong.KeyAuth HMACAuths []*kong.HMACAuth JWTAuths []*kong.JWTAuth BasicAuths []*kong.BasicAuth ACLGroups []*kong.ACLGroup Oauth2Creds []*kong.Oauth2Credential MTLSAuths []*kong.MTLSAuth RBACRoles []*kong.RBACRole RBACEndpointPermissions []*kong.RBACEndpointPermission }
KongRawState contains all of Kong Data
type KonnectConfig ¶
type KonnectRawState ¶
type KonnectRawState struct { ServicePackages []*konnect.ServicePackage Documents []*konnect.Document }
KonnectRawState contains all of Konnect resources.