Skip to content

Commit

Permalink
feat(crd): create & apply CRD can ignore discovery if set (#180)
Browse files Browse the repository at this point in the history
Recipe based create or apply action introduces IgnoreDiscovery
boolean flag. This is set to false by default. When this is
set to true it avoids discovering CRD if this CRD got created.

This solves the problem of waiting for each CRD to get
discovered when a Recipe consisting of one or more CRDs get
created.

Signed-off-by: AmitKumarDas <[email protected]>
  • Loading branch information
Amit Kumar Das authored Nov 14, 2020
1 parent ea9dc5d commit f01b6bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
12 changes: 7 additions & 5 deletions pkg/recipe/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,13 @@ func (a *Applyable) createCRD() (*types.ApplyResult, error) {
nil,
)
})
// run an additional step to wait till this CRD
// is discovered at apiserver
err = a.postCreateCRD(crd)
if err != nil {
return nil, err
if !a.Apply.IgnoreDiscovery {
// run an additional step to wait till this CRD
// is discovered at apiserver
err = a.postCreateCRD(crd)
if err != nil {
return nil, err
}
}
return &types.ApplyResult{
Phase: types.ApplyStatusPassed,
Expand Down
12 changes: 7 additions & 5 deletions pkg/recipe/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,13 @@ func (c *Creatable) createCRD() (*types.CreateResult, error) {
nil,
)
})
// run an additional step to wait till this CRD
// is discovered at apiserver
err = c.postCreateCRD(crd)
if err != nil {
return nil, err
if !c.Create.IgnoreDiscovery {
// run an additional step to wait till this CRD
// is discovered at apiserver
err = c.postCreateCRD(crd)
if err != nil {
return nil, err
}
}
return &types.CreateResult{
Phase: types.CreateStatusPassed,
Expand Down
7 changes: 7 additions & 0 deletions types/recipe/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ type Apply struct {
// NOTE:
// Presence of Targets implies an update operation
Targets metac.ResourceSelector `json:"targets,omitempty"`

// IgnoreDiscovery if set to true will not retry till
// resource gets discovered
//
// NOTE:
// This is only applicable for kind: CustomResourceDefinition
IgnoreDiscovery bool
}

// String implements the Stringer interface
Expand Down
7 changes: 7 additions & 0 deletions types/recipe/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ type Create struct {

// Desired count that needs to be created
Replicas *int `json:"replicas,omitempty"`

// IgnoreDiscovery if set to true will not retry till
// resource gets discovered
//
// NOTE:
// This is only applicable for kind: CustomResourceDefinition
IgnoreDiscovery bool
}

// String implements the Stringer interface
Expand Down

0 comments on commit f01b6bd

Please sign in to comment.