From e4100755f460395466f1908304ddaa9a58792e4d Mon Sep 17 00:00:00 2001 From: Artsiom Koltun Date: Sat, 28 Oct 2023 10:25:14 +0200 Subject: [PATCH] refactor: use aip-go Join for resource names Signed-off-by: Artsiom Koltun --- pkg/bridge/common.go | 7 +++++-- pkg/port/common.go | 7 +++++-- pkg/svi/common.go | 7 +++++-- pkg/vrf/common.go | 6 +++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pkg/bridge/common.go b/pkg/bridge/common.go index eb883d30..e327f1eb 100644 --- a/pkg/bridge/common.go +++ b/pkg/bridge/common.go @@ -6,13 +6,13 @@ package bridge import ( "context" - "fmt" "log" "net" "sort" "testing" "github.com/philippgille/gokv/gomap" + "go.einride.tech/aip/resourcename" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" @@ -29,7 +29,10 @@ func sortLogicalBridges(bridges []*pb.LogicalBridge) { } func resourceIDToFullName(resourceID string) string { - return fmt.Sprintf("//network.opiproject.org/bridges/%s", resourceID) + return resourcename.Join( + "//network.opiproject.org/", + "bridges", resourceID, + ) } // TODO: move all of this to a common place diff --git a/pkg/port/common.go b/pkg/port/common.go index 93f9dcaf..99d66c68 100644 --- a/pkg/port/common.go +++ b/pkg/port/common.go @@ -6,13 +6,13 @@ package port import ( "context" - "fmt" "log" "net" "sort" "testing" "github.com/philippgille/gokv/gomap" + "go.einride.tech/aip/resourcename" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" @@ -31,7 +31,10 @@ func sortBridgePorts(ports []*pb.BridgePort) { } func resourceIDToFullName(resourceID string) string { - return fmt.Sprintf("//network.opiproject.org/ports/%s", resourceID) + return resourcename.Join( + "//network.opiproject.org/", + "ports", resourceID, + ) } // TODO: move all of this to a common place diff --git a/pkg/svi/common.go b/pkg/svi/common.go index c2451fbb..84c7d44a 100644 --- a/pkg/svi/common.go +++ b/pkg/svi/common.go @@ -6,13 +6,13 @@ package svi import ( "context" - "fmt" "log" "net" "sort" "testing" "github.com/philippgille/gokv/gomap" + "go.einride.tech/aip/resourcename" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" @@ -31,7 +31,10 @@ func sortSvis(svis []*pb.Svi) { } func resourceIDToFullName(resourceID string) string { - return fmt.Sprintf("//network.opiproject.org/svis/%s", resourceID) + return resourcename.Join( + "//network.opiproject.org/", + "svis", resourceID, + ) } // TODO: move all of this to a common place diff --git a/pkg/vrf/common.go b/pkg/vrf/common.go index 044f86fb..e353be84 100644 --- a/pkg/vrf/common.go +++ b/pkg/vrf/common.go @@ -14,6 +14,7 @@ import ( "testing" "github.com/philippgille/gokv/gomap" + "go.einride.tech/aip/resourcename" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" @@ -30,7 +31,10 @@ func sortVrfs(vrfs []*pb.Vrf) { } func resourceIDToFullName(resourceID string) string { - return fmt.Sprintf("//network.opiproject.org/vrfs/%s", resourceID) + return resourcename.Join( + "//network.opiproject.org/", + "vrfs", resourceID, + ) } func generateRandMAC() ([]byte, error) {