Skip to content

Commit

Permalink
feat(wait): add MongoDBOperator readiness check
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Nguyen committed Mar 21, 2021
1 parent 9d7d842 commit 05a640f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ func IsPostgresql(obj *unstructured.Unstructured) bool {
return obj.GetKind() == "postgresql"
}

func IsMongoDB(obj *unstructured.Unstructured) bool {
return obj.GetKind() == "PerconaServerMongoDB"
}

func NewDeployment(ns, name, image string, labels map[string]string, port int32, args ...string) *apps.Deployment {
if labels == nil {
labels = make(map[string]string)
Expand Down
17 changes: 17 additions & 0 deletions wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func (c *Client) IsReady(item *unstructured.Unstructured) (bool, string) {
return c.IsPostgresqlReady(item)
case IsConstraintTemplate(item):
return c.IsConstraintTemplateReady(item)
case IsMongoDB(item):
return c.IsMongoDBReady(item)
}

if item.Object["status"] == nil {
Expand Down Expand Up @@ -260,6 +262,21 @@ func IsElasticReady(item *unstructured.Unstructured) (bool, string) {
return true, ""
}

func (c *Client) IsMongoDBReady(item *unstructured.Unstructured) (bool, string) {
status := item.Object["status"]

if status == nil {
return false, "⏳ waiting to become ready"
}

state := item.Object["status"].(map[string]interface{})["state"]
if state != "ready" {
return false, "⏳ waiting to become ready"
}

return true, ""
}

func (c *Client) IsElasticsearchReady(item *unstructured.Unstructured) (bool, string) {
name := item.GetName()
namespace := item.GetNamespace()
Expand Down

0 comments on commit 05a640f

Please # to comment.