-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathingress.go
51 lines (41 loc) · 2.08 KB
/
ingress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package kube
import (
"context"
networkv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// GetIngress returns an Ingress with the given name.
func (c *Client) GetIngress(ctx context.Context, namespace, name string) (*networkv1.Ingress, error) {
return c.client.NetworkingV1().Ingresses(namespace).Get(ctx, name, metav1.GetOptions{})
}
// GetIngresses returns a IngressList.
func (c *Client) GetIngresses(ctx context.Context, namespace string, label ...string) (*networkv1.IngressList, error) {
return c.client.NetworkingV1().Ingresses(namespace).List(ctx, listOptions(label))
}
// CreateIngress creates a new Ingress.
func (c *Client) CreateIngress(ctx context.Context, ing *networkv1.Ingress) (*networkv1.Ingress, error) {
if len(ing.Namespace) == 0 {
return nil, ErrorMissingNamespace
}
return c.client.NetworkingV1().Ingresses(ing.Namespace).Create(ctx, ing, metav1.CreateOptions{})
}
// DeleteIngress deletes a Ingress.
func (c *Client) DeleteIngress(ctx context.Context, namespace, name string) error {
return c.client.NetworkingV1().Ingresses(namespace).Delete(ctx, name, metav1.DeleteOptions{})
}
// GetIngressClass returns an IngressClass with the given name.
func (c *Client) GetIngressClass(ctx context.Context, name string) (*networkv1.IngressClass, error) {
return c.client.NetworkingV1().IngressClasses().Get(ctx, name, metav1.GetOptions{})
}
// GetIngressClasses returns a IngressClassList.
func (c *Client) GetIngressClasses(ctx context.Context, label ...string) (*networkv1.IngressClassList, error) {
return c.client.NetworkingV1().IngressClasses().List(ctx, listOptions(label))
}
// CreateIngressClass creates a new IngressClass.
func (c *Client) CreateIngressClass(ctx context.Context, ingc *networkv1.IngressClass) (*networkv1.IngressClass, error) {
return c.client.NetworkingV1().IngressClasses().Create(ctx, ingc, metav1.CreateOptions{})
}
// DeleteIngressClass deletes a IngressClass.
func (c *Client) DeleteIngressClass(ctx context.Context, name string) error {
return c.client.NetworkingV1().IngressClasses().Delete(ctx, name, metav1.DeleteOptions{})
}