Skip to content

Commit

Permalink
flatten agents list
Browse files Browse the repository at this point in the history
Signed-off-by: Sahil Lakhwani <[email protected]>
  • Loading branch information
sahil-lakhwani committed Oct 19, 2023
1 parent fde28e2 commit c3f9f60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
19 changes: 2 additions & 17 deletions cmd/aperturectl/cmd/cloud/agents.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package cloud

import (
"context"
"fmt"

"github.com/fluxninja/aperture/v2/cmd/aperturectl/cmd/utils"
"github.com/spf13/cobra"

cmdv1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/cmd/v1"
)

var agentGroup string
Expand All @@ -30,17 +26,6 @@ var agentsCmd = &cobra.Command{
return err
}

agents, err := client.ListAgents(context.Background(), &cmdv1.ListAgentsRequest{
AgentGroup: agentGroup,
})
if err != nil {
return err
}

for _, agent := range agents.Agents {
fmt.Println(agent)
}

return nil
return utils.ListAgents(client, agentGroup)
},
}
4 changes: 2 additions & 2 deletions pkg/agent-functions/agents/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (a Agents) ListFlowControlPoints() ([]transport.Result[*cmdv1.ListFlowContr
if err != nil {
return nil, err
}
return transport.SendRequests[cmdv1.ListFlowControlPointsAgentResponse](a.etcdTransport, agents["default"], &req)
return transport.SendRequests[cmdv1.ListFlowControlPointsAgentResponse](a.etcdTransport, flattenAgents(agents), &req)
}

// ListAutoScaleControlPoints lists auto-scale control points of all agents.
Expand All @@ -56,7 +56,7 @@ func (a Agents) ListAutoScaleControlPoints() ([]transport.Result[*cmdv1.ListAuto
if err != nil {
return nil, err
}
return transport.SendRequests[cmdv1.ListAutoScaleControlPointsAgentResponse](a.etcdTransport, agents["default"], &req)
return transport.SendRequests[cmdv1.ListAutoScaleControlPointsAgentResponse](a.etcdTransport, flattenAgents(agents), &req)
}

// ListDiscoveryEntities lists discovery entities.
Expand Down

0 comments on commit c3f9f60

Please sign in to comment.