From 1dec62e50c9f6179a1d0940b90dc4af73a85fc0e Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Wed, 28 Dec 2022 05:16:03 +0300 Subject: [PATCH] :hammer: Define `DockerConfig` --- cmd/tap.go | 4 ++-- cmd/tapPcapRunner.go | 4 ++-- cmd/tapRunner.go | 4 ++-- config/configStructs/tapConfig.go | 8 ++++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/tap.go b/cmd/tap.go index c0f9391e3..1e9db3bea 100644 --- a/cmd/tap.go +++ b/cmd/tap.go @@ -46,8 +46,8 @@ func init() { log.Debug().Err(err).Send() } - tapCmd.Flags().StringP(configStructs.DockerRegistryLabel, "r", defaultTapConfig.DockerRegistry, "The Docker registry that's hosting the images.") - tapCmd.Flags().StringP(configStructs.DockerTagLabel, "t", defaultTapConfig.DockerTag, "The tag of the Docker images that are going to be pulled.") + tapCmd.Flags().StringP(configStructs.DockerRegistryLabel, "r", defaultTapConfig.Docker.Registry, "The Docker registry that's hosting the images.") + tapCmd.Flags().StringP(configStructs.DockerTagLabel, "t", defaultTapConfig.Docker.Tag, "The tag of the Docker images that are going to be pulled.") tapCmd.Flags().Uint16(configStructs.ProxyPortFrontLabel, defaultTapConfig.Proxy.Front.SrcPort, "Provide a custom port for the front-end proxy/port-forward.") tapCmd.Flags().Uint16(configStructs.ProxyPortHubLabel, defaultTapConfig.Proxy.Hub.SrcPort, "Provide a custom port for the Hub proxy/port-forward.") tapCmd.Flags().String(configStructs.ProxyHostLabel, defaultTapConfig.Proxy.Host, "Provide a custom host for the proxy/port-forward.") diff --git a/cmd/tapPcapRunner.go b/cmd/tapPcapRunner.go index 72f03ac77..1c61c9723 100644 --- a/cmd/tapPcapRunner.go +++ b/cmd/tapPcapRunner.go @@ -228,8 +228,8 @@ func stopAndRemoveContainers( } func pcap(tarPath string) { - docker.SetRegistry(config.Config.Tap.DockerRegistry) - docker.SetTag(config.Config.Tap.DockerTag) + docker.SetRegistry(config.Config.Tap.Docker.Registry) + docker.SetTag(config.Config.Tap.Docker.Tag) ctx := context.Background() cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) diff --git a/cmd/tapRunner.go b/cmd/tapRunner.go index bea17d010..9d705a62a 100644 --- a/cmd/tapRunner.go +++ b/cmd/tapRunner.go @@ -40,8 +40,8 @@ var proxyDone bool func tap() { state.startTime = time.Now() - docker.SetRegistry(config.Config.Tap.DockerRegistry) - docker.SetTag(config.Config.Tap.DockerTag) + docker.SetRegistry(config.Config.Tap.Docker.Registry) + docker.SetTag(config.Config.Tap.Docker.Tag) log.Info().Str("registry", docker.GetRegistry()).Str("tag", docker.GetTag()).Msg("Using Docker:") if config.Config.Tap.Pcap != "" { pcap(config.Config.Tap.Pcap) diff --git a/config/configStructs/tapConfig.go b/config/configStructs/tapConfig.go index fe4192ab1..ddac9a831 100644 --- a/config/configStructs/tapConfig.go +++ b/config/configStructs/tapConfig.go @@ -46,10 +46,14 @@ type ProxyConfig struct { Host string `yaml:"host" default:"127.0.0.1"` } +type DockerConfig struct { + Registry string `yaml:"registry" default:"docker.io/kubeshark"` + Tag string `yaml:"tag" default:"latest"` +} + type TapConfig struct { + Docker DockerConfig `yaml:"docker"` Proxy ProxyConfig `yaml:"proxy"` - DockerRegistry string `yaml:"docker-registry" default:"docker.io/kubeshark"` - DockerTag string `yaml:"docker-tag" default:"latest"` PodRegexStr string `yaml:"regex" default:".*"` Namespaces []string `yaml:"namespaces"` AllNamespaces bool `yaml:"all-namespaces" default:"false"`