Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete temporary files generated by controller-gen #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/controller-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,18 @@ func copyGoPathToModules(customArgs *cgargs.CustomArgs) error {
continue
}

return filepath.Walk(pkg, func(path string, info os.FileInfo, err error) error {
if err := filepath.Walk(pkg, func(path string, info os.FileInfo, err error) error {
newPath := strings.Replace(path, pkg, ".", 1)
if info.IsDir() {
return os.MkdirAll(newPath, info.Mode())
}

return copyFile(path, newPath)
})
}); err != nil {
return err
}

return deleteFile(pkg)
}

return nil
Expand Down Expand Up @@ -180,6 +184,10 @@ func copyFile(src, dst string) error {
return os.Chmod(dst, srcinfo.Mode())
}

func deleteFile(path string) error {
return os.RemoveAll(path)
}

func generateDeepcopy(groups map[string]bool, customArgs *cgargs.CustomArgs) error {
if len(groups) == 0 {
return nil
Expand Down