Skip to content

Commit

Permalink
feat: add GetDeployment
Browse files Browse the repository at this point in the history
longhorn/longhorn-9752

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang authored and derekbit committed Nov 24, 2024
1 parent a58ee3e commit d84da51
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions kubernetes/deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package kubernetes

import (
"context"

"github.com/sirupsen/logrus"

appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeclient "k8s.io/client-go/kubernetes"
)

// GetDeployment returns the Deployment with the given name in the given namespace.
func GetDeployment(kubeClient kubeclient.Interface, namespace, name string) (*appsv1.Deployment, error) {
log := logrus.WithFields(logrus.Fields{
"kind": "Deployment",
"namespace": namespace,
"name": name,
})
log.Trace("Getting resource")

return kubeClient.AppsV1().Deployments(namespace).Get(context.Background(), name, metav1.GetOptions{})
}

0 comments on commit d84da51

Please sign in to comment.