CRDObjects returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts
()
| 161 | |
| 162 | // CRDObjects returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts |
| 163 | func (ch *Chart) CRDObjects() []CRD { |
| 164 | crds := []CRD{} |
| 165 | // Find all resources in the crds/ directory |
| 166 | for _, f := range ch.Files { |
| 167 | if strings.HasPrefix(f.Name, "crds/") && hasManifestExtension(f.Name) { |
| 168 | mycrd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f} |
| 169 | crds = append(crds, mycrd) |
| 170 | } |
| 171 | } |
| 172 | // Get CRDs from dependencies, too. |
| 173 | for _, dep := range ch.Dependencies() { |
| 174 | crds = append(crds, dep.CRDObjects()...) |
| 175 | } |
| 176 | return crds |
| 177 | } |
| 178 | |
| 179 | func hasManifestExtension(fname string) bool { |
| 180 | ext := filepath.Ext(fname) |