Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Fixed postinstall for empty prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasdille committed Jun 15, 2023
1 parent ba159c6 commit 2aa3d58
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/docker-setup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,26 @@ func main() {
log.SetLevel(level)
log.Debugf("Log level is now %s\n", logLevel)

re, err := regexp.Compile(`^\/`)
if err != nil {
return fmt.Errorf("cannot compile regexp: %w", err)
}
if !re.MatchString(prefix) {
wd, err := os.Getwd()
if len(prefix) > 0 {
re, err := regexp.Compile(`^\/`)
if err != nil {
return fmt.Errorf("cannot determine working directory: %w", err)
return fmt.Errorf("cannot compile regexp: %w", err)
}
if !re.MatchString(prefix) {
wd, err := os.Getwd()
if err != nil {
return fmt.Errorf("cannot determine working directory: %w", err)
}
prefix = wd + "/" + prefix
log.Debugf("Convered prefix to absolute path %s\n", prefix)
}
prefix = wd + "/" + prefix
log.Debugf("Convered prefix to absolute path %s\n", prefix)
}

return nil
}
rootCmd.PersistentFlags().StringVarP(&logLevel, "log-level", "l", log.WarnLevel.String(), "Log level (trace, debug, info, warning, error)")
// TODO: Add flags --trace and --debug (make mutually exclusive)
rootCmd.PersistentFlags().StringVarP(&prefix, "prefix", "p", "/", "Prefix for installation")
rootCmd.PersistentFlags().StringVarP(&prefix, "prefix", "p", "", "Prefix for installation")
rootCmd.PersistentFlags().StringVarP(&target, "target", "t", "usr/local", "Target directory for installation")
rootCmd.PersistentFlags().StringVarP(&cacheDirectory, "cache-directory", "C", "var/cache/docker-setup", "Cache directory relative to PREFIX")
rootCmd.PersistentFlags().StringVarP(&libDirectory, "lib-directory", "L", "var/lib/docker-setup", "Library directory relative to PREFIX")
Expand Down

0 comments on commit 2aa3d58

Please sign in to comment.