Documentation ¶
Index ¶
- Constants
- func AfterMigrate(apisixConfig *apisix.Config) error
- func ConvertKongRouteToA6(kongService Service, kongRoute Route) apisix.Routes
- func DumpKong(kongAddr string, fileName string) error
- func GenerateApisixServiceUpstream(kongService Service, apisixConfig *apisix.Config) string
- func GenerateProxyRewritePluginConfig(servicePath string, routerPath string, stripPath bool, pathHandling string) *apisix.ProxyRewrite
- func KTAConversionKongConsumerPluginBasicAuthCredential(credential BasicAuthCredential) *apisix.BasicAuthCredential
- func KTAConversionKongConsumerPluginHmacAuthCredential(credential HmacAuthCredential) *apisix.HmacAuthCredential
- func KTAConversionKongConsumerPluginJwtSecrets(secret JwtSecret) *apisix.JwtSecrets
- func KTAConversionKongConsumerPluginKeyAuthCredential(credential KeyAuthCredential) *apisix.KeyAuthCredential
- func KTAConversionKongPluginKeyAuth(kongPlugin Plugin) *apisix.KeyAuth
- func KTAConversionKongPluginProxyCache(kongPlugin Plugin) *apisix.ProxyCache
- func KTAConversionKongPluginRateLimiting(kongPlugin Plugin) *apisix.LimitCount
- func KTAConversionKongUpstreamTargets(kongTargets Targets, kongUpstreamId string) apisix.UpstreamNodes
- func KTAConversionKongUpstreamTimeout(kongTime uint) float32
- func KTAIsKongGlobalPlugin(kongPlugin Plugin) bool
- func KTAUpdateApisixConsumerPlugin(apisixConsumer *apisix.Consumer, kongPlugin interface{})
- func KTAUpdateApisixRoutePlugin(apisixRoute *apisix.Route, kongPlugin *Plugin)
- func KTAUpdateApisixServicePlugin(apisixService *apisix.Service, kongPlugin *Plugin)
- func Migrate(kongConfig *Config) (*apisix.Config, *[]utils.YamlItem, error)
- func MigrateConsumer(kongConfig *Config, apisixConfig *apisix.Config) error
- func MigrateGlobalRules(kongConfig *Config, apisixConfig *apisix.Config) error
- func MigratePlugins(kongConfig *Config, apisixConfig *apisix.Config) error
- func MigrateRoute(kongConfig *Config, apisixConfig *apisix.Config) error
- func MigrateService(kongConfig *Config, apisixConfig *apisix.Config) error
- func MigrateUpstream(kongConfig *Config, apisixConfig *apisix.Config) error
- type A6ServiceUpstreamMapping
- type A6UpstreamNodeHostPort
- type ActiveHealthCheck
- type BasicAuthCredential
- type BasicAuthCredentials
- type CIDRPort
- type Certificate
- type Certificates
- type Config
- type Configuration
- type Consumer
- type Consumers
- type HealthCheck
- type Healthy
- type HmacAuthCredential
- type HmacAuthCredentials
- type JwtSecret
- type JwtSecrets
- type KeyAuth
- type KeyAuthCredential
- type KeyAuthCredentials
- type PassiveHealthCheck
- type Plugin
- type Plugins
- type ProxyCache
- type ProxyCacheMemory
- type RateLimiting
- type Route
- type Routes
- type SNI
- type SNIs
- type Service
- type Services
- type Target
- type Targets
- type Unhealthy
- type Upstream
- type Upstreams
Constants ¶
const KTAKongUpstreamAlgorithmConsistentHashing = "consistent-hashing"
const KTAKongUpstreamAlgorithmLeastConnections = "least-connections"
const KTAKongUpstreamAlgorithmRoundRobin = "round-robin"
const KTASixUpstreamAlgorithmConsistentHashing = "chash"
const KTASixUpstreamAlgorithmLeastConnections = "least_conn"
const KTASixUpstreamAlgorithmRoundRobin = "roundrobin"
const PluginKeyAuth = "key-auth"
const PluginProxyCache = "proxy-cache"
const PluginRateLimiting = "rate-limiting"
const PluginRateLimitingPolicyLocal = "local"
const PluginRateLimitingPolicyRedis = "redis"
Variables ¶
This section is empty.
Functions ¶
func AfterMigrate ¶
func ConvertKongRouteToA6 ¶
func GenerateProxyRewritePluginConfig ¶
func GenerateProxyRewritePluginConfig(servicePath string, routerPath string, stripPath bool, pathHandling string) *apisix.ProxyRewrite
GenerateProxyRewritePluginConfig Generate routing and forwarding rules https://docs.konghq.com/gateway-oss/2.4.x/admin-api/#path-handling-algorithms
func KTAConversionKongConsumerPluginBasicAuthCredential ¶
func KTAConversionKongConsumerPluginBasicAuthCredential(credential BasicAuthCredential) *apisix.BasicAuthCredential
func KTAConversionKongConsumerPluginHmacAuthCredential ¶
func KTAConversionKongConsumerPluginHmacAuthCredential(credential HmacAuthCredential) *apisix.HmacAuthCredential
func KTAConversionKongConsumerPluginJwtSecrets ¶
func KTAConversionKongConsumerPluginJwtSecrets(secret JwtSecret) *apisix.JwtSecrets
func KTAConversionKongConsumerPluginKeyAuthCredential ¶
func KTAConversionKongConsumerPluginKeyAuthCredential(credential KeyAuthCredential) *apisix.KeyAuthCredential
func KTAConversionKongPluginProxyCache ¶
func KTAConversionKongPluginProxyCache(kongPlugin Plugin) *apisix.ProxyCache
func KTAConversionKongPluginRateLimiting ¶
func KTAConversionKongPluginRateLimiting(kongPlugin Plugin) *apisix.LimitCount
func KTAConversionKongUpstreamTargets ¶
func KTAConversionKongUpstreamTargets(kongTargets Targets, kongUpstreamId string) apisix.UpstreamNodes
func KTAIsKongGlobalPlugin ¶
func MigrateGlobalRules ¶
MigrateGlobalRules attention to plugin priority https://docs.konghq.com/gateway-oss/2.4.x/admin-api/#precedence
func MigratePlugins ¶
MigratePlugins This function is only called when the data exported by kong config is used
Types ¶
type A6UpstreamNodeHostPort ¶
func KTAFormatKongTarget ¶
func KTAFormatKongTarget(kongTarget string) (*A6UpstreamNodeHostPort, error)
type ActiveHealthCheck ¶
type ActiveHealthCheck struct { Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"` Healthy Healthy `json:"healthy,omitempty" yaml:"healthy,omitempty"` HTTPPath string `json:"http_path,omitempty" yaml:"http_path,omitempty"` HTTPSSni string `json:"https_sni,omitempty" yaml:"https_sni,omitempty"` HTTPSVerifyCertificate bool `json:"https_verify_certificate,omitempty" yaml:"https_verify_certificate,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"` Unhealthy Unhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"` }
type BasicAuthCredential ¶
type BasicAuthCredentials ¶
type BasicAuthCredentials []BasicAuthCredential
type CIDRPort ¶
type CIDRPort struct { IP string `json:"ip,omitempty" yaml:"ip,omitempty"` Port int `json:"port,omitempty" yaml:"port,omitempty"` }
CIDRPort is the kong cidr port definition.
type Certificate ¶
type Certificate 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"` CertALT string `json:"cert_alt,omitempty" yaml:"cert_alt,omitempty"` KeyALT string `json:"key_alt,omitempty" yaml:"key_alt,omitempty"` SNIs []string `json:"snis,omitempty" yaml:"snis,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` }
Certificate is the kong certificate definition.
type Certificates ¶
type Certificates []Certificate
type Config ¶
type Config struct { Services Services `json:"services,omitempty" yaml:"services,omitempty"` Consumers Consumers `json:"consumers,omitempty" yaml:"consumers,omitempty"` Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"` Upstreams Upstreams `json:"upstreams,omitempty" yaml:"upstreams,omitempty"` Routes Routes `json:"routes,omitempty" yaml:"routes,omitempty"` Targets Targets `json:"targets,omitempty" yaml:"targets,omitempty"` KeyAuthCredentials KeyAuthCredentials `json:"keyauth_credentials,omitempty" yaml:"keyauth_credentials,omitempty"` BasicAuthCredentials BasicAuthCredentials `json:"basicauth_credentials,omitempty" yaml:"basicauth_credentials,omitempty"` HmacAuthCredentials HmacAuthCredentials `json:"hmacauth_credentials,omitempty" yaml:"hmacauth_credentials,omitempty"` JwtSecrets JwtSecrets `json:"jwt_secrets,omitempty" yaml:"jwt_secrets,omitempty"` }
type Configuration ¶
type Configuration map[string]interface{}
Configuration is the kong plugin config definition.
type Consumer ¶
type Consumer struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` CustomID string `json:"custom_id,omitempty" yaml:"custom_id,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` KeyAuthCredentials KeyAuthCredentials `json:"keyauth_credentials,omitempty" yaml:"keyauth_credentials,omitempty"` BasicAuthCredentials BasicAuthCredentials `json:"basicauth_credentials,omitempty" yaml:"basicauth_credentials,omitempty"` HmacAuthCredentials HmacAuthCredentials `json:"hmacauth_credentials,omitempty" yaml:"hmacauth_credentials,omitempty"` JwtSecrets JwtSecrets `json:"jwt_secrets,omitempty" yaml:"jwt_secrets,omitempty"` }
Consumer is the kong consumer definition.
type HealthCheck ¶
type HealthCheck struct { Active ActiveHealthCheck `json:"active,omitempty" yaml:"active,omitempty"` Passive PassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"` Threshold float64 `json:"threshold,omitempty" yaml:"threshold,omitempty"` }
type HmacAuthCredential ¶
type HmacAuthCredentials ¶
type HmacAuthCredentials []HmacAuthCredential
type JwtSecret ¶
type JwtSecret struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` ConsumerID string `json:"consumer,omitempty" yaml:"consumer,omitempty"` Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` Key string `json:"key,omitempty" yaml:"key,omitempty"` Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` }
type JwtSecrets ¶
type JwtSecrets []JwtSecret
type KeyAuth ¶
type KeyAuth struct { Anonymous string `yaml:"anonymous"` HideCredentials bool `yaml:"hide_credentials"` KeyInBody bool `yaml:"key_in_body"` KeyInHeader bool `yaml:"key_in_header"` KeyInQuery bool `yaml:"key_in_query"` KeyNames []string `yaml:"key_names"` RunOnPreflight bool `yaml:"run_on_preflight"` }
type KeyAuthCredential ¶
type KeyAuthCredentials ¶
type KeyAuthCredentials []KeyAuthCredential
type PassiveHealthCheck ¶
type Plugin ¶
type Plugin struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` RouteID string `json:"route,omitempty" yaml:"route,omitempty"` ServiceID string `json:"service,omitempty" yaml:"service,omitempty"` ConsumerID string `json:"consumer,omitempty" yaml:"consumer,omitempty"` Config Configuration `json:"config,omitempty" yaml:"config,omitempty"` Protocols []string `json:"protocols,omitempty" yaml:"protocols,omitempty"` Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` }
Plugin is the kong plugin definition.
type ProxyCache ¶
type ProxyCache struct { CacheControl bool `yaml:"cache_control"` CacheTTL int `yaml:"cache_ttl"` ContentType []string `yaml:"content_type"` Memory ProxyCacheMemory `yaml:"memory"` RequestMethod []string `yaml:"request_method"` ResponseCode []int `yaml:"response_code"` StorageTTL int `yaml:"storage_ttl"` Strategy string `yaml:"strategy"` VaryHeaders []string `yaml:"vary_headers"` VaryQueryParams []string `yaml:"vary_query_params"` }
type ProxyCacheMemory ¶
type ProxyCacheMemory struct {
DictionaryName string `yaml:"dictionary_name"`
}
type RateLimiting ¶
type RateLimiting struct { Day int `yaml:"day"` FaultTolerant bool `yaml:"fault_tolerant"` HeaderName string `yaml:"header_name"` HideClientHeaders bool `yaml:"hide_client_headers"` Hour int `yaml:"hour"` LimitBy string `yaml:"limit_by"` Minute int `yaml:"minute"` Month int `yaml:"month"` Path string `yaml:"path"` Policy string `yaml:"policy"` RedisDatabase int `yaml:"redis_database"` RedisHost string `yaml:"redis_host"` RedisPassword string `yaml:"redis_password"` RedisPort int `yaml:"redis_port"` RedisTimeout int `yaml:"redis_timeout"` Second int `yaml:"second"` Year int `yaml:"year"` }
type Route ¶
type Route struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Protocols []string `json:"protocols,omitempty" yaml:"protocols,omitempty"` Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"` Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"` Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"` Headers map[string][]string `json:"headers,omitempty" yaml:"headers,omitempty"` HTTPSRedirectStatusCode int `json:"https_redirect_status_code,omitempty" yaml:"https_redirect_status_code,omitempty"` RegexPriority uint `json:"regex_priority,omitempty" yaml:"regex_priority,omitempty"` StripPath bool `json:"strip_path" yaml:"strip_path"` PathHandling string `json:"path_handling,omitempty" yaml:"path_handling,omitempty"` PreserveHost bool `json:"preserve_host,omitempty" yaml:"preserve_host,omitempty"` RequestBuffering bool `json:"request_buffering,omitempty" yaml:"request_buffering,omitempty"` ResponseBuffering bool `json:"response_buffering,omitempty" yaml:"response_buffering,omitempty"` SNIs []string `json:"snis,omitempty" yaml:"snis,omitempty"` Sources []CIDRPort `json:"sources,omitempty" yaml:"sources,omitempty"` Destinations []CIDRPort `json:"destinations,omitempty" yaml:"destinations,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` ServiceID string `json:"service,omitempty" yaml:"service,omitempty"` Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"` }
Route is the kong route definition.
type SNI ¶
type SNI struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Certificate Certificate `json:"certificate,omitempty" yaml:"certificate,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` }
SNI is the kong sni definition.
type Service ¶
type Service struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Retries uint `json:"retries,omitempty" yaml:"retries,omitempty"` Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"` Host string `json:"host,omitempty" yaml:"host,omitempty"` Path string `json:"path,omitempty" yaml:"path,omitempty"` Port int `json:"port,omitempty" yaml:"port,omitempty"` ConnectTimeout uint `json:"connect_timeout,omitempty" yaml:"connect_timeout,omitempty"` ReadTimeout uint `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty"` WriteTimeout uint `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` ClientCertificate Certificate `json:"client_certificate,omitempty" yaml:"client_certificate,omitempty"` TLSVerify bool `json:"tls_verify,omitempty" yaml:"tls_verify,omitempty"` TLSVerifyDepth int `json:"tls_verify_depth,omitempty" yaml:"tls_verify_depth,omitempty"` CACertificates []string `json:"ca_certificates,omitempty" yaml:"ca_certificates,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` Routes Routes `json:"routes,omitempty" yaml:"routes,omitempty"` Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"` }
Service is the kong service definition.
func FindKongServiceByHost ¶
type Target ¶
type Target struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Target string `json:"target,omitempty" yaml:"target,omitempty"` UpstreamID string `json:"upstream,omitempty" yaml:"upstream,omitempty"` Weight int `json:"weight,omitempty" yaml:"weight,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` }
type Unhealthy ¶
type Unhealthy struct { HTTPFailures int `json:"http_failures,omitempty" yaml:"http_failures,omitempty"` HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"` TCPFailures int `json:"tcp_failures,omitempty" yaml:"tcp_failures,omitempty"` Timeouts int `json:"timeouts,omitempty" yaml:"timeouts,omitempty"` Interval int `json:"interval,omitempty" yaml:"interval,omitempty"` }
type Upstream ¶
type Upstream struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` HashOn string `json:"hash_on,omitempty" yaml:"hash_on,omitempty"` HashFallback string `json:"hash_fallback,omitempty" yaml:"hash_fallback,omitempty"` HashOnHeader string `json:"hash_on_header,omitempty" yaml:"hash_on_header,omitempty"` HashFallbackHeader string `json:"hash_fallback_header,omitempty" yaml:"hash_fallback_header,omitempty"` HashOnCookie string `json:"hash_on_cookie,omitempty" yaml:"hash_on_cookie,omitempty"` HashOnCookiePath string `json:"hash_on_cookie_path,omitempty" yaml:"hash_on_cookie_path,omitempty"` Slots int `json:"slots,omitempty" yaml:"slots,omitempty"` HealthChecks HealthCheck `json:"healthchecks,omitempty" yaml:"healthchecks,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` HostHeader string `json:"host_header,omitempty" yaml:"host_header,omitempty"` ClientCertificate Certificate `json:"client_certificate,omitempty" yaml:"client_certificate,omitempty"` Targets Targets `json:"targets,omitempty" yaml:"targets,omitempty"` }
Upstream is the kong upstream definition.