-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transparent-proxy): allow config to be initialized (#10207)
- Introduced `InitializedConfig` structure `InitializedConfig` extends the `Config` struct by adding fields that require additional logic to retrieve their values. These values typically involve interacting with the system or external resources. An `InitializedConfig` can contain nested configuration structs. If these nested structs share field names with the `Config` struct, they should embed the corresponding field from `Config` during initialization. I.e. ```go type Redirect struct { // NamePrefix is a prefix which will be used go generate chains name NamePrefix string Inbound TrafficFlow Outbound TrafficFlow DNS DNS VNet VNet } type InitializedRedirect struct { Redirect DNS InitializedDNS } func (c Redirect) Initialize() (InitializedRedirect, error) { var err error initialized := InitializedRedirect{Redirect: c} // .DNS initialized.DNS, err = c.DNS.Initialize() ... return initialized, nil } ``` I moved obtaining DNS servers from `/etc/resolv.conf` and getting loopback network interface name to initialization methods for appropriate sub-configs. - Combined static variables in `builder_restore.go` By combining them all together at top it makes it easier to read. - Moved iptables/ip6tables consts to consts package As we have a package for consts let's use it everywhere - Got rid of unnecessary `IPTables` struct This structure was unnecessary as it was only used in `BuildIPTablesForRestore`, which also was using only its one method `BuildForRestore`. I moved logic of this method directly inside `BuildIPTablesForRestore`, which removes unnecessary complexity. Signed-off-by: Bart Smykla <bartek@smykla.com> Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
- Loading branch information
1 parent
2863d8c
commit 3b87136
Showing
25 changed files
with
362 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.