Skip to content

Commit

Permalink
remove raw crds from additiona crd charts
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmeranda committed May 7, 2024
1 parent 09bb44f commit e10ecda
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pkg/charts/additionalchart.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,27 @@ func (c *AdditionalChart) ApplyMainChanges(pkgFs billy.Filesystem) error {
if err != nil {
return fmt.Errorf("encountered error while trying to get the main chart's working directory: %s", err)
}
if c.CRDChartOptions.UseTarArchive {
if err := helm.ArchiveCRDs(pkgFs, mainChartWorkingDir, path.ChartCRDDir, c.WorkingDir, path.ChartExtraFileDir); err != nil {
return fmt.Errorf("encountered error while trying to bundle and compress CRD files from the main chart: %s", err)
}
}
if err := helm.CopyCRDsFromChart(pkgFs, mainChartWorkingDir, path.ChartCRDDir, c.WorkingDir, c.CRDChartOptions.CRDDirectory); err != nil {
return fmt.Errorf("encountered error while trying to copy CRDs from %s to %s: %s", mainChartWorkingDir, c.WorkingDir, err)
}
if err := helm.DeleteCRDsFromChart(pkgFs, mainChartWorkingDir); err != nil {
return fmt.Errorf("encountered error while trying to delete CRDs from main chart: %s", err)
}
if c.CRDChartOptions.AddCRDValidationToMainChart {
if err := AddCRDValidationToChart(pkgFs, mainChartWorkingDir, c.WorkingDir, c.CRDChartOptions.CRDDirectory); err != nil {
return fmt.Errorf("encountered error while trying to add CRD validation to %s based on CRDs in %s: %s", mainChartWorkingDir, c.WorkingDir, err)
}
}
if c.CRDChartOptions.UseTarArchive {
if err := helm.ArchiveCRDs(pkgFs, mainChartWorkingDir, path.ChartCRDDir, c.WorkingDir, path.ChartExtraFileDir); err != nil {
return fmt.Errorf("encountered error while trying to bundle and compress CRD files from the main chart: %s", err)
}

if err := helm.DeleteCRDsFromChart(pkgFs, c.WorkingDir); err != nil {
return fmt.Errorf("encountered error while trying to delete CRDs from crd chart: %s", err)
}
}
if err := helm.DeleteCRDsFromChart(pkgFs, mainChartWorkingDir); err != nil {
return fmt.Errorf("encountered error while trying to delete CRDs from main chart: %s", err)
}

return nil
}

Expand All @@ -82,6 +87,11 @@ func (c *AdditionalChart) RevertMainChanges(pkgFs billy.Filesystem) error {
if err != nil {
return fmt.Errorf("encountered error while trying to get the main chart's working directory: %s", err)
}
if c.CRDChartOptions.UseTarArchive {
if err := filesystem.UnarchiveTgz(pkgFs, filepath.Join(c.WorkingDir, path.ChartExtraFileDir, path.ChartCRDTgzFilename), "", filepath.Join(c.WorkingDir, c.CRDChartOptions.CRDDirectory), false); err != nil {
return fmt.Errorf("encountered error while trying to unarchive CRD files from %s: %s", filepath.Join(c.WorkingDir, path.ChartExtraFileDir, path.ChartCRDTgzFilename), err)
}
}
// copy CRD files from packages/<package>/charts-crd/crd-manifest/ back to packages/<package>/charts/crds/
if err := helm.CopyCRDsFromChart(pkgFs, c.WorkingDir, c.CRDChartOptions.CRDDirectory, mainChartWorkingDir, path.ChartCRDDir); err != nil {
return fmt.Errorf("encountered error while trying to copy CRDs from %s to %s: %s", c.WorkingDir, mainChartWorkingDir, err)
Expand Down

0 comments on commit e10ecda

Please sign in to comment.