func TestCompileBinary(t *testing.T) { scriptFilename := "output.go" binaryFilename := "TestCompileBinary_output" if Exist(binaryFilename) { removeFile(t, binaryFilename) } scriptPath, err := filepath.Abs(scriptFilename) if err != nil { t.Fatal(err) } binaryPath, err := filepath.Abs(binaryFilename) if err != nil { t.Fatal(err) } CompileBinary(scriptPath, binaryPath, false) if !Exist(binaryFilename) { t.Fatalf("Compiled binary does not exist: [%s]", binaryFilename) } defer removeFile(t, binaryFilename) out, err := exec.Command("./" + binaryFilename).Output() if err != nil { t.Fatal(err) } expected(t, binaryFilename, string(out), "The night is all magic\n") }
// doCmd executes the given command line string in either the out/Debug // directory or the inout directory. Returns the stdout and stderr. func doCmd(commandLine string, moveToDebug bool) (string, error) { log.Printf("Command: %q\n", commandLine) programAndArgs := strings.SplitN(commandLine, " ", 2) program := programAndArgs[0] args := []string{} if len(programAndArgs) > 1 { args = strings.Split(programAndArgs[1], " ") } cmd := exec.Command(program, args...) abs, err := filepath.Abs("../../out/Debug") if err != nil { return "", fmt.Errorf("Failed to find absolute path to Debug directory.") } if moveToDebug { cmd.Dir = abs } else if !*useChroot { // Don't set cmd.Dir when using chroot. abs, err := filepath.Abs("../../../inout") if err != nil { return "", fmt.Errorf("Failed to find absolute path to inout directory.") } cmd.Dir = abs } log.Printf("Run in directory: %q\n", cmd.Dir) message, err := cmd.CombinedOutput() log.Printf("StdOut + StdErr: %s\n", string(message)) if err != nil { log.Printf("Exit status: %s\n", err.Error()) return string(message), fmt.Errorf("Failed to run command.") } return string(message), nil }
func (this *fileWriterTester) checkRequiredFilesExist(testCase *fileWriterTestCase, files []string) { var found bool for _, expected := range testCase.resFiles { found = false exAbs, err := filepath.Abs(expected) if err != nil { this.t.Errorf("filepath.Abs failed for %s", expected) continue } for _, f := range files { if af, e := filepath.Abs(f); e == nil { this.t.Log(af) if exAbs == af { found = true break } } else { this.t.Errorf("filepath.Abs failed for %s", f) } } if !found { this.t.Errorf("Expected file: %s doesn't exist. Got %v\n", exAbs, files) } } }
func NewPod(path string, args BuildArgs) (*Pod, error) { fullPath, err := filepath.Abs(path) if err != nil { logs.WithE(err).WithField("path", path).Fatal("Cannot get fullpath") } manifest, err := readPodManifest(fullPath + POD_MANIFEST) if err != nil { return nil, errors.Annotate(err, "Failed to read pod manifest") } fields := data.WithField("pod", manifest.Name.String()) target := path + PATH_TARGET if cnt.Home.Config.TargetWorkDir != "" { currentAbsDir, err := filepath.Abs(cnt.Home.Config.TargetWorkDir + "/" + manifest.Name.ShortName()) if err != nil { logs.WithEF(err, fields).Panic("invalid target path") } target = currentAbsDir } pod := &Pod{ fields: fields, path: fullPath, args: args, target: target, manifest: *manifest, } return pod, nil }
func TestEnvOverride(t *testing.T) { cgifile, _ := filepath.Abs("testdata/test.cgi") var perl string var err error perl, err = exec.LookPath("perl") if err != nil { return } perl, _ = filepath.Abs(perl) cwd, _ := os.Getwd() h := &Handler{ Path: perl, Root: "/test.cgi", Dir: cwd, Args: []string{cgifile}, Env: []string{ "SCRIPT_FILENAME=" + cgifile, "REQUEST_URI=/foo/bar"}, } expectedMap := map[string]string{ "cwd": cwd, "env-SCRIPT_FILENAME": cgifile, "env-REQUEST_URI": "/foo/bar", } runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) }
func (f *Fs) filterPath(s string) string { s = filepath.Clean(s) if runtime.GOOS == "windows" { s = strings.Replace(s, `/`, `\`, -1) if !filepath.IsAbs(s) && !strings.HasPrefix(s, "\\") { s2, err := filepath.Abs(s) if err == nil { s = s2 } } if f.nounc { return s } // Convert to UNC return uncPath(s) } if !filepath.IsAbs(s) { s2, err := filepath.Abs(s) if err == nil { s = s2 } } return s }
func LoadConfigure() *Configure { dir := "conf" absDir := "." if _, err := os.Stat("../" + dir + "/"); err == nil { absDir, _ = filepath.Abs("../" + dir + "/") } else if _, err := os.Stat("../../" + dir + "/"); err == nil { absDir, _ = filepath.Abs("../../" + dir + "/") } else { absDir = binDir() + "/../" + dir } var file = absDir + "/../conf/server.cfg" var default_file = absDir + "/../conf/server_default.cfg" if _, err := os.Stat(file); err != nil { file = default_file } var config = Configure{} if _, err := toml.DecodeFile(file, &config); err != nil { panic(err) } fmt.Print(config) return &config }
// pkgFromDir extracts package import path from dir. dir can be a path on file system // or go get path. func pkgFromDir(dir string) string { gopaths := strings.Split(os.Getenv("GOPATH"), string(filepath.ListSeparator)) // if directory exits, infer import path from dir relative to GOPATH. if stat, err := os.Stat(dir); err == nil && stat.IsDir() { for _, gopath := range gopaths { absgopath, _ := filepath.Abs(gopath) gosrc := filepath.Join(absgopath, "src") + string(filepath.Separator) absdir, _ := filepath.Abs(dir) if strings.HasPrefix(absdir, gosrc) { return strings.TrimPrefix(absdir, gosrc) } } // not in GOPATH, create symlink to fake GOPATH. if newpath, err := symlinkGOPATH(dir); err == nil { return filepath.Base(newpath) } } if isLocalPkg(dir) { return dir } return "" }
func testFile(t *testing.T, filename string) { path, _ := filepath.Abs("./tests/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) if err != nil { t.Error("Could not load "+filename+".json", err) } // Create a new container vi := &VersionInfo{} // Parse the config if err := vi.ParseJSON(jsonBytes); err != nil { t.Error("Could not parse "+filename+".json", err) } // Fill the structures with config data vi.Build() // Write the data to a buffer vi.Walk() path2, _ := filepath.Abs("./tests/" + filename + ".hex") expected, err := ioutil.ReadFile(path2) if err != nil { t.Error("Could not load "+filename+".hex", err) } if !bytes.Equal(vi.Buffer.Bytes(), expected) { t.Error("Data does not match " + filename + ".hex") } }
// guessImportPath finds the package containing filename, and returns // its source directory (an element of $GOPATH) and its import path // relative to it. // // TODO(adonovan): what about _test.go files that are not part of the // package? // func guessImportPath(filename string, buildContext *build.Context) (srcdir, importPath string, err error) { absFile, err := filepath.Abs(filename) if err != nil { err = fmt.Errorf("can't form absolute path of %s", filename) return } absFileDir := segments(filepath.Dir(absFile)) // Find the innermost directory in $GOPATH that encloses filename. minD := 1024 for _, gopathDir := range buildContext.SrcDirs() { absDir, err := filepath.Abs(gopathDir) if err != nil { continue // e.g. non-existent dir on $GOPATH } d := prefixLen(segments(absDir), absFileDir) // If there are multiple matches, // prefer the innermost enclosing directory // (smallest d). if d >= 0 && d < minD { minD = d srcdir = gopathDir importPath = strings.Join(absFileDir[len(absFileDir)-minD:], string(os.PathSeparator)) } } if srcdir == "" { err = fmt.Errorf("can't find package for file %s", filename) } return }
// cleanAssetName returns an asset name from the parent dirname and // the file name without extension. // The combination // path=/tmp/css/default.css // basePath=/tmp/ // prependPath=new/ // will return // new/css/default func cleanAssetName(path, basePath, prependPath string) string { var name string path, basePath, prependPath = strings.TrimSpace(path), strings.TrimSpace(basePath), strings.TrimSpace(prependPath) basePath, err := filepath.Abs(basePath) if err != nil { basePath = "" } apath, err := filepath.Abs(path) if err == nil { path = apath } if basePath == "" { idx := strings.LastIndex(path, string(os.PathSeparator)) if idx != -1 { idx = strings.LastIndex(path[:idx], string(os.PathSeparator)) } name = path[idx+1:] } else { // Directory name = strings.Replace(path, basePath, "", 1) if name[0] == os.PathSeparator { name = name[1:] } } if prependPath != "" { if prependPath[0] == os.PathSeparator { prependPath = prependPath[1:] } prependPath = EnsureTrailingSlash(prependPath) } return prependPath + name[:len(name)-len(filepath.Ext(name))] }
func main() { if flag.NArg() == 0 { fmt.Printf("[Error] path or file must provide one.\n\n") flag.Usage() os.Exit(retFail) } for i := 0; i < flag.NArg(); i++ { path := strings.TrimSpace(flag.Arg(i)) switch dir, err := os.Stat(path); { case err != nil: //fmt.Printf("[Error] error in Stat(): %s.\n", err) panic(err) case dir.IsDir(): if path, err = filepath.Abs(path); err != nil { panic(err) } dealDirWithWhiteList(path, cmd, suffixArray) default: if path, err = filepath.Abs(path); err != nil { panic(err) } dealFileWithWhiteList(path, cmd, suffixArray) } } }
// LoadSync loads the sync based on the settings found in localPath func LoadSync(localPath string) (*SyncInfo, error) { // Only open pre-existing syncs. sql.Open would indiscrimately create an // empty database if we didn't check this in advance dbPath := filepath.Join(localPath, settingsDir, dbFileName) if _, err := os.Stat(dbPath); os.IsNotExist(err) { return nil, &ErrSync{fmt.Sprintf("'%v' does not appear to be a valid sync: no settings directory found", localPath), err} } db, err := sql.Open("sqlite3", dbPath) if err != nil { return nil, err } // Load remainder of settings sync := new(SyncInfo) sync.db = db sync.changesReady = make(chan bool) if sync.localBase, err = filepath.Abs(localPath); err != nil { return nil, &ErrSync{"Unable to get absolute local path", err} } if sync.remoteBase, err = sync.Get(remotePathKey); err != nil { return nil, &ErrSync{"Remote path not set", err} } if sync.remoteBase, err = filepath.Abs(filepath.FromSlash(sync.remoteBase)); err != nil { return nil, &ErrSync{"Unable to get absolute remote path", err} } cKeyStr, err := sync.Get(cryptoKeyKey) if err != nil { return nil, &ErrSync{"Encryption key not set", err} } aKeyStr, err := sync.Get(authKeyKey) if err != nil { return nil, &ErrSync{"Authentication key not set", err} } cKey, err := gocrypt.KeyFromString(cKeyStr) if err != nil { return nil, &ErrSync{"Failed to convert encryption key", err} } aKey, err := gocrypt.KeyFromString(aKeyStr) if err != nil { return nil, &ErrSync{"Failed to convert authentication key", err} } sync.keys = &gocrypt.KeyCombo{CryptoKey: cKey, AuthKey: aKey} // Make sure everything loaded correctly if err = sync.sanityCheckConfig(); err != nil { return nil, err } log.Println("Cleaning sync") sync.Clean() return sync, nil }
func TestCompleteBuild(t *testing.T) { scriptFilename := "build/builder.go" binaryFilename := "build/TestCompleteBuildBinary_builder" if Exist(binaryFilename) { removeFile(t, binaryFilename) } out, err := exec.Command("./" + scriptFilename).Output() if err != nil { t.Fatal(err) } expected(t, "build/builder.go", string(out), "Build!\n") scriptPath, err := filepath.Abs(scriptFilename) if err != nil { t.Fatal(err) } binaryPath, err := filepath.Abs(binaryFilename) if err != nil { t.Fatal(err) } CompileBinary(scriptPath, binaryPath, true) if !Exist(binaryFilename) { t.Fatalf("Compiled binary does not exist: [%s]", binaryFilename) } defer removeFile(t, binaryFilename) out, err = exec.Command("./" + binaryFilename).Output() if err != nil { t.Fatal(err) } expected(t, "build/builder.go", string(out), "Build!\n") }
func TestNewStaticPageHandler(t *testing.T) { defPagePath, _ := filepath.Abs("haproxy.cfg") defErrorPath, _ := filepath.Abs("template.cfg") defErrURL := "http://www.k8s.io" testDefPage := "file://" + defPagePath testErrorPage := "file://" + defErrorPath handler := newStaticPageHandler("", testDefPage) if handler == nil { t.Fatalf("Expected page handler") } handler = newStaticPageHandler(testErrorPage, testDefPage) if handler.pagePath != testErrorPage { t.Fatalf("Expected local file content but got default page") } handler = newStaticPageHandler(defErrURL, testDefPage) if handler.pagePath != defErrURL { t.Fatalf("Expected remote error page content but got default page") } handler = newStaticPageHandler(defErrURL+"s", testDefPage) if handler.pagePath != testDefPage { t.Fatalf("Expected local file content with not valid URL") } }
func GitAndRootDirs() (string, string, error) { cmd := execCommand("git", "rev-parse", "--git-dir", "--show-toplevel") buf := &bytes.Buffer{} cmd.Stderr = buf out, err := cmd.Output() output := string(out) if err != nil { return "", "", fmt.Errorf("Failed to call git rev-parse --git-dir --show-toplevel: %q", buf.String()) } paths := strings.Split(output, "\n") pathLen := len(paths) if pathLen == 0 { return "", "", fmt.Errorf("Bad git rev-parse output: %q", output) } absGitDir, err := filepath.Abs(paths[0]) if err != nil { return "", "", fmt.Errorf("Error converting %q to absolute: %s", paths[0], err) } if pathLen == 1 || len(paths[1]) == 0 { return absGitDir, "", nil } absRootDir, err := filepath.Abs(paths[1]) if err != nil { return "", "", fmt.Errorf("Error converting %q to absolute: %s", paths[1], err) } return absGitDir, absRootDir, nil }
func RelTo(path, to string) string { var err error path, err = filepath.Abs(path) if err != nil { panic("could not get absolute path") } to, err = filepath.Abs(to) if err != nil { panic("could not get absolute path") } if path == to { return "." } prefix := trailingSeparator(to) if strings.HasPrefix(path, prefix) { // can't use filepath.Join as it strips the leading './' return "." + string(filepath.Separator) + path[len(prefix):] } to = filepath.Dir(to) prefix = trailingSeparator(to) if strings.HasPrefix(path, prefix) { // can't use filepath.Join as it strips the leading './' return ".." + string(filepath.Separator) + path[len(prefix):] } return path }
func (c *Conf) include(parentConfPath string) { includeFileNames := c.getIncludeFileNames() for _, includeFileName := range includeFileNames { if !filepath.IsAbs(includeFileName) { confPath := func() string { parentConfPath, err := filepath.Abs(parentConfPath) if err != nil { return "" } splitPath := strings.Split(parentConfPath, "/") return "/" + strings.Join(splitPath[:len(splitPath)-1], "/") }() var err error includeFileName, err = filepath.Abs(confPath + "/" + includeFileName) if err != nil { continue } } var err error c.loopDetector, err = loopDetection(includeFileName, c.loopDetector) if err != nil { return } childConf := NewConf(includeFileName) if childConf == nil { continue } childKeys := childConf.GetKeys() for _, childKey := range childKeys { c.Set(childKey, childConf.Get(childKey)) } } }
func (context *ExecutionContext) FetchInputDocument(loc string, relativeToSource bool) (doc *xml.XmlDocument) { //create the map if needed if context.InputDocuments == nil { context.InputDocuments = make(map[string]*xml.XmlDocument) } // rely on caller to tell us how to resolve relative paths base := "" if relativeToSource { base, _ = filepath.Abs(filepath.Dir(context.Source.Uri())) } else { base, _ = filepath.Abs(filepath.Dir(context.Style.Doc.Uri())) } resolvedLoc := filepath.Join(base, loc) //if abspath in map return existing document doc, ok := context.InputDocuments[resolvedLoc] if ok { return } //else load the document and add to map doc, e := xml.ReadFile(resolvedLoc, xml.StrictParseOption) if e != nil { fmt.Println(e) return } context.InputDocuments[resolvedLoc] = doc return }
func getK8sBin(bin string) (string, error) { // Use commandline specified path if *k8sBinDir != "" { absPath, err := filepath.Abs(*k8sBinDir) if err != nil { return "", err } if _, err := os.Stat(filepath.Join(*k8sBinDir, bin)); err != nil { return "", fmt.Errorf("Could not find kube-apiserver under directory %s.", absPath) } return filepath.Join(absPath, bin), nil } path, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { return "", fmt.Errorf("Could not find absolute path of directory containing the tests %s.", filepath.Dir(os.Args[0])) } if _, err := os.Stat(filepath.Join(path, bin)); err == nil { return filepath.Join(path, bin), nil } buildOutputDir, err := getK8sBuildOutputDir() if err != nil { return "", err } if _, err := os.Stat(filepath.Join(buildOutputDir, bin)); err == nil { return filepath.Join(buildOutputDir, bin), nil } // Give up with error return "", fmt.Errorf("Unable to locate %s. Can be defined using --k8s-path.", bin) }
// PackageName determines the package name from sourceFile if it is within $GOPATH func PackageName(sourceFile string) (string, error) { if filepath.Ext(sourceFile) != ".go" { return "", errors.New("sourcefile must end with .go") } sourceFile, err := filepath.Abs(sourceFile) if err != nil { Panic("util", "Could not convert to absolute path: %s", sourceFile) } gopath := os.Getenv("GOPATH") if gopath == "" { return "", errors.New("Environment variable GOPATH is not set") } paths := strings.Split(gopath, string(os.PathListSeparator)) for _, path := range paths { srcDir := filepath.Join(path, "src") srcDir, err := filepath.Abs(srcDir) if err != nil { continue } //log.Printf("srcDir %s sourceFile %s\n", srcDir, sourceFile) rel, err := filepath.Rel(srcDir, sourceFile) if err != nil { continue } return filepath.Dir(rel), nil } return "", errors.New("sourceFile not reachable from GOPATH") }
func TestJoinChart(t *testing.T) { chartDir, _ := filepath.Abs("../testdata/charts/redis") // prepare files fixture var files []string paths := []string{ "../testdata/charts/redis/Chart.yaml", "../testdata/charts/redis/manifests/redis-pod.yaml", } for _, f := range paths { abspath, _ := filepath.Abs(f) files = append(files, abspath) } bytes, err := joinChart(chartDir, files) if err != nil { t.Fatalf("failed to join chart: %v", bytes) } if bytes.Len() < 1 { t.Fatalf("empty chart after join: %v", bytes) } }
func initBitriseWorkPaths() error { bitriseWorkDirPath, err := filepath.Abs("./.bitrise") if err != nil { return err } if exist, err := pathutil.IsPathExists(bitriseWorkDirPath); err != nil { return err } else if !exist { if err := os.MkdirAll(bitriseWorkDirPath, 0777); err != nil { return err } } BitriseWorkDirPath = bitriseWorkDirPath bitriseWorkStepsDirPath, err := filepath.Abs(path.Join(BitriseWorkDirPath, "step_src")) if err != nil { return err } if exist, err := pathutil.IsPathExists(bitriseWorkStepsDirPath); err != nil { return err } else if !exist { if err := os.MkdirAll(bitriseWorkStepsDirPath, 0777); err != nil { return err } } BitriseWorkStepsDirPath = bitriseWorkStepsDirPath return nil }
func (self *Phantom) setFile(js string) (string, error) { self.Mutex.Lock() defer self.Mutex.Unlock() jshash := util.MakeHash(js) fullFileName := self.FullTempJsFilePrefix + jshash if self.FullTempJsFiles[fullFileName] { return fullFileName, nil } if !filepath.IsAbs(fullFileName) { fullFileName, _ = filepath.Abs(fullFileName) } if !filepath.IsAbs(self.FullPhantomjsName) { self.FullPhantomjsName, _ = filepath.Abs(self.FullPhantomjsName) } // 创建/打开目录 p, _ := filepath.Split(fullFileName) d, err := os.Stat(p) if err != nil || !d.IsDir() { if err := os.MkdirAll(p, 0777); err != nil { return "", err } } // 创建并写入文件 f, _ := os.Create(fullFileName) f.Write([]byte(js)) f.Close() self.FullTempJsFiles[fullFileName] = true return fullFileName, nil }
func main() { defer panicHandler() app.Version(Version) kingpin.MustParse(app.Parse(os.Args[1:])) inputPath, _ := filepath.Abs((*inputFile).Name()) if *outputPath != "" { *outputPath, _ = filepath.Abs(*outputPath) } outputPackageName := determineOutputPackageName() config := NewConfig(outputPackageName, *functionName, inputPath, *outputPath) gen := New(config) output := &bytes.Buffer{} if *verbose { gen.Debug = true } logVerboseGeneratorConfig(inputPath, outputPackageName) err := gen.Generate(*inputFile, output) if err != nil { log(err.Error()) os.Exit(1) } if *outputPath == "" || *forceStdOut { logVerbose("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") fmt.Println(output.String()) return } writeOutputFile(output) }
// appendShardSnapshotFiles adds snapshot files for each shard in the store. func appendShardSnapshotFiles(sw *snapshot.Writer, store *Store) error { // Calculate absolute path of store to use for relative shard paths. storePath, err := filepath.Abs(store.Path()) if err != nil { return fmt.Errorf("store abs path: %s", err) } // Create files for each shard. for _, shardID := range store.ShardIDs() { // Retrieve shard. sh := store.Shard(shardID) if sh == nil { return fmt.Errorf("shard not found: %d", shardID) } // Calculate relative path from store. shardPath, err := filepath.Abs(sh.Path()) if err != nil { return fmt.Errorf("shard abs path: %s", err) } name, err := filepath.Rel(storePath, shardPath) if err != nil { return fmt.Errorf("shard rel path: %s", err) } if err := appendShardSnapshotFile(sw, sh, name); err != nil { return fmt.Errorf("append shard: name=%s, err=%s", name, err) } } return nil }
// filterPath cleans and makes absolute the path passed in. // // On windows it makes the path UNC also. func (f *Fs) filterPath(s string) string { s = filterFragment(s) if runtime.GOOS == "windows" { if !filepath.IsAbs(s) && !strings.HasPrefix(s, "\\") { s2, err := filepath.Abs(s) if err == nil { s = s2 } } if f.nounc { return s } // Convert to UNC return uncPath(s) } if !filepath.IsAbs(s) { s2, err := filepath.Abs(s) if err == nil { s = s2 } } return s }
// runs dist bootrap to build the compilers for a target platform func distBootstrap(goRoot string, p Platform) (err error) { // the dist tool gets put in the pkg/tool/{host_platform} directory after we've built // the compilers/stdlib for the host platform hostPlatform := Platform{runtime.GOOS, runtime.GOARCH} scriptPath, err := filepath.Abs(filepath.Join(goRoot, "pkg", "tool", hostPlatform.String(), "dist")) if err != nil { return } // but we want to run it from the src directory scriptDir, err := filepath.Abs(filepath.Join(goRoot, "src")) if err != nil { return } bootstrapCmd := exec.Cmd{ Path: scriptPath, Args: []string{scriptPath, "bootstrap", "-v"}, Env: append(os.Environ(), "GOOS="+p.OS, "GOARCH="+p.Arch), Dir: scriptDir, Stdout: os.Stdout, Stderr: os.Stderr, } return bootstrapCmd.Run() }
// ResolveLocalPaths resolves all relative paths in the config object with respect to the stanza's LocationOfOrigin // this cannot be done directly inside of LoadFromFile because doing so there would make it impossible to load a file without // modification of its contents. func ResolveLocalPaths(config *clientcmdapi.Config) error { for _, cluster := range config.Clusters { if len(cluster.LocationOfOrigin) == 0 { continue } base, err := filepath.Abs(filepath.Dir(cluster.LocationOfOrigin)) if err != nil { return fmt.Errorf("Could not determine the absolute path of config file %s: %v", cluster.LocationOfOrigin, err) } if err := ResolvePaths(GetClusterFileReferences(cluster), base); err != nil { return err } } for _, authInfo := range config.AuthInfos { if len(authInfo.LocationOfOrigin) == 0 { continue } base, err := filepath.Abs(filepath.Dir(authInfo.LocationOfOrigin)) if err != nil { return fmt.Errorf("Could not determine the absolute path of config file %s: %v", authInfo.LocationOfOrigin, err) } if err := ResolvePaths(GetAuthInfoFileReferences(authInfo), base); err != nil { return err } } return nil }
func main() { flag.Parse() args := flag.Args() if len(args) < 2 { logrus.Fatal("Expecting source and target directory") } targetDir, err := filepath.Abs(args[len(args)-1]) if err != nil { logrus.Fatal("Error resolving target directory %s: %v", args[len(args)-1], err) } targetDir = filepath.Clean(targetDir) for _, bundleDir := range args[:len(args)-1] { absDir, err := filepath.Abs(bundleDir) if err != nil { logrus.Fatalf("Error resolving directory %s: %v", bundleDir, err) } bundleDir = filepath.Clean(absDir) logrus.Infof("Copying %s to %s", bundleDir, targetDir) if err := buildutil.CopyBundleBinaries(bundleDir, targetDir); err != nil { logrus.Fatalf("Error copying binaries: %v", err) } } }