Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit e4ece18

Browse files
Revert "Add supportTaskTypes for agentservice without write it in config twice. (#398)" (#412)
This reverts commit 2598c96. Signed-off-by: Future Outlier <[email protected]>
1 parent 445fc58 commit e4ece18

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

go/tasks/plugins/webapi/agent/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var (
4444
Insecure: true,
4545
DefaultTimeout: config.Duration{Duration: 10 * time.Second},
4646
},
47+
SupportedTaskTypes: []string{"task_type_1", "task_type_2"},
4748
}
4849

4950
configSection = pluginsConfig.MustRegisterSubSection("agent-service", &defaultConfig)
@@ -65,6 +66,9 @@ type Config struct {
6566

6667
// Maps task types to their agents. {TaskType: AgentId}
6768
AgentForTaskTypes map[string]string `json:"agentForTaskTypes" pflag:"-,"`
69+
70+
// SupportedTaskTypes is a list of task types that are supported by this plugin.
71+
SupportedTaskTypes []string `json:"supportedTaskTypes" pflag:"-,Defines a list of task types that are supported by this plugin."`
6872
}
6973

7074
type Agent struct {

go/tasks/plugins/webapi/agent/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func TestEndToEnd(t *testing.T) {
161161
tr.OnRead(context.Background()).Return(nil, fmt.Errorf("read fail"))
162162
tCtx.OnTaskReader().Return(tr)
163163

164-
agentPlugin := newAgentPlugin(SupportedTaskTypes{})
164+
agentPlugin := newAgentPlugin()
165165
pluginEntry := pluginmachinery.CreateRemotePlugin(agentPlugin)
166166
plugin, err := pluginEntry.LoadPlugin(context.TODO(), newFakeSetupContext("test3"))
167167
assert.NoError(t, err)

go/tasks/plugins/webapi/agent/plugin.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import (
2929

3030
type GetClientFunc func(ctx context.Context, agent *Agent, connectionCache map[*Agent]*grpc.ClientConn) (service.AsyncAgentServiceClient, error)
3131

32-
type TaskType = string
33-
type SupportedTaskTypes []TaskType
3432
type Plugin struct {
3533
metricScope promutils.Scope
3634
cfg *Config
@@ -298,10 +296,8 @@ func getFinalContext(ctx context.Context, operation string, agent *Agent) (conte
298296
return context.WithTimeout(ctx, timeout)
299297
}
300298

301-
func newAgentPlugin(supportedTaskTypes SupportedTaskTypes) webapi.PluginEntry {
302-
if len(supportedTaskTypes) == 0 {
303-
supportedTaskTypes = SupportedTaskTypes{"default_supported_task_type"}
304-
}
299+
func newAgentPlugin() webapi.PluginEntry {
300+
supportedTaskTypes := GetConfig().SupportedTaskTypes
305301

306302
return webapi.PluginEntry{
307303
ID: "agent-service",
@@ -317,9 +313,9 @@ func newAgentPlugin(supportedTaskTypes SupportedTaskTypes) webapi.PluginEntry {
317313
}
318314
}
319315

320-
func RegisterAgentPlugin(supportedTaskTypes SupportedTaskTypes) {
316+
func RegisterAgentPlugin() {
321317
gob.Register(ResourceMetaWrapper{})
322318
gob.Register(ResourceWrapper{})
323319

324-
pluginmachinery.PluginRegistry().RegisterRemotePlugin(newAgentPlugin(supportedTaskTypes))
320+
pluginmachinery.PluginRegistry().RegisterRemotePlugin(newAgentPlugin())
325321
}

go/tasks/plugins/webapi/agent/plugin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestPlugin(t *testing.T) {
4343
})
4444

4545
t.Run("test newAgentPlugin", func(t *testing.T) {
46-
p := newAgentPlugin(SupportedTaskTypes{})
46+
p := newAgentPlugin()
4747
assert.NotNil(t, p)
4848
assert.Equal(t, "agent-service", p.ID)
4949
assert.NotNil(t, p.PluginLoader)

0 commit comments

Comments
 (0)