Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Add UndeployAll() using label selectors to clean up monorepo components on project deletion (replaces name-based Undeploy in DeleteProject and the direct undeploy handler) - Add ResourceGC background worker that periodically finds K8s resources whose project label has no matching DB record, deletes after 1h safety window - Widen deployer client type from *kubernetes.Clientset to kubernetes.Interface for testability - UndeployAll accumulates errors via errors.Join instead of failing fast - Add checkout/checkin sidecar dev flow: temporary git tokens, branch checkout, review on checkin with cleanup workers - Add interactive sessions: pod binding, command execution, SSE streaming, ephemeral preview URLs with session cleanup workers - Add GET /workers/pool endpoint for aggregate capacity and queue depth - Add sessions:read and sessions:execute auth scopes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.9 KiB
Go
43 lines
1.9 KiB
Go
package deployer
|
|
|
|
import (
|
|
"context"
|
|
|
|
networkingv1 "k8s.io/api/networking/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/kubernetes"
|
|
)
|
|
|
|
// IngressClient abstracts Kubernetes Ingress operations for testability.
|
|
type IngressClient interface {
|
|
GetIngress(ctx context.Context, namespace, name string) (*networkingv1.Ingress, error)
|
|
CreateIngress(ctx context.Context, namespace string, ingress *networkingv1.Ingress) (*networkingv1.Ingress, error)
|
|
UpdateIngress(ctx context.Context, namespace string, ingress *networkingv1.Ingress) (*networkingv1.Ingress, error)
|
|
DeleteIngress(ctx context.Context, namespace, name string) error
|
|
}
|
|
|
|
// k8sIngressClient wraps kubernetes.Interface to implement IngressClient.
|
|
type k8sIngressClient struct {
|
|
clientset kubernetes.Interface
|
|
}
|
|
|
|
// GetIngress retrieves an Ingress by namespace and name.
|
|
func (c *k8sIngressClient) GetIngress(ctx context.Context, namespace, name string) (*networkingv1.Ingress, error) {
|
|
return c.clientset.NetworkingV1().Ingresses(namespace).Get(ctx, name, metav1.GetOptions{})
|
|
}
|
|
|
|
// CreateIngress creates a new Ingress in the specified namespace.
|
|
func (c *k8sIngressClient) CreateIngress(ctx context.Context, namespace string, ingress *networkingv1.Ingress) (*networkingv1.Ingress, error) {
|
|
return c.clientset.NetworkingV1().Ingresses(namespace).Create(ctx, ingress, metav1.CreateOptions{})
|
|
}
|
|
|
|
// UpdateIngress updates an existing Ingress in the specified namespace.
|
|
func (c *k8sIngressClient) UpdateIngress(ctx context.Context, namespace string, ingress *networkingv1.Ingress) (*networkingv1.Ingress, error) {
|
|
return c.clientset.NetworkingV1().Ingresses(namespace).Update(ctx, ingress, metav1.UpdateOptions{})
|
|
}
|
|
|
|
// DeleteIngress deletes an Ingress by namespace and name.
|
|
func (c *k8sIngressClient) DeleteIngress(ctx context.Context, namespace, name string) error {
|
|
return c.clientset.NetworkingV1().Ingresses(namespace).Delete(ctx, name, metav1.DeleteOptions{})
|
|
}
|