From 2491526d06b095e5f903fa8539da45afcb74bb83 Mon Sep 17 00:00:00 2001 From: Jeff MAURY Date: Thu, 16 Nov 2023 17:04:57 +0100 Subject: [PATCH] fix: replace Dockerfile by Containerfile Fixes #5 Signed-off-by: Jeff MAURY --- pkg/cli/analyze.go | 10 +++++----- pkg/cli/cli.go | 6 +++--- pkg/command/analyzer.go | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/cli/analyze.go b/pkg/cli/analyze.go index ba85932..e81acd6 100644 --- a/pkg/cli/analyze.go +++ b/pkg/cli/analyze.go @@ -12,11 +12,11 @@ import ( func NewCmdAnalyze() *cobra.Command { analyzeCmd := &cobra.Command{ Use: "analyze", - Short: "Analyze the Dockerfile and discover potential issues when deploying it on OpenShift", - Long: "Analyze the Dockerfile and discover potential issues when deploying it on OpenShift. It accepts the project root path or the Dockerfile path.", + Short: "Analyze the Containerfile and discover potential issues when deploying it on OpenShift", + Long: "Analyze the Containerfile and discover potential issues when deploying it on OpenShift. It accepts the project root path or the Containerfile path.", Args: cobra.MaximumNArgs(0), Run: doAnalyze, - Example: ` doa analyze -f /your/local/project/path[/Dockerfile_name]`, + Example: ` doa analyze -f /your/local/project/path[/Containerfile_name]`, } analyzeCmd.PersistentFlags().StringP( "file", "f", "", "Container file to analyze", @@ -55,10 +55,10 @@ func doAnalyze(cmd *cobra.Command, args []string) { func PrintNoArgsWarningMessage(command string) { fmt.Printf(` -No arg received. Did you forget to add the dockerfile or project path to analyze? +No arg received. Did you forget to add the Containerfile or project path to analyze? Expected: - doa %s /your/local/project/path[/Dockerfile_name] [flags] + doa %s /your/local/project/path[/Containerfile_name] [flags] To find out more, run 'doa %s --help' `, command, command) diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 9c8f92e..74b7d97 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -10,13 +10,13 @@ import ( var ( doaLong = ` -The Docker OpenShift Analyzer is a CLI tool for finding and highlighting potential issues a Dockerfile could have on an OpenShift cluster. +The Docker OpenShift Analyzer is a CLI tool for finding and highlighting potential issues a Containerfile could have on an OpenShift cluster. Find out more at https://github.com/lstocchi/docker-openshift-analyzer ` doaExample = ` - # Analyze the Dockerfile of a project: - doa analyze /your/local/project/path[/Dockerfile_name] + # Analyze the Containerfile of a project: + doa analyze /your/local/project/path[/Containerfile_name] ` rootHelpMessage = "To see a full list of commands, run 'doa --help'" diff --git a/pkg/command/analyzer.go b/pkg/command/analyzer.go index 167b6ea..5e7f772 100644 --- a/pkg/command/analyzer.go +++ b/pkg/command/analyzer.go @@ -44,6 +44,9 @@ func AnalyzePath(path string) []error { if fileInfo.IsDir() { path = filepath.Join(path, "Dockerfile") + if _, err := os.Stat(path); err != nil { + path = filepath.Join(filepath.Base(path), "Containerfile") + } } file, err := os.Open(path) @@ -70,7 +73,7 @@ func AnalyzeFile(file *os.File) []error { res, err := parser.Parse(file) if err != nil { return []error{ - fmt.Errorf("unable to analyze the Dockerfile. Error when parsing %s : %s", file.Name(), err.Error()), + fmt.Errorf("unable to analyze the Containerfile. Error when parsing %s : %s", file.Name(), err.Error()), } }