Skip to content

Commit

Permalink
new func to find file location
Browse files Browse the repository at this point in the history
  • Loading branch information
framsouza committed Jul 27, 2022
1 parent 502131b commit 90c16eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions pkg/handlingfiles/handlingfiles.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package findfile

import (
"log"
"os"
"path/filepath"
"regexp"
)

var (
Expand All @@ -14,6 +16,7 @@ var (
absPathDeploy []string
absPathService []string
absPathEndpoint []string
DeployPath []string
)

func FindFileAbsPathPods(d, filename string) ([]string, error) {
Expand Down Expand Up @@ -176,7 +179,7 @@ func FindFileAbsPathSTS(d, filename string) ([]string, error) {
return absPathSTS, nil
}

/* TRY TO MAKE IT WORK AS A GLOBAL FUNC FOR ALL THE FILES
// TRY TO MAKE IT WORK AS A GLOBAL FUNC FOR ALL THE FILES
func FindFile(filename, d string) []string {
filepath.Walk(d, func(path string, f os.FileInfo, _ error) error {
if !f.IsDir() {
Expand All @@ -187,15 +190,13 @@ func FindFile(filename, d string) []string {
log.Fatal(err)
}

files = append(files, absolutefilepath)
DeployPath = append(DeployPath, absolutefilepath)

}

}
return nil
})
return files
return DeployPath

}
*/
9 changes: 6 additions & 3 deletions pkg/resources/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (

func Deployment() {
w := new(tabwriter.Writer)
w.Init(os.Stdout, 8, 8, 0, '\t', 0)
w.Init(os.Stdout, 10, 10, 0, ' ', 0)
defer w.Flush()

abspath, _ := handlingfiles.FindFileAbsPathDeploy(extract.Destination, "deployments.json")
//abspath, _ := handlingfiles.FindFileAbsPathDeploy(extract.Destination, "deployments.json")
deploypath := handlingfiles.FindFile("deployments.json", extract.Destination)

for _, f := range abspath {
//for _, f := range abspath {

for _, f := range deploypath {
if f == extract.Destination+"/kube-system/deployments.json" {
break
}
Expand Down

0 comments on commit 90c16eb

Please sign in to comment.