Skip to content

Commit 1f68ad1

Browse files
committed
rename to channel_helpers
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
1 parent c9c3e5f commit 1f68ad1

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

go/core/pkg/sandboxbackend/channels/channels.go renamed to go/core/pkg/sandboxbackend/channel_helpers/channel_helpers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Package channels holds backend-agnostic helpers for translating AgentHarness
2-
// channel (Slack/Telegram) credentials and allowlists into Substrate
3-
// ActorTemplate container env vars. Both the OpenClaw and Hermes substrate
4-
// paths reuse these primitives; only the env var naming and config shape
5-
// differ per backend.
6-
package channels
1+
// Package channel_helpers holds backend-agnostic helpers for translating
2+
// AgentHarness channel (Slack/Telegram) credentials and allowlists into
3+
// Substrate ActorTemplate container env vars. Both the OpenClaw and Hermes
4+
// substrate paths reuse these primitives; only the env var naming and config
5+
// shape differ per backend.
6+
package channel_helpers
77

88
import (
99
"context"

go/core/pkg/sandboxbackend/channels/channels_test.go renamed to go/core/pkg/sandboxbackend/channel_helpers/channel_helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package channels
1+
package channel_helpers
22

33
import (
44
"context"

go/core/pkg/sandboxbackend/openclaw/channels_shared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66

77
"github.com/kagent-dev/kagent/go/api/v1alpha2"
8-
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channels"
8+
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channel_helpers"
99
"sigs.k8s.io/controller-runtime/pkg/client"
1010
)
1111

@@ -79,5 +79,5 @@ func unsupportedChannelType(name string, typ v1alpha2.AgentHarnessChannelType) e
7979
}
8080

8181
func telegramAllowFrom(ctx context.Context, kube client.Client, namespace string, spec *v1alpha2.AgentHarnessTelegramChannelSpec) ([]string, error) {
82-
return channels.ResolveAllowedUserIDs(ctx, kube, namespace, spec.AllowedUserIDs, spec.AllowedUserIDsFrom)
82+
return channel_helpers.ResolveAllowedUserIDs(ctx, kube, namespace, spec.AllowedUserIDs, spec.AllowedUserIDsFrom)
8383
}

go/core/pkg/sandboxbackend/openclaw/channels_substrate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66

77
"github.com/kagent-dev/kagent/go/api/v1alpha2"
8-
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channels"
8+
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channel_helpers"
99
corev1 "k8s.io/api/core/v1"
1010
"sigs.k8s.io/controller-runtime/pkg/client"
1111
)
@@ -42,7 +42,7 @@ func (a *harnessChannels) addSubstrateTelegram(ctx context.Context, kube client.
4242
return nil, fmt.Errorf("channel %q: telegram spec is required", ch.Name)
4343
}
4444
botEnv := channelSecretEnvVar(ch.Name, "TELEGRAM_BOT")
45-
botEnvVar, err := channels.CredentialContainerEnv(spec.BotToken, botEnv)
45+
botEnvVar, err := channel_helpers.CredentialContainerEnv(spec.BotToken, botEnv)
4646
if err != nil {
4747
return nil, fmt.Errorf("channel %q telegram bot token: %w", ch.Name, err)
4848
}
@@ -76,11 +76,11 @@ func (a *harnessChannels) addSubstrateSlack(ctx context.Context, kube client.Cli
7676
}
7777
botEnv := channelSecretEnvVar(ch.Name, "SLACK_BOT")
7878
appEnv := channelSecretEnvVar(ch.Name, "SLACK_APP")
79-
botEnvVar, err := channels.CredentialContainerEnv(spec.BotToken, botEnv)
79+
botEnvVar, err := channel_helpers.CredentialContainerEnv(spec.BotToken, botEnv)
8080
if err != nil {
8181
return nil, fmt.Errorf("channel %q slack bot token: %w", ch.Name, err)
8282
}
83-
appEnvVar, err := channels.CredentialContainerEnv(spec.AppToken, appEnv)
83+
appEnvVar, err := channel_helpers.CredentialContainerEnv(spec.AppToken, appEnv)
8484
if err != nil {
8585
return nil, fmt.Errorf("channel %q slack app token: %w", ch.Name, err)
8686
}
@@ -100,7 +100,7 @@ func (a *harnessChannels) addSubstrateSlack(ctx context.Context, kube client.Cli
100100
InteractiveReplies: slackInteractiveReplies(opts),
101101
},
102102
}
103-
if chans := channels.TrimNonEmpty(opts.AllowlistChannels); len(chans) > 0 {
103+
if chans := channel_helpers.TrimNonEmpty(opts.AllowlistChannels); len(chans) > 0 {
104104
acc.DM = &groupDM{GroupEnabled: true, GroupChannels: chans}
105105
}
106106
a.slack[ch.Name] = acc

go/core/pkg/sandboxbackend/substrate/channels_hermes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77

88
"github.com/kagent-dev/kagent/go/api/v1alpha2"
9-
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channels"
9+
"github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/channel_helpers"
1010
corev1 "k8s.io/api/core/v1"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212
)
@@ -52,12 +52,12 @@ func hermesTelegramEnv(ctx context.Context, kube client.Client, namespace string
5252
if spec == nil {
5353
return nil, fmt.Errorf("channel %q: telegram spec is required", ch.Name)
5454
}
55-
botEnv, err := channels.CredentialContainerEnv(spec.BotToken, "TELEGRAM_BOT_TOKEN")
55+
botEnv, err := channel_helpers.CredentialContainerEnv(spec.BotToken, "TELEGRAM_BOT_TOKEN")
5656
if err != nil {
5757
return nil, fmt.Errorf("channel %q telegram bot token: %w", ch.Name, err)
5858
}
5959
out := []corev1.EnvVar{botEnv}
60-
allow, err := channels.ResolveAllowedUserIDs(ctx, kube, namespace, spec.AllowedUserIDs, spec.AllowedUserIDsFrom)
60+
allow, err := channel_helpers.ResolveAllowedUserIDs(ctx, kube, namespace, spec.AllowedUserIDs, spec.AllowedUserIDsFrom)
6161
if err != nil {
6262
return nil, fmt.Errorf("channel %q telegram allowed users: %w", ch.Name, err)
6363
}
@@ -72,17 +72,17 @@ func hermesSlackEnv(ctx context.Context, kube client.Client, namespace string, c
7272
if spec == nil {
7373
return nil, fmt.Errorf("channel %q: slack spec is required", ch.Name)
7474
}
75-
botEnv, err := channels.CredentialContainerEnv(spec.BotToken, "SLACK_BOT_TOKEN")
75+
botEnv, err := channel_helpers.CredentialContainerEnv(spec.BotToken, "SLACK_BOT_TOKEN")
7676
if err != nil {
7777
return nil, fmt.Errorf("channel %q slack bot token: %w", ch.Name, err)
7878
}
79-
appEnv, err := channels.CredentialContainerEnv(spec.AppToken, "SLACK_APP_TOKEN")
79+
appEnv, err := channel_helpers.CredentialContainerEnv(spec.AppToken, "SLACK_APP_TOKEN")
8080
if err != nil {
8181
return nil, fmt.Errorf("channel %q slack app token: %w", ch.Name, err)
8282
}
8383
out := []corev1.EnvVar{botEnv, appEnv}
8484
if opts := spec.Hermes; opts != nil {
85-
allow, err := channels.ResolveAllowedUserIDs(ctx, kube, namespace, opts.AllowedUserIDs, opts.AllowedUserIDsFrom)
85+
allow, err := channel_helpers.ResolveAllowedUserIDs(ctx, kube, namespace, opts.AllowedUserIDs, opts.AllowedUserIDsFrom)
8686
if err != nil {
8787
return nil, fmt.Errorf("channel %q slack allowed users: %w", ch.Name, err)
8888
}

0 commit comments

Comments
 (0)