fix downloadAnalyzerSpec function too
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
+ "github.com/replicatedhq/troubleshoot/cmd/util"
analyzer "github.com/replicatedhq/troubleshoot/pkg/analyze"
"github.com/replicatedhq/troubleshoot/pkg/convert"
"github.com/replicatedhq/troubleshoot/pkg/logger"
@@ -83,7 +84,8 @@ func Analyze() *cobra.Command {
func downloadAnalyzerSpec(specPath string) (string, error) {
specContent := ""
- if !isURL(specPath) {
+ var err error
+ if _, err = os.Stat(specPath); err == nil {
if _, err := os.Stat(specPath); os.IsNotExist(err) {
return "", fmt.Errorf("%s was not found", specPath)
}
@@ -95,6 +97,10 @@ func downloadAnalyzerSpec(specPath string) (string, error) {
specContent = string(b)
} else {
+ if !util.IsURL(specPath) {
+ return "", fmt.Errorf("%s is not a URL and was not found (err %s)", specPath, err)
+ }
+
req, err := http.NewRequest("GET", specPath, nil)
if err != nil {
return "", err
