From e5919d8166350325e3615c6b436c1a578f0978e1 Mon Sep 17 00:00:00 2001 From: kkumar Date: Mon, 20 Jan 2025 17:41:09 +0530 Subject: [PATCH 1/2] Change subnet lebel to key-pair --- example/oob_config.yaml | 3 ++- internal/api/oob_config.go | 7 +++++-- plugins/oob/plugin.go | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/example/oob_config.yaml b/example/oob_config.yaml index 66df14f..e5fb43b 100644 --- a/example/oob_config.yaml +++ b/example/oob_config.yaml @@ -1,2 +1,3 @@ namespace: oob-ns -subnetLabel: subnet=dhcp \ No newline at end of file +subnetLabel: + subnet: dhcp \ No newline at end of file diff --git a/internal/api/oob_config.go b/internal/api/oob_config.go index 0766c96..1f64839 100644 --- a/internal/api/oob_config.go +++ b/internal/api/oob_config.go @@ -3,7 +3,10 @@ package api +type SubnetLabel struct { + Subnet string `yaml:"subnet"` +} type OOBConfig struct { - Namespace string `yaml:"namespace"` - SubnetLabel string `yaml:"subnetLabel"` + Namespace string `yaml:"namespace"` + SubnetLabel SubnetLabel `yaml:"subnetLabel"` } diff --git a/plugins/oob/plugin.go b/plugins/oob/plugin.go index 18b5aab..8733c1d 100644 --- a/plugins/oob/plugin.go +++ b/plugins/oob/plugin.go @@ -66,7 +66,7 @@ func loadConfig(args ...string) (*api.OOBConfig, error) { } // TODO remove after https://github.com/ironcore-dev/FeDHCP/issues/221 is implemented - if !strings.Contains(config.SubnetLabel, "=") { + if !strings.Contains(config.SubnetLabel.Subnet, "=") { return nil, fmt.Errorf("invalid subnet label: %s, should be 'key=value'", config.SubnetLabel) } return config, nil @@ -78,7 +78,7 @@ func setup6(args ...string) (handler.Handler6, error) { return nil, fmt.Errorf("invalid configuration: %v", err) } - k8sClient, err = NewK8sClient(oobConfig.Namespace, oobConfig.SubnetLabel) + k8sClient, err = NewK8sClient(oobConfig.Namespace, oobConfig.SubnetLabel.Subnet) if err != nil { return nil, fmt.Errorf("failed to create k8s client: %w", err) } @@ -148,7 +148,7 @@ func setup4(args ...string) (handler.Handler4, error) { return nil, fmt.Errorf("invalid configuration: %v", err) } - k8sClient, err = NewK8sClient(oobConfig.Namespace, oobConfig.SubnetLabel) + k8sClient, err = NewK8sClient(oobConfig.Namespace, oobConfig.SubnetLabel.Subnet) if err != nil { return nil, fmt.Errorf("failed to create k8s client: %w", err) } From 34e5b2858b365ea437aca4b03c8f80d170f0b772 Mon Sep 17 00:00:00 2001 From: kkumar Date: Mon, 27 Jan 2025 14:37:26 +0530 Subject: [PATCH 2/2] Remove check for key=value string --- plugins/oob/plugin.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/oob/plugin.go b/plugins/oob/plugin.go index 8733c1d..3db27de 100644 --- a/plugins/oob/plugin.go +++ b/plugins/oob/plugin.go @@ -7,7 +7,6 @@ import ( "fmt" "net" "os" - "strings" "time" "github.com/ironcore-dev/fedhcp/internal/api" @@ -64,11 +63,6 @@ func loadConfig(args ...string) (*api.OOBConfig, error) { if err = yaml.Unmarshal(configData, config); err != nil { return nil, fmt.Errorf("failed to parse config file: %v", err) } - - // TODO remove after https://github.com/ironcore-dev/FeDHCP/issues/221 is implemented - if !strings.Contains(config.SubnetLabel.Subnet, "=") { - return nil, fmt.Errorf("invalid subnet label: %s, should be 'key=value'", config.SubnetLabel) - } return config, nil }