Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
elek committed Mar 4, 2021
1 parent 22ae444 commit dc36abc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions api/v2/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
skip-dirs: yaml
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ func appCommands(inputDir *string, outputDir *string) cli.Command {
ArgsUsage: "[flekszible_dir]",
Action: func(c *cli.Context) error {
context := processor.CreateRenderContext("k8s", findInputDir(inputDir, c.Args().Get(0)), findOutputDir(outputDir, c.Args().Get(0)))
pkg.SearchComponent(context)
return nil
return pkg.SearchComponent(context)

},
},
{
Expand Down Expand Up @@ -330,7 +330,6 @@ func findInputDir(argument *string, inputDirFromArg string) string {
}
return workDir
}
return *argument
}

return pwd
Expand Down
21 changes: 11 additions & 10 deletions pkg/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,32 +303,36 @@ func ListSources(context *processor.RenderContext) {
fmt.Println(table.Render())
}

func SearchComponent(context *processor.RenderContext) {
func SearchComponent(context *processor.RenderContext) error {
err := context.Init()
if err != nil {
panic(err)
return err
}

table := termtables.CreateTable()
table.AddHeaders("path", "description")
cacheManager := data.NewSourceCacheManager(context.RootResource.Dir)
for _, source := range listUniqSources(context, &cacheManager) {
findApps(source, &cacheManager, table)
err = findApps(source, &cacheManager, table)
if err != nil {
return err
}

}
fmt.Println(table.Render())
return nil
}

func findApps(source data.Source, manager *data.SourceCacheManager, table *termtables.Table) {
func findApps(source data.Source, manager *data.SourceCacheManager, table *termtables.Table) error {

dir, err := source.GetPath(manager)
if dir == "" {
return
return nil
}
if err != nil {
logrus.Error("Can't find real path of the source")
}
err = filepath.Walk(dir, func(filePath string, info os.FileInfo, err error) error {
return filepath.Walk(dir, func(filePath string, info os.FileInfo, err error) error {
if err != nil {
return err
}
Expand All @@ -353,12 +357,9 @@ func findApps(source data.Source, manager *data.SourceCacheManager, table *termt
if err != nil {
logrus.Error("Can't parse flekszible.yaml from " + filePath + " " + err.Error())
}
if strings.HasPrefix(relpath, "flekszible/") {
relpath = relpath[len("flekszible/"):]
}
if declaredName, found := fleksz["description"]; found {
name = declaredName.(string)
table.AddRow(relpath, name)
table.AddRow(strings.TrimPrefix(relpath, "flekszible/"), name)
}
}

Expand Down

0 comments on commit dc36abc

Please sign in to comment.