Skip to content

Commit f01b6bd

Browse files
author
Amit Kumar Das
authored
feat(crd): create & apply CRD can ignore discovery if set (#180)
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]>
1 parent ea9dc5d commit f01b6bd

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

pkg/recipe/apply.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,13 @@ func (a *Applyable) createCRD() (*types.ApplyResult, error) {
225225
nil,
226226
)
227227
})
228-
// run an additional step to wait till this CRD
229-
// is discovered at apiserver
230-
err = a.postCreateCRD(crd)
231-
if err != nil {
232-
return nil, err
228+
if !a.Apply.IgnoreDiscovery {
229+
// run an additional step to wait till this CRD
230+
// is discovered at apiserver
231+
err = a.postCreateCRD(crd)
232+
if err != nil {
233+
return nil, err
234+
}
233235
}
234236
return &types.ApplyResult{
235237
Phase: types.ApplyStatusPassed,

pkg/recipe/create.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,13 @@ func (c *Creatable) createCRD() (*types.CreateResult, error) {
248248
nil,
249249
)
250250
})
251-
// run an additional step to wait till this CRD
252-
// is discovered at apiserver
253-
err = c.postCreateCRD(crd)
254-
if err != nil {
255-
return nil, err
251+
if !c.Create.IgnoreDiscovery {
252+
// run an additional step to wait till this CRD
253+
// is discovered at apiserver
254+
err = c.postCreateCRD(crd)
255+
if err != nil {
256+
return nil, err
257+
}
256258
}
257259
return &types.CreateResult{
258260
Phase: types.CreateStatusPassed,

types/recipe/apply.go

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ type Apply struct {
4747
// NOTE:
4848
// Presence of Targets implies an update operation
4949
Targets metac.ResourceSelector `json:"targets,omitempty"`
50+
51+
// IgnoreDiscovery if set to true will not retry till
52+
// resource gets discovered
53+
//
54+
// NOTE:
55+
// This is only applicable for kind: CustomResourceDefinition
56+
IgnoreDiscovery bool
5057
}
5158

5259
// String implements the Stringer interface

types/recipe/create.go

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ type Create struct {
2929

3030
// Desired count that needs to be created
3131
Replicas *int `json:"replicas,omitempty"`
32+
33+
// IgnoreDiscovery if set to true will not retry till
34+
// resource gets discovered
35+
//
36+
// NOTE:
37+
// This is only applicable for kind: CustomResourceDefinition
38+
IgnoreDiscovery bool
3239
}
3340

3441
// String implements the Stringer interface

0 commit comments

Comments
 (0)