Skip to content

Commit

Permalink
Add ingMgr Update func (#1869)
Browse files Browse the repository at this point in the history
* add ingMgr Update func

* comment tweak to re-test
  • Loading branch information
KastenMike committed Jan 18, 2023
1 parent 0e80011 commit 425870e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/kube/ingress/ingress_extbeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func (i *ExtensionsV1beta1) Create(ctx context.Context, ingress *unstructured.Un
return i.kubeCli.ExtensionsV1beta1().Ingresses(ing.Namespace).Create(ctx, &ing, opts)
}

// Update can be used to update an ingress resource in extensions v1beta1 apiVersion
func (i *ExtensionsV1beta1) Update(ctx context.Context, ingress *unstructured.Unstructured, opts metav1.UpdateOptions) (runtime.Object, error) {
var ing extensionsv1beta1.Ingress
err := runtime.DefaultUnstructuredConverter.FromUnstructured(ingress.UnstructuredContent(), &ing)
if err != nil {
return nil, errors.Wrapf(err, "Failed converting runtime.Object to extensions/v1beta1 ingress")
}
return i.kubeCli.ExtensionsV1beta1().Ingresses(ing.Namespace).Update(ctx, &ing, opts)
}

// IngressPath can be used to get the backend path that is specified in the
// ingress resource in `ns` namespace and name `releaseName-ingress`
func (i *ExtensionsV1beta1) IngressPath(ctx context.Context, ns, releaseName string) (string, error) {
Expand Down
10 changes: 10 additions & 0 deletions pkg/kube/ingress/ingress_netbeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func (i *NetworkingV1beta1) Create(ctx context.Context, ingress *unstructured.Un
return i.kubeCli.NetworkingV1beta1().Ingresses(ing.Namespace).Create(ctx, &ing, opts)
}

// Update can be used to update an ingress resource in networking v1beta1 apiVersion
func (i *NetworkingV1beta1) Update(ctx context.Context, ingress *unstructured.Unstructured, opts metav1.UpdateOptions) (runtime.Object, error) {
var ing netv1beta1.Ingress
err := runtime.DefaultUnstructuredConverter.FromUnstructured(ingress.UnstructuredContent(), &ing)
if err != nil {
return nil, errors.Wrapf(err, "Failed converting runtime.Object to networking/v1beta1 ingress")
}
return i.kubeCli.NetworkingV1beta1().Ingresses(ing.Namespace).Update(ctx, &ing, opts)
}

// IngressPath can be used to get the backend path that is specified in the
// ingress resource in `ns` namespace and name `releaseName-ingress`
func (i *NetworkingV1beta1) IngressPath(ctx context.Context, ns, releaseName string) (string, error) {
Expand Down
10 changes: 10 additions & 0 deletions pkg/kube/ingress/ingress_netv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func (i *NetworkingV1) Create(ctx context.Context, ingress *unstructured.Unstruc
return i.kubeCli.NetworkingV1().Ingresses(ing.Namespace).Create(ctx, &ing, opts)
}

// Update can be used to update an ingress resource in networking v1 apiVersion
func (i *NetworkingV1) Update(ctx context.Context, ingress *unstructured.Unstructured, opts metav1.UpdateOptions) (runtime.Object, error) {
var ing netv1.Ingress
err := runtime.DefaultUnstructuredConverter.FromUnstructured(ingress.UnstructuredContent(), &ing)
if err != nil {
return nil, errors.Wrapf(err, "Failed converting runtime.Object to networking/v1 ingress")
}
return i.kubeCli.NetworkingV1().Ingresses(ing.Namespace).Update(ctx, &ing, opts)
}

// IngressPath can be used to get the backend path that is specified in the
// ingress resource in `ns` namespace and name `releaseName-ingress`
func (i *NetworkingV1) IngressPath(ctx context.Context, ns, releaseName string) (string, error) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/kube/ingress/ingressmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ const (
type Manager interface {
// List can be used to list all the ingress resources from `ns` namespace
List(ctx context.Context, ns string) (runtime.Object, error)
// Get can be used to to get ingress resource with name `name` in `ns` namespace
// Get can be used to get ingress resource with name `name` in `ns` namespace
Get(ctx context.Context, ns, name string) (runtime.Object, error)
// IngressPath can be used to get the backend path that is specified in the
// ingress resource in `ns` namespace and name `releaseName-ingress`
IngressPath(ctx context.Context, ns, releaseName string) (string, error)
// Create accepts an ingress in as runtime.Object and creates on the cluster
Create(ctx context.Context, ingress *unstructured.Unstructured, opts metav1.CreateOptions) (runtime.Object, error)
// Update accepts an ingress as a runtime.Object and updates it on the cluster
Update(ctx context.Context, ingress *unstructured.Unstructured, opts metav1.UpdateOptions) (runtime.Object, error)
}

// NewManager can be used to get the Manager based on the APIVersion of the ingress resources on the cluster
Expand Down

0 comments on commit 425870e

Please sign in to comment.