-
Notifications
You must be signed in to change notification settings - Fork 2
fix: remove gateway config items from the config file. #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bfb0284
b8852fa
b031588
a15337e
d7f500f
cbcc4fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| log_level: "info" # The log level of the API7 Ingress Controller. | ||
| log_level: "debug" # The log level of the API7 Ingress Controller. | ||
| # the default value is "info". | ||
|
|
||
| controller_name: gateway.api7.io/api7-ingress-controller # The controller name of the API7 Ingress Controller, | ||
|
|
@@ -16,15 +16,15 @@ leader_election: | |
| # will wait between tries of actions with the controller. | ||
| disable: false # Whether to disable leader election. | ||
|
|
||
| ingress_class: api7 # The ingress class name of the API7 Ingress Controller. | ||
| ingress_publish_service: "" # The service name of the ingress publish service. | ||
| ingress_status_address: [] # The status address of the ingress. | ||
| gateway_configs: # The configuration of the API7 Gateway. | ||
| - name: api7 # The name of the Gateway in the Gateway API. | ||
| control_plane: | ||
| admin_key: "${ADMIN_KEY}" # The admin key of the control plane. | ||
| endpoints: | ||
| - ${ENDPOINT} # The endpoint of the control plane. | ||
| tls_verify: false | ||
| addresses: # record the status address of the gateway-api gateway | ||
| - "172.18.0.4" # The LB IP of the gateway service. | ||
| # ingress_class: api7 # The ingress class name of the API7 Ingress Controller. | ||
| # ingress_publish_service: "" # The service name of the ingress publish service. | ||
| # ingress_status_address: [] # The status address of the ingress. | ||
| # gateway_configs: # The configuration of the API7 Gateway. | ||
| # - name: api7 # The name of the Gateway in the Gateway API. | ||
| # control_plane: | ||
| # admin_key: "${ADMIN_KEY}" # The admin key of the control plane. | ||
| # endpoints: | ||
| # - ${ENDPOINT} # The endpoint of the control plane. | ||
| # tls_verify: false | ||
| # addresses: # record the status address of the gateway-api gateway | ||
| # - "172.18.0.4" # The LB IP of the gateway service. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why keep it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will resolve it in the next PR. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,6 @@ func NewDefaultConfig() *Config { | |
| LeaderElectionID: DefaultLeaderElectionID, | ||
| ProbeAddr: DefaultProbeAddr, | ||
| MetricsAddr: DefaultMetricsAddr, | ||
| IngressClass: DefaultIngressClass, | ||
| LeaderElection: NewLeaderElection(), | ||
| } | ||
| } | ||
|
|
@@ -84,21 +83,13 @@ func NewConfigFromFile(filename string) (*Config, error) { | |
| } | ||
|
|
||
| func (c *Config) Validate() error { | ||
|
|
||
| if len(c.GatewayConfigs) == 0 { | ||
| return fmt.Errorf("gateway_configs config is required") | ||
| } | ||
| for _, gc := range c.GatewayConfigs { | ||
| if err := c.validateGatewayConfig(gc); err != nil { | ||
| return fmt.Errorf("failed to validate control_planes: %w", err) | ||
| } | ||
| } | ||
| if c.ControllerName == "" { | ||
| return fmt.Errorf("controller_name is required") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| //nolint:unused | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dito. |
||
| func (c *Config) validateGatewayConfig(gc *GatewayConfig) error { | ||
|
|
||
| if gc.Name == "" { | ||
|
|
@@ -118,75 +109,6 @@ func (c *Config) validateGatewayConfig(gc *GatewayConfig) error { | |
| return nil | ||
| } | ||
|
|
||
| var gatewayNameMap map[string]*GatewayConfig | ||
| var gatewayNameList []string | ||
|
|
||
| func initGatewayNameMap() { | ||
| if gatewayNameMap == nil { | ||
| gatewayNameMap = make(map[string]*GatewayConfig) | ||
| for _, gc := range ControllerConfig.GatewayConfigs { | ||
| gatewayNameMap[gc.Name] = gc | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func GetControlPlaneConfigByGatewatName(gatewatName string) *ControlPlaneConfig { | ||
| initGatewayNameMap() | ||
| if gc, ok := gatewayNameMap[gatewatName]; ok { | ||
| return gc.ControlPlane | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func GetGatewayConfig(gatewayName string) *GatewayConfig { | ||
| initGatewayNameMap() | ||
| if gc, ok := gatewayNameMap[gatewayName]; ok { | ||
| return gc | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func GetFirstGatewayConfig() *GatewayConfig { | ||
| if len(ControllerConfig.GatewayConfigs) > 0 { | ||
| return ControllerConfig.GatewayConfigs[0] | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func GetGatewayAddresses(gatewayName string) []string { | ||
| initGatewayNameMap() | ||
| if gc, ok := gatewayNameMap[gatewayName]; ok { | ||
| return gc.Addresses | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func GatewayConfigs() []*GatewayConfig { | ||
| return ControllerConfig.GatewayConfigs | ||
| } | ||
|
|
||
| func GatewayNameList() []string { | ||
| if gatewayNameList == nil { | ||
| gatewayNameList = make([]string, 0, len(ControllerConfig.GatewayConfigs)) | ||
| for _, gc := range ControllerConfig.GatewayConfigs { | ||
| gatewayNameList = append(gatewayNameList, gc.Name) | ||
| } | ||
| } | ||
| return gatewayNameList | ||
| } | ||
|
|
||
| func GetIngressClass() string { | ||
| return ControllerConfig.IngressClass | ||
| } | ||
|
|
||
| func GetIngressPublishService() string { | ||
| return ControllerConfig.IngressPublishService | ||
| } | ||
|
|
||
| func GetIngressStatusAddress() []string { | ||
| return ControllerConfig.IngressStatusAddress | ||
| } | ||
|
|
||
| func GetControllerName() string { | ||
| return ControllerConfig.ControllerName | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info