diff --git a/docs/stackit_network_create.md b/docs/stackit_network_create.md index 9d6ed3097..ab44a8a14 100644 --- a/docs/stackit_network_create.md +++ b/docs/stackit_network_create.md @@ -16,6 +16,9 @@ stackit network create [flags] Create a network with name "network-1" $ stackit network create --name network-1 + Create a network with name "network-1" and a description + $ stackit network create --name network-1 --description "My network" + Create a non-routed network with name "network-1" $ stackit network create --name network-1 --non-routed @@ -38,6 +41,7 @@ stackit network create [flags] ### Options ``` + --description string Description of the network (up to 255 characters) -h, --help Help for "stackit network create" --ipv4-dns-name-servers strings List of DNS name servers for IPv4. Nameservers cannot be defined for routed networks --ipv4-gateway string The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway diff --git a/docs/stackit_network_update.md b/docs/stackit_network_update.md index fbd5523de..e37d19ac1 100644 --- a/docs/stackit_network_update.md +++ b/docs/stackit_network_update.md @@ -16,6 +16,12 @@ stackit network update NETWORK_ID [flags] Update network with ID "xxx" with new name "network-1-new" $ stackit network update xxx --name network-1-new + Update the description of network with ID "xxx" + $ stackit network update xxx --description "My network" + + Clear the description of network with ID "xxx" + $ stackit network update xxx --description "" + Update network with ID "xxx" with no gateway $ stackit network update --no-ipv4-gateway @@ -32,6 +38,7 @@ stackit network update NETWORK_ID [flags] ### Options ``` + --description string Description of the network (up to 255 characters). Use an empty string to clear it -h, --help Help for "stackit network update" --ipv4-dns-name-servers strings List of DNS name servers IPv4. Nameservers cannot be defined for routed networks --ipv4-gateway string The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway diff --git a/go.mod b/go.mod index 9a8cc2ed3..7e1adffb0 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/dns v0.23.1 github.com/stackitcloud/stackit-sdk-go/services/edge v0.13.2 github.com/stackitcloud/stackit-sdk-go/services/git v0.14.1 - github.com/stackitcloud/stackit-sdk-go/services/iaas v1.14.5 + github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.0 github.com/stackitcloud/stackit-sdk-go/services/intake v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.2 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.13.0 diff --git a/go.sum b/go.sum index 307cf0906..b1253aae5 100644 --- a/go.sum +++ b/go.sum @@ -626,8 +626,8 @@ github.com/stackitcloud/stackit-sdk-go/services/edge v0.13.2 h1:UDkXmgOAlP3y/u7F github.com/stackitcloud/stackit-sdk-go/services/edge v0.13.2/go.mod h1:hlUcPvOgH/CzZqH7u4SwV81qiismCVAtvw5pTAf6si4= github.com/stackitcloud/stackit-sdk-go/services/git v0.14.1 h1:7R5peSRer3Y83mfB6wcdCP0vhEjsq4myUdVhl24q6to= github.com/stackitcloud/stackit-sdk-go/services/git v0.14.1/go.mod h1:kz2pl17t9MNQx0+fNXg10ZAVfjmvOtsHB7VlAzu/Io8= -github.com/stackitcloud/stackit-sdk-go/services/iaas v1.14.5 h1:CVRo4/hCy6vLlh6LQjQikTDnh/0KF43nRhKsiicxyXc= -github.com/stackitcloud/stackit-sdk-go/services/iaas v1.14.5/go.mod h1:oJmNZY04vvjrQI+y91ZZWOQiCAREcCldkh6cib+YtP0= +github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.0 h1:DZEd4ORWEAu3/t92xLD7ah5gCshP+n5mOYxdOzdiZLc= +github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.0/go.mod h1:o6Mt/ZUB/3qvIwtu4B57m9IlyaUxAFS2Tu5XImiZxCE= github.com/stackitcloud/stackit-sdk-go/services/intake v0.12.0 h1:1RDIGabA3U/kWrV0vkbkTof075liEHMdn39BsNwDI4k= github.com/stackitcloud/stackit-sdk-go/services/intake v0.12.0/go.mod h1:+v3VG6bXopAB2/uRz5yDXNFUwMSw0qJVRPxb3SDsACM= github.com/stackitcloud/stackit-sdk-go/services/kms v1.14.0 h1:6vZhGEIEqXUcs6pzpVNsHRAcskAVuKRq9lNMCMlYn+Q= diff --git a/internal/cmd/network-area/route/list/list.go b/internal/cmd/network-area/route/list/list.go index c9ef46f6a..abf7ce18c 100644 --- a/internal/cmd/network-area/route/list/list.go +++ b/internal/cmd/network-area/route/list/list.go @@ -152,14 +152,14 @@ func outputResult(p *print.Printer, outputFormat, networkAreaLabel string, route routeNexthop := route.Nexthop if routeNexthop.NexthopIPv4 != nil { nextHop = routeNexthop.NexthopIPv4.Value - nextHopType = routeNexthop.NexthopIPv4.Type + nextHopType = string(routeNexthop.NexthopIPv4.Type) } else if routeNexthop.NexthopIPv6 != nil { nextHop = routeNexthop.NexthopIPv6.Value - nextHopType = routeNexthop.NexthopIPv6.Type + nextHopType = string(routeNexthop.NexthopIPv6.Type) } else if routeNexthop.NexthopBlackhole != nil { - nextHopType = routeNexthop.NexthopBlackhole.Type + nextHopType = string(routeNexthop.NexthopBlackhole.Type) } else if routeNexthop.NexthopInternet != nil { - nextHopType = routeNexthop.NexthopInternet.Type + nextHopType = string(routeNexthop.NexthopInternet.Type) } table.AddRow( diff --git a/internal/cmd/network-area/routingtable/route/create/create.go b/internal/cmd/network-area/routingtable/route/create/create.go index cbf0eed63..96eb20fb0 100644 --- a/internal/cmd/network-area/routingtable/route/create/create.go +++ b/internal/cmd/network-area/routingtable/route/create/create.go @@ -210,14 +210,14 @@ func buildDestination(model *inputModel) *iaas.RouteDestination { case destTypeCIDRv4: return &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: model.DestinationType, + Type: iaas.DestinationCIDRv4Type(model.DestinationType), Value: *model.DestinationValue, }, } case destTypeCIDRv6: return &iaas.RouteDestination{ DestinationCIDRv6: &iaas.DestinationCIDRv6{ - Type: model.DestinationType, + Type: iaas.DestinationCIDRv6Type(model.DestinationType), Value: *model.DestinationValue, }, } @@ -232,27 +232,27 @@ func buildNextHop(model *inputModel) *iaas.RouteNexthop { case nextHopTypeIPv4: return &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: model.NextHopType, + Type: iaas.NexthopIPv4Type(model.NextHopType), Value: *model.NextHopValue, }, } case nextHopTypeIPv6: return &iaas.RouteNexthop{ NexthopIPv6: &iaas.NexthopIPv6{ - Type: model.NextHopType, + Type: iaas.NexthopIPv6Type(model.NextHopType), Value: *model.NextHopValue, }, } case nextHopTypeInternet: return &iaas.RouteNexthop{ NexthopInternet: &iaas.NexthopInternet{ - Type: model.NextHopType, + Type: iaas.NexthopInternetType(model.NextHopType), }, } case nextHopTypeBlackhole: return &iaas.RouteNexthop{ NexthopBlackhole: &iaas.NexthopBlackhole{ - Type: model.NextHopType, + Type: iaas.NexthopBlackholeType(model.NextHopType), }, } default: diff --git a/internal/cmd/network/create/create.go b/internal/cmd/network/create/create.go index 1aae3c8f9..d4f06a1c5 100644 --- a/internal/cmd/network/create/create.go +++ b/internal/cmd/network/create/create.go @@ -25,6 +25,7 @@ import ( const ( nameFlag = "name" + descriptionFlag = "description" ipv4DnsNameServersFlag = "ipv4-dns-name-servers" ipv4PrefixLengthFlag = "ipv4-prefix-length" ipv4PrefixFlag = "ipv4-prefix" @@ -43,6 +44,7 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel Name string + Description *string IPv4DnsNameServers []string IPv4PrefixLength *int64 IPv4Prefix *string @@ -69,6 +71,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { `Create a network with name "network-1"`, `$ stackit network create --name network-1`, ), + examples.NewExample( + `Create a network with name "network-1" and a description`, + `$ stackit network create --name network-1 --description "My network"`, + ), examples.NewExample( `Create a non-routed network with name "network-1"`, `$ stackit network create --name network-1 --non-routed`, @@ -122,7 +128,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("create network : %w", err) @@ -152,6 +158,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(nameFlag, "n", "", "Network name") + cmd.Flags().String(descriptionFlag, "", "Description of the network (up to 255 characters)") cmd.Flags().StringSlice(ipv4DnsNameServersFlag, []string{}, "List of DNS name servers for IPv4. Nameservers cannot be defined for routed networks") cmd.Flags().Int64(ipv4PrefixLengthFlag, 0, "The prefix length of the IPv4 network") cmd.Flags().String(ipv4PrefixFlag, "", "The IPv4 prefix of the network (CIDR)") @@ -190,6 +197,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, Name: flags.FlagToStringValue(p, cmd, nameFlag), + Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), IPv4DnsNameServers: flags.FlagToStringSliceValue(p, cmd, ipv4DnsNameServersFlag), IPv4PrefixLength: flags.FlagToInt64Pointer(p, cmd, ipv4PrefixLengthFlag), IPv4Prefix: flags.FlagToStringPointer(p, cmd, ipv4PrefixFlag), @@ -246,8 +254,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiCreateNetworkRequest { - req := apiClient.DefaultAPI.CreateNetwork(ctx, model.ProjectId, model.Region) +func buildRequest(ctx context.Context, model *inputModel, apiClient iaas.DefaultAPI) iaas.ApiCreateNetworkRequest { + req := apiClient.CreateNetwork(ctx, model.ProjectId, model.Region) var ipv4Network *iaas.CreateNetworkIPv4 var ipv6Network *iaas.CreateNetworkIPv6 @@ -297,6 +305,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli payload := iaas.CreateNetworkPayload{ Name: model.Name, + Description: model.Description, Labels: model.Labels, Routed: utils.Ptr(!model.NonRouted), Ipv4: ipv4Network, diff --git a/internal/cmd/network/create/create_test.go b/internal/cmd/network/create/create_test.go index 37aec4fb0..14458acb9 100644 --- a/internal/cmd/network/create/create_test.go +++ b/internal/cmd/network/create/create_test.go @@ -234,6 +234,26 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(), }, + { + description: "description set", + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[descriptionFlag] = "My network" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.Description = new("My network") + }), + }, + { + description: "description empty", + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[descriptionFlag] = "" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.Description = new("") + }), + }, { description: "required only", flagValues: map[string]string{ @@ -509,6 +529,28 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), }, + { + description: "description set", + model: fixtureInputModel(func(model *inputModel) { + model.Description = new("My network") + }), + expectedRequest: fixtureRequest(func(request *iaas.ApiCreateNetworkRequest) { + *request = request.CreateNetworkPayload(fixturePayload(func(payload *iaas.CreateNetworkPayload) { + payload.Description = new("My network") + })) + }), + }, + { + description: "description empty", + model: fixtureInputModel(func(model *inputModel) { + model.Description = new("") + }), + expectedRequest: fixtureRequest(func(request *iaas.ApiCreateNetworkRequest) { + *request = request.CreateNetworkPayload(fixturePayload(func(payload *iaas.CreateNetworkPayload) { + payload.Description = new("") + })) + }), + }, { description: "only name in payload", model: &inputModel{ @@ -632,7 +674,7 @@ func TestBuildRequest(t *testing.T) { } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), diff --git a/internal/cmd/network/describe/describe.go b/internal/cmd/network/describe/describe.go index f76d18017..4c82faaa7 100644 --- a/internal/cmd/network/describe/describe.go +++ b/internal/cmd/network/describe/describe.go @@ -136,6 +136,8 @@ func outputResult(p *print.Printer, outputFormat string, network *iaas.Network) table.AddSeparator() table.AddRow("NAME", network.Name) table.AddSeparator() + table.AddRow("DESCRIPTION", utils.PtrString(network.Description)) + table.AddSeparator() table.AddRow("STATE", network.Status) table.AddSeparator() diff --git a/internal/cmd/network/list/list.go b/internal/cmd/network/list/list.go index ad412f36a..749090915 100644 --- a/internal/cmd/network/list/list.go +++ b/internal/cmd/network/list/list.go @@ -143,7 +143,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, networks } table := tables.NewTable() - table.SetHeader("ID", "NAME", "STATUS", "PUBLIC IP", "PREFIXES", "ROUTED", "ROUTING TABLE ID") + table.SetHeader("ID", "NAME", "DESCRIPTION", "STATUS", "PUBLIC IP", "PREFIXES", "ROUTED", "ROUTING TABLE ID") for _, network := range networks { var publicIp, prefixes string @@ -160,6 +160,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, networks table.AddRow( network.Id, network.Name, + utils.Truncate(network.Description, 70), network.Status, publicIp, prefixes, diff --git a/internal/cmd/network/update/update.go b/internal/cmd/network/update/update.go index 7d08e7d4d..355e8dbf7 100644 --- a/internal/cmd/network/update/update.go +++ b/internal/cmd/network/update/update.go @@ -27,6 +27,7 @@ const ( networkIdArg = "NETWORK_ID" nameFlag = "name" + descriptionFlag = "description" ipv4DnsNameServersFlag = "ipv4-dns-name-servers" ipv4GatewayFlag = "ipv4-gateway" ipv6DnsNameServersFlag = "ipv6-dns-name-servers" @@ -41,6 +42,7 @@ type inputModel struct { *globalflags.GlobalFlagModel NetworkId string Name *string + Description *string IPv4DnsNameServers *[]string IPv4Gateway *string IPv6DnsNameServers *[]string @@ -62,6 +64,14 @@ func NewCmd(params *types.CmdParams) *cobra.Command { `Update network with ID "xxx" with new name "network-1-new"`, `$ stackit network update xxx --name network-1-new`, ), + examples.NewExample( + `Update the description of network with ID "xxx"`, + `$ stackit network update xxx --description "My network"`, + ), + examples.NewExample( + `Clear the description of network with ID "xxx"`, + `$ stackit network update xxx --description ""`, + ), examples.NewExample( `Update network with ID "xxx" with no gateway`, `$ stackit network update --no-ipv4-gateway`, @@ -107,7 +117,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) err = req.Execute() if err != nil { return fmt.Errorf("update network area: %w", err) @@ -138,6 +148,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(nameFlag, "n", "", "Network name") + cmd.Flags().String(descriptionFlag, "", "Description of the network (up to 255 characters). Use an empty string to clear it") cmd.Flags().StringSlice(ipv4DnsNameServersFlag, nil, "List of DNS name servers IPv4. Nameservers cannot be defined for routed networks") cmd.Flags().String(ipv4GatewayFlag, "", "The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway") cmd.Flags().StringSlice(ipv6DnsNameServersFlag, nil, "List of DNS name servers for IPv6. Nameservers cannot be defined for routed networks") @@ -146,6 +157,19 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(noIpv6GatewayFlag, false, "If set to true, the network doesn't have an IPv6 gateway") cmd.Flags().Var(flags.UUIDFlag(), routingTableIdFlag, "The ID of the routing-table for the network") cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a network. E.g. '--labels key1=value1,key2=value2,...'") + + cmd.MarkFlagsOneRequired( + nameFlag, + descriptionFlag, + ipv4DnsNameServersFlag, + ipv4GatewayFlag, + ipv6DnsNameServersFlag, + ipv6GatewayFlag, + noIpv4GatewayFlag, + noIpv6GatewayFlag, + routingTableIdFlag, + labelFlag, + ) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -159,6 +183,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu model := inputModel{ GlobalFlagModel: globalFlags, Name: flags.FlagToStringPointer(p, cmd, nameFlag), + Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), NetworkId: networkId, IPv4DnsNameServers: flags.FlagToStringSlicePointer(p, cmd, ipv4DnsNameServersFlag), IPv4Gateway: flags.FlagToStringPointer(p, cmd, ipv4GatewayFlag), @@ -174,8 +199,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiPartialUpdateNetworkRequest { - req := apiClient.DefaultAPI.PartialUpdateNetwork(ctx, model.ProjectId, model.Region, model.NetworkId) +func buildRequest(ctx context.Context, model *inputModel, apiClient iaas.DefaultAPI) iaas.ApiPartialUpdateNetworkRequest { + req := apiClient.PartialUpdateNetwork(ctx, model.ProjectId, model.Region, model.NetworkId) var payloadIPv4 *iaas.UpdateNetworkIPv4Body var payloadIPv6 *iaas.UpdateNetworkIPv6Body @@ -209,6 +234,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli payload := iaas.PartialUpdateNetworkPayload{ Name: model.Name, + Description: model.Description, Ipv4: payloadIPv4, Ipv6: payloadIPv6, Labels: model.Labels, diff --git a/internal/cmd/network/update/update_test.go b/internal/cmd/network/update/update_test.go index 8cd5182cc..5dfd94d07 100644 --- a/internal/cmd/network/update/update_test.go +++ b/internal/cmd/network/update/update_test.go @@ -125,6 +125,28 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(), }, + { + description: "description set", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[descriptionFlag] = "My network" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.Description = new("My network") + }), + }, + { + description: "description empty", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[descriptionFlag] = "" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.Description = new("") + }), + }, { description: "required only", argValues: fixtureArgValues(), @@ -317,6 +339,39 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), }, + { + description: "description set", + model: fixtureInputModel(func(model *inputModel) { + model.Description = new("My network") + }), + expectedRequest: fixtureRequest(func(payload *iaas.PartialUpdateNetworkPayload) { + payload.Description = new("My network") + }), + }, + { + description: "description empty", + model: fixtureInputModel(func(model *inputModel) { + model.Description = new("") + }), + expectedRequest: fixtureRequest(func(payload *iaas.PartialUpdateNetworkPayload) { + payload.Description = new("") + }), + }, + { + description: "description only", + model: &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + ProjectId: testProjectId, + Region: testRegion, + }, + NetworkId: testNetworkId, + Description: new("My network"), + }, + expectedRequest: testClient.DefaultAPI.PartialUpdateNetwork(testCtx, testProjectId, testRegion, testNetworkId). + PartialUpdateNetworkPayload(iaas.PartialUpdateNetworkPayload{ + Description: new("My network"), + }), + }, { description: "not setting IPv4DnsNameServers does not result in nil pointer dereference", model: fixtureInputModel(func(model *inputModel) { @@ -343,7 +398,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), diff --git a/internal/pkg/services/iaas/utils/utils.go b/internal/pkg/services/iaas/utils/utils.go index 6f6bd4c83..d5dfa5be2 100644 --- a/internal/pkg/services/iaas/utils/utils.go +++ b/internal/pkg/services/iaas/utils/utils.go @@ -134,9 +134,9 @@ func GetRouteFromAPIResponse(destination, nexthop string, routes []iaas.Route) ( nextHopV6 := route.Nexthop.NexthopIPv6 nextHopV6Matches := nextHopV6 != nil && nextHopV6.Value == nexthop nextHopInet := route.Nexthop.NexthopInternet - nextHopInetMatches := nextHopInet != nil && nextHopInet.Type == nexthop + nextHopInetMatches := nextHopInet != nil && string(nextHopInet.Type) == nexthop nextHopBlackhole := route.Nexthop.NexthopBlackhole - nextHopBlackholeMatches := nextHopBlackhole != nil && nextHopBlackhole.Type == nexthop + nextHopBlackholeMatches := nextHopBlackhole != nil && string(nextHopBlackhole.Type) == nexthop nextHopMatches := nextHopV4Matches || nextHopV6Matches || nextHopInetMatches || nextHopBlackholeMatches if nextHopMatches { return route, nil diff --git a/internal/pkg/services/network-area/routing-table/utils/utils.go b/internal/pkg/services/network-area/routing-table/utils/utils.go index 708c43352..67cda2dd2 100644 --- a/internal/pkg/services/network-area/routing-table/utils/utils.go +++ b/internal/pkg/services/network-area/routing-table/utils/utils.go @@ -23,23 +23,23 @@ func ExtractRouteDetails(route *iaas.Route) RouteDetails { var routeDetails RouteDetails if route.Destination.DestinationCIDRv4 != nil { - routeDetails.DestType = route.Destination.DestinationCIDRv4.Type + routeDetails.DestType = string(route.Destination.DestinationCIDRv4.Type) routeDetails.DestValue = route.Destination.DestinationCIDRv4.Value } else if route.Destination.DestinationCIDRv6 != nil { - routeDetails.DestType = route.Destination.DestinationCIDRv6.Type + routeDetails.DestType = string(route.Destination.DestinationCIDRv6.Type) routeDetails.DestValue = route.Destination.DestinationCIDRv6.Value } if route.Nexthop.NexthopIPv4 != nil { - routeDetails.HopType = route.Nexthop.NexthopIPv4.Type + routeDetails.HopType = string(route.Nexthop.NexthopIPv4.Type) routeDetails.HopValue = route.Nexthop.NexthopIPv4.Value } else if route.Nexthop.NexthopIPv6 != nil { - routeDetails.HopType = route.Nexthop.NexthopIPv6.Type + routeDetails.HopType = string(route.Nexthop.NexthopIPv6.Type) routeDetails.HopValue = route.Nexthop.NexthopIPv6.Value } else if route.Nexthop.NexthopInternet != nil { - routeDetails.HopType = route.Nexthop.NexthopInternet.Type + routeDetails.HopType = string(route.Nexthop.NexthopInternet.Type) } else if route.Nexthop.NexthopBlackhole != nil { - routeDetails.HopType = route.Nexthop.NexthopBlackhole.Type + routeDetails.HopType = string(route.Nexthop.NexthopBlackhole.Type) } if len(route.Labels) > 0 {