1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-18 22:17:44 +02:00

K8s list deployments (#921)

* Outline of ListDeployments method

* Added implementation of DeploymentList
This commit is contained in:
Milos Gajdos
2019-11-07 07:44:57 +00:00
committed by Asim Aslam
parent 0e3550229b
commit 6f28852e1b
4 changed files with 73 additions and 14 deletions

View File

@ -90,7 +90,7 @@ func detectNamespace() (string, error) {
}
}
// UpdateDeployment
// UpdateDeployment patches kubernetes deployment with metadata provided in body
func (c *client) UpdateDeployment(name string, body interface{}) error {
return api.NewRequest(c.opts).
Patch().
@ -100,3 +100,16 @@ func (c *client) UpdateDeployment(name string, body interface{}) error {
Do().
Error()
}
// ListDeployments lists all kubernetes deployments with given labels
func (c *client) ListDeployments(labels map[string]string) (*DeploymentList, error) {
var deployments DeploymentList
err := api.NewRequest(c.opts).
Get().
Resource("deployments").
Params(&api.Params{LabelSelector: labels}).
Do().
Into(&deployments)
return &deployments, err
}