mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
89e6725eee
This new controller produces an intermediate output (ComputedRoutes) that is meant to summarize all relevant xRoutes and related mesh configuration in an easier-to-use format for downstream use to construct the ProxyStateTemplate. It also applies status updates to the xRoute resource types to indicate that they are themselves semantically valid inputs.
35 lines
762 B
Go
35 lines
762 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package controller
|
|
|
|
import (
|
|
"github.com/hashicorp/consul/internal/resource"
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
|
)
|
|
|
|
// MakeRequests accepts a list of pbresource.ID and pbresource.Reference items,
|
|
// and mirrors them into a slice of []controller.Request items where the Type
|
|
// of of the items has replaced by 'typ'.
|
|
func MakeRequests[V resource.ReferenceOrID](
|
|
typ *pbresource.Type,
|
|
refs []V,
|
|
) []Request {
|
|
if len(refs) == 0 {
|
|
return nil
|
|
}
|
|
|
|
out := make([]Request, 0, len(refs))
|
|
for _, ref := range refs {
|
|
out = append(out, Request{
|
|
ID: &pbresource.ID{
|
|
Type: typ,
|
|
Tenancy: ref.GetTenancy(),
|
|
Name: ref.GetName(),
|
|
},
|
|
})
|
|
}
|
|
|
|
return out
|
|
}
|