Skip to content
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

Change OOB subnet label to key-pair #251

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example/oob_config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
namespace: oob-ns
subnetLabel: subnet=dhcp
subnetLabel:
subnet: dhcp
7 changes: 5 additions & 2 deletions internal/api/oob_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
10 changes: 2 additions & 8 deletions plugins/oob/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"net"
"os"
"strings"
"time"

"github.com/ironcore-dev/fedhcp/internal/api"
Expand Down Expand Up @@ -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, "=") {
return nil, fmt.Errorf("invalid subnet label: %s, should be 'key=value'", config.SubnetLabel)
}
return config, nil
}

Expand All @@ -78,7 +72,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)
}
Expand Down Expand Up @@ -148,7 +142,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)
}
Expand Down
Loading