Skip to content

Commit

Permalink
Add helper function to check if OV exists in cluster (#1571)
Browse files Browse the repository at this point in the history
* Add helper function to check if OV exists incluster to mirror the check for operator

Signed-off-by: Thomas Runyon <runyontr@gmail.com>

* Return default true

Signed-off-by: Thomas Runyon <runyontr@gmail.com>
  • Loading branch information
runyontr committed Jun 29, 2020
1 parent 6fc3086 commit 54b6175
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/kudoctl/util/kudo/kudo.go
Expand Up @@ -98,10 +98,21 @@ func NewClientFromK8s(kudo versioned.Interface, kube kubernetes.Interface) *Clie
func (c *Client) OperatorExistsInCluster(name, namespace string) bool {
operator, err := c.kudoClientset.KudoV1beta1().Operators(namespace).Get(name, v1.GetOptions{})
if err != nil {
clog.V(2).Printf("operator.kudo.dev/%s does not exist\n", name)
clog.V(2).Printf("operator.kudo.dev %s/%s does not exist\n", namespace, name)
return false
}
clog.V(2).Printf("operator.kudo.dev/%s unchanged", operator.Name)
clog.V(2).Printf("operator.kudo.dev %s/%s unchanged", operator.Namespace, operator.Name)
return true
}

// OperatorVersionExistsInCluster checks if a given OperatorVersion object is installed on the current k8s cluster
func (c *Client) OperatorVersionExistsInCluster(name, namespace string) bool {
operator, err := c.kudoClientset.KudoV1beta1().OperatorVersions(namespace).Get(name, v1.GetOptions{})
if err != nil {
clog.V(2).Printf("operatorversion.kudo.dev %s/%s does not exist\n", namespace, name)
return false
}
clog.V(2).Printf("operatorversion.kudo.dev %s/%s unchanged", operator.Namespace, operator.Name)
return true
}

Expand Down

0 comments on commit 54b6175

Please sign in to comment.