Add attribute flag building and parsing (#1562)

This adds a few command sketches but that's not the main point of the PR
and filling those out will come in a different PR. This adds a new flag
type that can combine inputs to a single target slice, retaining the
ability to distinguish where it came from but also keep ordering across
different flag names. It also implements a function that does the
heuristic parsing with fallback.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-09-26 11:48:43 -04:00
1 parent 14cc97b645
commit a834a14785
16 files changed
+1166 -36

No files matched your search

+8 -8
View File
@@ -373,14 +373,14 @@ func (r *Repository) Endpoints(ctx context.Context, setIds []string) ([]*host.En
type setInfo struct {
preferredEndpoint endpoint.Option
plgSet *pb.HostSet
plgSet *pb.HostSet
}
type catalogInfo struct{
publicId string
plg plgpb.HostPluginServiceServer
setInfos map[string]*setInfo
plgCat *hcpb.HostCatalog
type catalogInfo struct {
publicId string
plg plgpb.HostPluginServiceServer
setInfos map[string]*setInfo
plgCat *hcpb.HostCatalog
persisted *plgpb.HostCatalogPersisted
}
@@ -458,10 +458,10 @@ func (r *Repository) Endpoints(ctx context.Context, setIds []string) ([]*host.En
sets = append(sets, si.plgSet)
}
resp, err := ci.plg.ListHosts(ctx, &plgpb.ListHostsRequest{
resp, err := ci.plg.ListHosts(ctx, &plgpb.ListHostsRequest{
Catalog: ci.plgCat,
Sets: sets,
//Persisted: ci.persisted,
// Persisted: ci.persisted,
})
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -389,7 +389,7 @@ func TestRepository_Endpoints(t *testing.T) {
}
return &plgpb.ListHostsResponse{Hosts: []*plgpb.ListHostsResponseHost{
{
SetIds: setIds,
SetIds: setIds,
ExternalId: "test",
IpAddresses: []string{"10.0.0.5", "192.168.0.5"},
DnsNames: nil,
@@ -407,7 +407,7 @@ func TestRepository_Endpoints(t *testing.T) {
tests := []struct {
name string
setIds []string
setIds []string
want []*host.Endpoint
wantIsErr errors.Code
}{
@@ -416,7 +416,7 @@ func TestRepository_Endpoints(t *testing.T) {
wantIsErr: errors.InvalidParameter,
},
{
name: "with-set10",
name: "with-set10",
setIds: []string{hostSet10.GetPublicId()},
want: []*host.Endpoint{
{
@@ -431,7 +431,7 @@ func TestRepository_Endpoints(t *testing.T) {
},
},
{
name: "with-different-set",
name: "with-different-set",
setIds: []string{hostSet192.GetPublicId()},
want: []*host.Endpoint{
{
@@ -446,14 +446,14 @@ func TestRepository_Endpoints(t *testing.T) {
},
},
{
name: "with-all-addresses-filtered-set",
name: "with-all-addresses-filtered-set",
setIds: []string{hostSet100.GetPublicId()},
want: nil,
want: nil,
},
{
name: "with-no-hosts-from-plugin",
name: "with-no-hosts-from-plugin",
setIds: []string{hostlessSet.GetPublicId()},
want: nil,
want: nil,
},
}