这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 53 additions & 9 deletions kubechain/api/v1alpha1/contactchannel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,77 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// SlackChannelConfig defines configuration specific to Slack channels
type SlackChannelConfig struct {
// ChannelOrUserID is the Slack channel ID (C...) or user ID (U...)
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=^[CU][A-Z0-9]+$
ChannelOrUserID string `json:"channelOrUserID"`

// ContextAboutChannelOrUser provides context for the LLM about the channel or user
ContextAboutChannelOrUser string `json:"contextAboutChannelOrUser,omitempty"`

// AllowedResponderIDs restricts who can respond (Slack user IDs)
AllowedResponderIDs []string `json:"allowedResponderIDs,omitempty"`
}

// EmailChannelConfig defines configuration specific to Email channels
type EmailChannelConfig struct {
// Address is the recipient email address
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=.+@.+\..+
Address string `json:"address"`

// ContextAboutUser provides context for the LLM about the recipient
ContextAboutUser string `json:"contextAboutUser,omitempty"`

// Subject is the custom subject line
Subject string `json:"subject,omitempty"`
}

// ContactChannelSpec defines the desired state of ContactChannel.
type ContactChannelSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of ContactChannel. Edit contactchannel_types.go to remove/update
Foo string `json:"foo,omitempty"`
// ChannelType is the type of channel (e.g. "slack", "email")
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=slack;email
ChannelType string `json:"channelType"`

// APIKeyFrom references the secret containing the API key or token
// +kubebuilder:validation:Required
APIKeyFrom APIKeySource `json:"apiKeyFrom"`

// SlackConfig holds configuration specific to Slack channels
// +optional
SlackConfig *SlackChannelConfig `json:"slackConfig,omitempty"`

// EmailConfig holds configuration specific to Email channels
// +optional
EmailConfig *EmailChannelConfig `json:"emailConfig,omitempty"`
}

// ContactChannelStatus defines the observed state of ContactChannel.
type ContactChannelStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Ready indicates if the ContactChannel is ready to be used
Ready bool `json:"ready,omitempty"`

// Status indicates the current status of the ContactChannel
// +kubebuilder:validation:Enum=Ready;Error;Pending
Status string `json:"status,omitempty"`

// StatusDetail provides additional details about the current status
StatusDetail string `json:"statusDetail,omitempty"`

// HumanLayerProject is the project ID from HumanLayer API
HumanLayerProject string `json:"humanLayerProject,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="ChannelType",type="string",JSONPath=".spec.channelType"
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status"
// +kubebuilder:printcolumn:name="Detail",type="string",JSONPath=".status.statusDetail",priority=1
// +kubebuilder:resource:scope=Namespaced

// ContactChannel is the Schema for the contactchannels API.
type ContactChannel struct {
Expand Down
48 changes: 47 additions & 1 deletion kubechain/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions kubechain/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"path/filepath"

"github.com/humanlayer/smallchain/kubechain/internal/controller/agent"
"github.com/humanlayer/smallchain/kubechain/internal/controller/contactchannel"
"github.com/humanlayer/smallchain/kubechain/internal/controller/llm"
"github.com/humanlayer/smallchain/kubechain/internal/controller/mcpserver"
"github.com/humanlayer/smallchain/kubechain/internal/controller/task"
Expand Down Expand Up @@ -290,6 +291,14 @@ func main() {
os.Exit(1)
}

if err = (&contactchannel.ContactChannelReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ContactChannel")
os.Exit(1)
}

if metricsCertWatcher != nil {
setupLog.Info("Adding metrics certificate watcher to manager")
if err := mgr.Add(metricsCertWatcher); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@ spec:
singular: contactchannel
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.channelType
name: ChannelType
type: string
- jsonPath: .status.ready
name: Ready
type: boolean
- jsonPath: .status.status
name: Status
type: string
- jsonPath: .status.statusDetail
name: Detail
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: ContactChannel is the Schema for the contactchannels API.
Expand All @@ -39,20 +53,86 @@ spec:
spec:
description: ContactChannelSpec defines the desired state of ContactChannel.
properties:
foo:
description: Foo is an example field of ContactChannel. Edit contactchannel_types.go
to remove/update
apiKeyFrom:
description: APIKeyFrom references the secret containing the API key
or token
properties:
secretKeyRef:
description: SecretKeyRef references a key in a secret
properties:
key:
description: Key is the key in the secret
type: string
name:
description: Name is the name of the secret
type: string
required:
- key
- name
type: object
required:
- secretKeyRef
type: object
channelType:
description: ChannelType is the type of channel (e.g. "slack", "email")
enum:
- slack
- email
type: string
emailConfig:
description: EmailConfig holds configuration specific to Email channels
properties:
address:
description: Address is the recipient email address
pattern: .+@.+\..+
type: string
contextAboutUser:
description: ContextAboutUser provides context for the LLM about
the recipient
type: string
subject:
description: Subject is the custom subject line
type: string
required:
- address
type: object
slackConfig:
description: SlackConfig holds configuration specific to Slack channels
properties:
allowedResponderIDs:
description: AllowedResponderIDs restricts who can respond (Slack
user IDs)
items:
type: string
type: array
channelOrUserID:
description: ChannelOrUserID is the Slack channel ID (C...) or
user ID (U...)
pattern: ^[CU][A-Z0-9]+$
type: string
contextAboutChannelOrUser:
description: ContextAboutChannelOrUser provides context for the
LLM about the channel or user
type: string
required:
- channelOrUserID
type: object
required:
- apiKeyFrom
- channelType
type: object
status:
description: ContactChannelStatus defines the observed state of ContactChannel.
properties:
humanLayerProject:
description: HumanLayerProject is the project ID from HumanLayer API
type: string
ready:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Ready indicates if the ContactChannel is ready to be
used
type: boolean
status:
description: Status indicates the current status of the ContactChannel
enum:
- Ready
- Error
Expand Down
29 changes: 27 additions & 2 deletions kubechain/config/samples/kubechain_v1alpha1_contactchannel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ metadata:
labels:
app.kubernetes.io/name: kubechain
app.kubernetes.io/managed-by: kustomize
name: contactchannel-sample
name: slack-channel-sample
spec:
# TODO(user): Add fields here
channelType: slack
apiKeyFrom:
secretKeyRef:
name: humanlayer-api-key
key: api-key
slackConfig:
channelOrUserID: "C01234ABCDE" # Replace with actual Slack channel ID
contextAboutChannelOrUser: "A channel used for approving deployment requests"
---
apiVersion: kubechain.humanlayer.dev/v1alpha1
kind: ContactChannel
metadata:
labels:
app.kubernetes.io/name: kubechain
app.kubernetes.io/managed-by: kustomize
name: email-channel-sample
spec:
channelType: email
apiKeyFrom:
secretKeyRef:
name: humanlayer-api-key
key: api-key
emailConfig:
address: "approvals@example.com"
contextAboutUser: "The approval team for production deployments"
subject: "Action Required: Deployment Approval"
Loading