From a0973449635e7dd5c0d66b11dc8247057cfd8f06 Mon Sep 17 00:00:00 2001 From: divolgin Date: Wed, 31 Jul 2019 17:15:25 +0000 Subject: [PATCH] fail with an error if downloaded bundle doesnt have the version file --- cmd/troubleshoot/cli/version.go | 4 ++-- pkg/analyze/download.go | 5 +++++ pkg/apis/troubleshoot/v1beta1/version.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/troubleshoot/cli/version.go b/cmd/troubleshoot/cli/version.go index b9396f6f4..1bd686118 100644 --- a/cmd/troubleshoot/cli/version.go +++ b/cmd/troubleshoot/cli/version.go @@ -9,8 +9,8 @@ import ( func writeVersionFile(path string) (string, error) { version := troubleshootv1beta1.SupportBundleVersion{ - ApiVersion: "troubleshoot.replicated.com/v1beta1", - Kind: "SupportBundle", + ApiVersion: "troubleshoot.replicated.com/v1beta1", + Kind: "SupportBundle", } b, err := yaml.Marshal(version) if err != nil { diff --git a/pkg/analyze/download.go b/pkg/analyze/download.go index 031c9935f..86465b301 100644 --- a/pkg/analyze/download.go +++ b/pkg/analyze/download.go @@ -32,6 +32,11 @@ func DownloadAndAnalyze(ctx context.Context, bundleURL string) ([]*AnalyzeResult return nil, err } + _, err = os.Stat(filepath.Join(tmpDir, "version.yaml")) + if err != nil { + return nil, err + } + analyzers, err := getTroubleshootAnalyzers() if err != nil { return nil, err diff --git a/pkg/apis/troubleshoot/v1beta1/version.go b/pkg/apis/troubleshoot/v1beta1/version.go index 20eab80b3..18d5ec43f 100644 --- a/pkg/apis/troubleshoot/v1beta1/version.go +++ b/pkg/apis/troubleshoot/v1beta1/version.go @@ -1,6 +1,6 @@ package v1beta1 type SupportBundleVersion struct { - ApiVersion string `json:"apiVersion" yaml:"apiVersion"` - Kind string `json:"kind" yaml:"kind"` + ApiVersion string `json:"apiVersion" yaml:"apiVersion"` + Kind string `json:"kind" yaml:"kind"` }