Documentation
¶
Index ¶
- Constants
- Variables
- func SetArrayDefaultValue(array []interface{}, schema map[string]interface{}) []interface{}
- func SetDefaultValue(object, defaultObject map[string]interface{}) map[string]interface{}
- type ClientTLS
- type Configuration
- type Consumer
- type ConsumerGroup
- type GlobalRule
- type Labels
- type MutualTLSClientConfig
- type Plugin
- type PluginConfig
- type PluginMetadata
- type Plugins
- type Route
- type SSL
- type Service
- type StreamRoute
- type StringOrSlice
- type Upstream
- type UpstreamActiveHealthCheck
- type UpstreamActiveHealthCheckHealthy
- type UpstreamActiveHealthCheckUnhealthy
- type UpstreamHealthCheck
- type UpstreamNode
- type UpstreamNodes
- type UpstreamPassiveHealthCheck
- type UpstreamPassiveHealthCheckHealthy
- type UpstreamPassiveHealthCheckUnhealthy
- type UpstreamTimeout
- type Vars
Constants ¶
const (
UpstreamPassHost = "host"
)
Variables ¶
var ( //go:embed data/default_values.json DefaultValues []byte PluginDefaultValues map[string]Plugin )
var (
ReservedKeys = map[string]struct{}{
"if": {},
"then": {},
"else": {},
"default": {},
"type": {},
"properties": {},
"dependencies": {},
"items": {},
}
)
ReservedKeys of default values generated from json schema Special cases: "google-cloud-logging": resource.type = global Other keys already checked manually
Functions ¶
func SetArrayDefaultValue ¶ added in v0.2.1
func SetArrayDefaultValue(array []interface{}, schema map[string]interface{}) []interface{}
func SetDefaultValue ¶ added in v0.2.1
Types ¶
type ClientTLS ¶
type ClientTLS struct {
Cert string `json:"client_cert,omitempty" yaml:"client_cert,omitempty"`
Key string `json:"client_key,omitempty" yaml:"client_key,omitempty"`
// ClientCertID is the referenced SSL id, can't be used with client_cert and client_key
ClientCertID string `json:"client_cert_id,omitempty"`
// Verify Turn on server certificate verification, currently only kafka upstream is supported
Verify bool `json:"verify,omitempty" yaml:"verify,omitempty"`
}
ClientTLS is tls cert and key use in mTLS
type Configuration ¶
type Configuration struct {
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
Services []*Service `yaml:"services,omitempty" json:"services,omitempty"`
Routes []*Route `yaml:"routes,omitempty" json:"routes,omitempty"`
Consumers []*Consumer `yaml:"consumers,omitempty" json:"consumers,omitempty"`
SSLs []*SSL `yaml:"ssls,omitempty" json:"ssls,omitempty"`
GlobalRules []*GlobalRule `yaml:"global_rules,omitempty" json:"global_rules,omitempty"`
PluginConfigs []*PluginConfig `yaml:"plugin_configs,omitempty" json:"plugin_configs,omitempty"`
ConsumerGroups []*ConsumerGroup `yaml:"consumer_groups,omitempty" json:"consumer_groups,omitempty"`
PluginMetadatas []*PluginMetadata `yaml:"plugin_metadatas,omitempty" json:"plugin_metadatas,omitempty"`
StreamRoutes []*StreamRoute `yaml:"stream_routes,omitempty" json:"stream_routes,omitempty"`
Upstreams []*Upstream `yaml:"upstreams,omitempty" json:"upstreams,omitempty"`
}
Configuration is the configuration of services
type Consumer ¶ added in v0.2.0
type Consumer struct {
Username string `json:"username" yaml:"username"`
Desc string `json:"desc,omitempty" yaml:"desc,omitempty"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
GroupID string `json:"group_id,omitempty" yaml:"group_id,omitempty"`
}
Consumer represents the consumer object in APISIX.
type ConsumerGroup ¶ added in v0.2.0
type ConsumerGroup struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Desc string `json:"desc,omitempty" yaml:"desc,omitempty"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
Plugins Plugins `json:"plugins" yaml:"plugins"`
}
ConsumerGroup apisix consumer group object
type GlobalRule ¶ added in v0.2.0
type GlobalRule struct {
ID string `json:"id" yaml:"id"`
Plugins Plugins `json:"plugins" yaml:"plugins"`
}
GlobalRule represents the global_rule object in APISIX.
type MutualTLSClientConfig ¶ added in v0.4.0
type MutualTLSClientConfig struct {
CA string `json:"ca,omitempty" yaml:"ca,omitempty"`
Depth int `json:"depth,omitempty" yaml:"depth,omitempty"`
SkipMtlsUriRegex []string `json:"skip_mtls_uri_regex,omitempty" yaml:"skip_mtls_uri_regex,omitempty"`
}
MutualTLSClientConfig apisix SSL client field
type Plugin ¶ added in v0.2.1
type Plugin map[string]interface{}
func GetPluginDefaultValues ¶ added in v0.2.1
func SpecialPatches ¶ added in v0.2.1
type PluginConfig ¶ added in v0.2.0
type PluginConfig struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Desc string `json:"desc,omitempty" yaml:"desc,omitempty"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
Plugins Plugins `json:"plugins" yaml:"plugins"`
}
PluginConfig apisix plugin object
type PluginMetadata ¶ added in v0.2.0
type PluginMetadata struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Config map[string]interface{} `json:",inline" yaml:",inline"`
}
func (*PluginMetadata) MarshalJSON ¶ added in v0.2.0
func (s *PluginMetadata) MarshalJSON() ([]byte, error)
func (*PluginMetadata) UnmarshalJSON ¶ added in v0.2.0
func (s *PluginMetadata) UnmarshalJSON(p []byte) error
type Route ¶
type Route struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
Description string `json:"desc,omitempty" yaml:"desc,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
Uris []string `json:"uris,omitempty" yaml:"uris,omitempty"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Vars Vars `json:"vars,omitempty" yaml:"vars,omitempty"`
Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"`
EnableWebsocket bool `json:"enable_websocket,omitempty" yaml:"enable_websocket,omitempty"`
RemoteAddr string `json:"remote_addr,omitempty" yaml:"remote_addr,omitempty"`
RemoteAddrs []string `json:"remote_addrs,omitempty" yaml:"remote_addrs,omitempty"`
Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"`
UpstreamID string `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
ServiceID string `json:"service_id,omitempty" yaml:"service_id,omitempty"`
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
PluginConfigID string `json:"plugin_config_id,omitempty" yaml:"plugin_config_id,omitempty"`
FilterFunc string `json:"filter_func,omitempty" yaml:"filter_func,omitempty"`
Script string `json:"script,omitempty" yaml:"script,omitempty"`
ScriptID string `json:"script_id,omitempty" yaml:"script_id,omitempty"`
Status int `json:"status,omitempty" yaml:"status,omitempty"`
// api7
StripPathPrefix bool `json:"strip_path_prefix,omitempty" yaml:"strip_path_prefix,omitempty"`
}
Route apisix route object
type SSL ¶ added in v0.2.0
type SSL struct {
ID string `json:"id" yaml:"id"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
SNI string `json:"sni" yaml:"sni"`
SNIs []string `json:"snis" yaml:"snis"`
Cert string `json:"cert,omitempty" yaml:"cert,omitempty"`
Key string `json:"key,omitempty" yaml:"key,omitempty"`
Certs []string `json:"certs,omitempty" yaml:"certs,omitempty"`
Keys []string `json:"keys,omitempty" yaml:"keys,omitempty"`
Client *MutualTLSClientConfig `json:"client,omitempty" yaml:"client,omitempty"`
ExpTime int `json:"exptime,omitempty" yaml:"exptime,omitempty"`
Status int `json:"status,omitempty" yaml:"status,omitempty"`
SSLProtocols []string `json:"ssl_protocols,omitempty" yaml:"ssl_protocols,omitempty"`
ValidityStart int `json:"validity_start,omitempty" yaml:"validity_start,omitempty"`
ValidityEnd int `json:"validity_end,omitempty" yaml:"validity_end,omitempty"`
}
SSL represents the ssl object in APISIX.
type Service ¶
type Service struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"desc,omitempty" yaml:"desc,omitempty"`
// Labels are used for resource classification and indexing
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
// HTTP hosts for this service.
Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
// Plugin settings on Service level
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
// Upstream settings for the Service.
Upstream Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"`
// UpstreamID settings for the Service.
UpstreamID string `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
// Enables a websocket. Set to false by default.
EnableWebsocket bool `json:"enable_websocket,omitempty" yaml:"enable_websocket,omitempty"`
Script string `json:"script,omitempty" yaml:"script,omitempty"`
// api7
PathPrefix string `json:"path_prefix,omitempty" yaml:"path_prefix,omitempty"`
Status int `json:"status,omitempty" yaml:"status,omitempty"`
}
Service is the abstraction of a backend service on API gateway.
type StreamRoute ¶ added in v0.4.0
type StreamRoute struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Desc string `json:"desc,omitempty" yaml:"desc,omitempty"`
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"`
RemoteAddr string `json:"remote_addr,omitempty" yaml:"remote_addr,omitempty"`
ServerAddr string `json:"server_addr,omitempty" yaml:"server_addr,omitempty"`
ServerPort int `json:"server_port,omitempty" yaml:"server_port,omitempty"`
SNI string `json:"sni,omitempty" yaml:"sni,omitempty"`
Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"`
UpstreamID string `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
ServiceID string `json:"service_id,omitempty" yaml:"service_id,omitempty"`
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
}
StreamRoute represents the stream_route object in APISIX.
type StringOrSlice ¶
StringOrSlice represents a string or a string slice. TODO Do not use interface{} to avoid the reflection overheads.
func (*StringOrSlice) MarshalJSON ¶
func (s *StringOrSlice) MarshalJSON() ([]byte, error)
func (*StringOrSlice) UnmarshalJSON ¶
func (s *StringOrSlice) UnmarshalJSON(p []byte) error
type Upstream ¶
type Upstream struct {
// ID is the upstream name. It should be unique among all upstreams
// in the same service.
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
HashOn string `json:"hash_on,omitempty" yaml:"hash_on,omitempty"`
Key string `json:"key,omitempty" yaml:"key,omitempty"`
Checks *UpstreamHealthCheck `json:"checks,omitempty" yaml:"checks,omitempty"`
Nodes UpstreamNodes `json:"nodes" yaml:"nodes"`
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
Retries int `json:"retries,omitempty" yaml:"retries,omitempty"`
RetryTimeout int `json:"retry_timeout,omitempty" yaml:"retry_timeout,omitempty"`
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
TLS *ClientTLS `json:"tls,omitempty" yaml:"tls,omitempty"`
PassHost string `json:"pass_host,omitempty" yaml:"pass_host,omitempty"`
UpstreamHost string `json:"upstream_host,omitempty" yaml:"upstream_host,omitempty"`
// for Service Discovery
ServiceName string `json:"service_name,omitempty" yaml:"service_name,omitempty"`
DiscoveryType string `json:"discovery_type,omitempty" yaml:"discovery_type,omitempty"`
DiscoveryArgs map[string]string `json:"discovery_args,omitempty" yaml:"discovery_args,omitempty"`
}
Upstream is the definition of the upstream on Service.
type UpstreamActiveHealthCheck ¶
type UpstreamActiveHealthCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
HTTPPath string `json:"http_path,omitempty" yaml:"http_path,omitempty"`
HTTPSVerifyCert bool `json:"https_verify_certificate,omitempty" yaml:"https_verify_certificate,omitempty"`
HTTPRequestHeaders []string `json:"req_headers,omitempty" yaml:"req_headers,omitempty"`
Healthy UpstreamActiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
Unhealthy UpstreamActiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}
UpstreamActiveHealthCheck defines the active kind of upstream health check.
type UpstreamActiveHealthCheckHealthy ¶
type UpstreamActiveHealthCheckHealthy struct {
UpstreamPassiveHealthCheckHealthy `json:",inline" yaml:",inline"`
Interval int `json:"interval,omitempty" yaml:"interval,omitempty"`
}
UpstreamActiveHealthCheckHealthy defines the conditions to judge whether an upstream node is healthy with the active manner.
type UpstreamActiveHealthCheckUnhealthy ¶
type UpstreamActiveHealthCheckUnhealthy struct {
UpstreamPassiveHealthCheckUnhealthy `json:",inline" yaml:",inline"`
Interval int `json:"interval,omitempty" yaml:"interval,omitempty"`
}
UpstreamActiveHealthCheckUnhealthy defines the conditions to judge whether an upstream node is unhealthy with the active manager.
type UpstreamHealthCheck ¶
type UpstreamHealthCheck struct {
Active *UpstreamActiveHealthCheck `json:"active" yaml:"active"`
Passive *UpstreamPassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"`
}
UpstreamHealthCheck defines the active and/or passive health check for an Upstream, with the upstream health check feature, pods can be kicked out or joined in quickly, if the feedback of Kubernetes liveness/readiness probe is long.
type UpstreamNode ¶
type UpstreamNode struct {
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"`
Weight int `json:"weight,omitempty" yaml:"weight,omitempty"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}
UpstreamNode is the node in upstream
type UpstreamNodes ¶
type UpstreamNodes []UpstreamNode
UpstreamNodes is the upstream node list.
func (*UpstreamNodes) UnmarshalJSON ¶
func (n *UpstreamNodes) UnmarshalJSON(p []byte) error
UnmarshalJSON implements json.Unmarshaler interface. lua-cjson doesn't distinguish empty array and table, and by default empty array will be encoded as '{}'. We have to maintain the compatibility.
type UpstreamPassiveHealthCheck ¶
type UpstreamPassiveHealthCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Healthy UpstreamPassiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
Unhealthy UpstreamPassiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}
UpstreamPassiveHealthCheck defines the passive kind of upstream health check.
type UpstreamPassiveHealthCheckHealthy ¶
type UpstreamPassiveHealthCheckHealthy struct {
HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
}
UpstreamPassiveHealthCheckHealthy defines the conditions to judge whether an upstream node is healthy with the passive manner.
type UpstreamPassiveHealthCheckUnhealthy ¶
type UpstreamPassiveHealthCheckUnhealthy struct {
HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
HTTPFailures int `json:"http_failures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcp_failures,omitempty" yaml:"tcp_failures,omitempty"`
Timeouts int `json:"timeouts,omitempty" yaml:"timeouts,omitempty"`
}
UpstreamPassiveHealthCheckUnhealthy defines the conditions to judge whether an upstream node is unhealthy with the passive manager.
type UpstreamTimeout ¶
type UpstreamTimeout struct {
// Connect is the connect timeout
Connect int `json:"connect" yaml:"connect"`
// Send is the send timeout
Send int `json:"send" yaml:"send"`
// Read is the read timeout
Read int `json:"read" yaml:"read"`
}
UpstreamTimeout represents the timeout settings on Upstream.