Skip to content

Commit

Permalink
use make(map[string]struct{})
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed Sep 3, 2024
1 parent 4eb88ac commit d7a7b82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions flyteplugins/go/tasks/plugins/webapi/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,26 @@ func getAgentRegistry(ctx context.Context, cs *ClientSet) Registry {
continue
}

var agentSupportedTaskCategories []string
agentSupportedTaskCategories := make(map[string]struct{})
for _, agent := range res.GetAgents() {
deprecatedSupportedTaskTypes := agent.SupportedTaskTypes
agentSupportedTaskCategories = append(agentSupportedTaskCategories, deprecatedSupportedTaskTypes...)
for _, supportedTaskType := range deprecatedSupportedTaskTypes {
agent := &Agent{AgentDeployment: agentDeployment, IsSync: agent.IsSync}
newAgentRegistry[supportedTaskType] = map[int32]*Agent{defaultTaskTypeVersion: agent}
agentSupportedTaskCategories[supportedTaskType] = struct{}{}

Check warning on line 137 in flyteplugins/go/tasks/plugins/webapi/agent/client.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/webapi/agent/client.go#L137

Added line #L137 was not covered by tests
}

supportedTaskCategories := agent.SupportedTaskCategories
for _, supportedCategory := range supportedTaskCategories {
agent := &Agent{AgentDeployment: agentDeployment, IsSync: agent.IsSync}
supportedCategoryName := supportedCategory.GetName()
newAgentRegistry[supportedCategoryName] = map[int32]*Agent{supportedCategory.GetVersion(): agent}
agentSupportedTaskCategories = append(agentSupportedTaskCategories, supportedCategoryName)
agentSupportedTaskCategories[supportedCategoryName] = struct{}{}
}

}
logger.Infof(ctx, "AgentDeployment [%v] supports the following task types: [%v]", agentDeployment.Endpoint, strings.Join(agentSupportedTaskCategories, ", "))
logger.Infof(ctx, "AgentDeployment [%v] supports the following task types: [%v]", agentDeployment.Endpoint,
strings.Join(maps.Keys(agentSupportedTaskCategories), ", "))
}

// If the agent doesn't implement the metadata service, we construct the registry based on the configuration
Expand Down

0 comments on commit d7a7b82

Please sign in to comment.