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 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 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
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") )
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 ¶ added in v1.6.0
func CallGetAll ¶ added in v1.11.0
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 ¶ added in v1.15.0
ConfigFilesInDir traverses the directory rooted at dir and returns all the files with a case-insensitive extension of `yml` or `yaml`.
func Confirm ¶ added in v1.7.0
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 ¶ added in v1.7.0
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 ¶ added in v1.7.0
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 GetConsumerReference ¶ added in v1.12.1
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 ¶ added in v1.5.0
func GetRouteReference ¶ added in v1.12.1
GetRouteReference returns a name+ID only copy of the input route, for use in references from other objects
func GetServiceReference ¶ added in v1.12.1
GetServiceReference returns a name+ID only copy of the input service, for use in references from other objects
func HTTPClient ¶ added in v1.7.0
HTTPClient returns a new Go stdlib's net/http.Client with sane default timeouts.
func HasPathsWithRegex300AndAbove ¶ added in v1.15.0
HasPathsWithRegex300AndAbove checks routes' paths format and returns true if these math a regex-pattern without a '~' prefix.
func IsPathRegexLike ¶ added in v1.15.0
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 ¶ added in v1.7.0
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 ¶ added in v1.15.0
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 ¶ added in v1.15.0
func PrintRouteRegexWarning(unsupportedRoutes []string)
PrintRouteRegexWarning prints out a warning about 3.x routes' path usage.
func RemoveDuplicates ¶ added in v1.11.0
func RemoveDuplicates(slice *[]string)
RemoveDuplicates removes duplicated elements from a slice.
func RemoveTags ¶
RemoveTags removes tags from the Tags in obj.
func SendAnalytics ¶ added in v1.7.0
func WorkspaceExists ¶ added in v1.12.0
func ZeroOutField ¶ added in v1.17.0
func ZeroOutField(obj interface{}, field string)
func ZeroOutTimestamps ¶ added in v1.5.1
func ZeroOutTimestamps(obj interface{})
Types ¶
type AtomicInt32Counter ¶ added in v1.8.0
type AtomicInt32Counter struct {
// contains filtered or unexported fields
}
func (*AtomicInt32Counter) Count ¶ added in v1.8.0
func (a *AtomicInt32Counter) Count() int32
func (*AtomicInt32Counter) Increment ¶ added in v1.8.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
type ErrArray ¶
type ErrArray struct {
Errors []error
}
ErrArray holds an array of errors.
type KongClientConfig ¶
type KongClientConfig struct {
Address string
Workspace string
TLSServerName string
TLSCACert string
TLSSkipVerify bool
Debug bool
SkipWorkspaceCrud bool
Headers []string
HTTPClient *http.Client
Timeout int
CookieJarPath string
TLSClientCert string
TLSClientKey string
// whether or not the client should retry on 429s
Retryable bool
}
KongClientConfig holds config details to use to talk to a Kong server.
func (*KongClientConfig) ForWorkspace ¶ added in v1.2.3
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 ¶ added in v1.5.0
type KonnectRawState ¶ added in v1.5.0
type KonnectRawState struct {
ServicePackages []*konnect.ServicePackage
Documents []*konnect.Document
}
KonnectRawState contains all of Konnect resources.