Skip to content

Commit

Permalink
feat: refactor customAnalyzer package for consistent naming
Browse files Browse the repository at this point in the history
Refactored the customAnalyzer package and its references to use consistent snake_case naming for improved code readability and alignment with Go naming conventions.

Signed-off-by: Matthis Holleville <[email protected]>
  • Loading branch information
matthisholleville committed Aug 5, 2024
1 parent 108424b commit 81ca439
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions cmd/customAnalyzer/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"os"

"github.com/fatih/color"
customanalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/customAnalyzer"
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -39,18 +39,18 @@ var addCmd = &cobra.Command{
color.Red("Error: %v", err)
os.Exit(1)
}
customAnalyzer := customanalyzer.NewCustomAnalyzer()
analyzer := customAnalyzer.NewCustomAnalyzer()

// Check if configuration is valid
err = customAnalyzer.Check(configCustomAnalyzer, name, url, port)
err = analyzer.Check(configCustomAnalyzer, name, url, port)
if err != nil {
color.Red("Error adding custom analyzer: %s", err.Error())
os.Exit(1)
}

configCustomAnalyzer = append(configCustomAnalyzer, customanalyzer.CustomAnalyzerConfiguration{
configCustomAnalyzer = append(configCustomAnalyzer, customAnalyzer.CustomAnalyzerConfiguration{
Name: name,
Connection: customanalyzer.Connection{
Connection: customAnalyzer.Connection{
Url: url,
Port: port,
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/customAnalyzer/customAnalyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ limitations under the License.
package customanalyzer

import (
customanalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/customAnalyzer"
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
)

var configCustomAnalyzer []customanalyzer.CustomAnalyzerConfiguration
var configCustomAnalyzer []customAnalyzer.CustomAnalyzerConfiguration

// authCmd represents the auth command
var CustomAnalyzerCmd = &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions cmd/customAnalyzer/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"os"

"github.com/fatih/color"
customanalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/customAnalyzer"
customAnalyzer "github.com/k8sgpt-ai/k8sgpt/pkg/custom_analyzer"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -53,7 +53,7 @@ func init() {
listCmd.Flags().BoolVar(&details, "details", false, "Print custom analyzers configuration details")
}

func printDetails(analyzer customanalyzer.CustomAnalyzerConfiguration) {
func printDetails(analyzer customAnalyzer.CustomAnalyzerConfiguration) {
fmt.Printf(" - Url: %s\n", analyzer.Connection.Url)
fmt.Printf(" - Port: %d\n", analyzer.Connection.Port)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package customanalyzer
package custom_analyzer

import (
"fmt"
Expand Down Expand Up @@ -28,7 +28,7 @@ func (*CustomAnalyzer) Check(actualConfig []CustomAnalyzerConfiguration, name, u
if !validName.MatchString(name) {
return fmt.Errorf("invalid name format. Must match %s", validNameRegex)
}

for _, analyzer := range actualConfig {
if analyzer.Name == name {
return fmt.Errorf("custom analyzer with the name '%s' already exists. Please use a different name", name)
Expand Down

0 comments on commit 81ca439

Please sign in to comment.