@@ -11,15 +11,12 @@ import (
1111 "github.com/replicatedhq/embedded-cluster/pkg-new/constants"
1212 "github.com/replicatedhq/embedded-cluster/pkg/helm"
1313 kotsv1beta2 "github.com/replicatedhq/kotskinds/apis/kots/v1beta2"
14+ troubleshootloader "github.com/replicatedhq/troubleshoot/pkg/loader"
1415 kyaml "sigs.k8s.io/yaml"
1516)
1617
1718// TemplateHelmChartCRs templates the HelmChart CRs from release data using the template engine and config values
1819func (m * appReleaseManager ) TemplateHelmChartCRs (ctx context.Context , configValues types.AppConfigValues ) ([]* kotsv1beta2.HelmChart , error ) {
19- if m .releaseData == nil {
20- return nil , fmt .Errorf ("release data not initialized" )
21- }
22-
2320 if m .templateEngine == nil {
2421 return nil , fmt .Errorf ("template engine not initialized" )
2522 }
@@ -72,10 +69,6 @@ func (m *appReleaseManager) DryRunHelmChart(ctx context.Context, templatedCR *ko
7269 return nil , fmt .Errorf ("templated CR is nil" )
7370 }
7471
75- if m .releaseData == nil {
76- return nil , fmt .Errorf ("release data not initialized" )
77- }
78-
7972 // Check if the chart should be excluded
8073 if ! templatedCR .Spec .Exclude .IsEmpty () {
8174 exclude , err := templatedCR .Spec .Exclude .Boolean ()
@@ -181,3 +174,22 @@ func (m *appReleaseManager) GenerateHelmValues(ctx context.Context, templatedCR
181174
182175 return helmValues , nil
183176}
177+
178+ // ExtractTroubleshootKinds extracts troubleshoot specifications from Helm chart manifests
179+ func (m * appReleaseManager ) ExtractTroubleshootKinds (ctx context.Context , manifests [][]byte ) (* troubleshootloader.TroubleshootKinds , error ) {
180+ // Convert [][]byte manifests to []string for troubleshootloader
181+ rawSpecs := make ([]string , len (manifests ))
182+ for i , manifest := range manifests {
183+ rawSpecs [i ] = string (manifest )
184+ }
185+
186+ // Use troubleshootloader to parse all specs
187+ tsKinds , err := troubleshootloader .LoadSpecs (ctx , troubleshootloader.LoadOptions {
188+ RawSpecs : rawSpecs ,
189+ })
190+ if err != nil {
191+ return nil , fmt .Errorf ("load troubleshoot specs: %w" , err )
192+ }
193+
194+ return tsKinds , nil
195+ }
0 commit comments