func run(c *cli.Context) error { args := c.Args() if len(args) < 3 { return errors.New("a directory, log file and command is required") } workingDir := os.ExpandEnv(args[0]) logFile := os.ExpandEnv(args[1]) fullCommand := os.ExpandEnv(args[2]) command, cmdArgs, err := parseCommand(fullCommand) if err != nil { return errors.WithStack(err) } log, err := os.Create(logFile) if err != nil { return errors.WithStack(err) } cmd := exec.Command(command, cmdArgs...) fmt.Println(cmd.Path) cmd.Dir = workingDir cmd.Stdout = log cmd.Stderr = log return cmd.Run() }
func createNewConfigIfNeeded() { newConfigPath := os.ExpandEnv("$HOME/.config/mumbledj/config.yaml.new") // Check if we should write an updated config file to config.yaml.new. if assetInfo, err := AssetInfo("config.yaml"); err == nil { asset, _ := Asset("config.yaml") if configFile, err := os.Open(os.ExpandEnv("$HOME/.config/mumbledj/config.yaml")); err == nil { configInfo, _ := configFile.Stat() defer configFile.Close() if configNewFile, err := os.Open(newConfigPath); err == nil { defer configNewFile.Close() configNewInfo, _ := configNewFile.Stat() if assetInfo.ModTime().Unix() > configNewInfo.ModTime().Unix() { // The config asset is newer than the config.yaml.new file. // Write a new config.yaml.new file. ioutil.WriteFile(os.ExpandEnv(newConfigPath), asset, 0644) logrus.WithFields(logrus.Fields{ "file_path": newConfigPath, }).Infoln("An updated default configuration file has been written.") } } else if assetInfo.ModTime().Unix() > configInfo.ModTime().Unix() { // The config asset is newer than the existing config file. // Write a config.yaml.new file. ioutil.WriteFile(os.ExpandEnv(newConfigPath), asset, 0644) logrus.WithFields(logrus.Fields{ "file_path": newConfigPath, }).Infoln("An updated default configuration file has been written.") } } } }
func (cmd *Cmd) EnsureSystemRuby() { cmd.Env = []string{ os.ExpandEnv("PATH=${PATH}"), os.ExpandEnv("USER=${USER}"), os.ExpandEnv("HOME=${HOME}"), } }
func (c *Client) authenticate() error { if c.cert != nil { return nil } cert_fname := filepath.Join(os.ExpandEnv(CertDir), "usercert.pem") key_fname := filepath.Join(os.ExpandEnv(CertDir), "userkey.pem") //FIXME: // X509_USER_PROXY doesn't have a format tls.LoadX509KeyPair understands // if os.Getenv("X509_USER_PROXY") != "" { // cert_fname = os.Getenv("X509_USER_PROXY") // key_fname = cert_fname // } cert, err := tls.LoadX509KeyPair(cert_fname, key_fname) if err != nil { user_cert, user_key, err := LoadCert(cert_fname, key_fname) if err != nil { //fmt.Printf("ami: error while trying to load certificate. try running:\n $ go-ami setup-auth\n") return ErrAuth } cert, err = tls.X509KeyPair(user_cert, user_key) if err != nil { return err } } c.cert = &cert return nil }
func serve(config *Config) error { http.Handle("/df", Command{CommandRunner: &commands.DiskCommand{}}) http.Handle("/service/", config.Services) if config.ServerCertificate == "" { return http.ListenAndServe(config.BindAddress, nil) } certFile := os.ExpandEnv(config.ServerCertificate) keyFile := os.ExpandEnv(config.ServerPrivate) caCertFile := os.ExpandEnv(config.CACertificate) cert, err := tls.LoadX509KeyPair(certFile, keyFile) if err != nil { return err } tlsConfig := &tls.Config{ ClientAuth: tls.RequireAndVerifyClientCert, Certificates: []tls.Certificate{cert}, ClientCAs: x509.NewCertPool(), } caCerts, err := ioutil.ReadFile(caCertFile) if err != nil { return err } tlsConfig.ClientCAs.AppendCertsFromPEM(caCerts) l, err := tls.Listen("tcp", config.BindAddress, tlsConfig) if err != nil { return err } return http.Serve(l, nil) }
func parseLink(params []string) (srcPath, dstPath string, mode os.FileMode, err error) { length := len(params) if length < 1 || length > 3 { err = fmt.Errorf("invalid link statement") return } if length > 2 { var parsed uint64 parsed, err = strconv.ParseUint(params[2], 0, 64) if err != nil { return } mode = os.FileMode(parsed) } else { mode = 0755 } dstPath = os.ExpandEnv(params[0]) srcPath = dstPath if length > 1 { srcPath = os.ExpandEnv(params[1]) } return }
func CreateAgent() error { path, err := osext.Executable() if err != nil { return err } fileDir := os.ExpandEnv("$HOME/Library/LaunchAgents") err = os.MkdirAll(fileDir, 0755) if err != nil { return err } err = changePermissions(fileDir) if err != nil { return err } filePath := os.ExpandEnv("$HOME/Library/LaunchAgents/local.dlite.plist") file, err := os.Create(filePath) if err != nil { return err } plist := fmt.Sprintf(template, path) _, err = file.WriteString(plist) if err != nil { return err } return changePermissions(filePath) }
// ExpandFields goes through a Package type to expand any environment variables // contained within, or expand XML structures referrenced before. func expandFields(pkg *Package) Package { // Reflect may throw type-errors (can't trust ourselves with writing good // code, now, can we?) so catch any panics and rewrite them as a general // type of error. defer func() { if r := recover(); r != nil { panic(ErrParseType) } }() // TODO rewrite for more generality in substructs // TODO remove duplicate code valOf := reflect.ValueOf(pkg).Elem() for i := 0; i < valOf.NumField(); i++ { field := valOf.Field(i) if field.Kind() == reflect.Struct { for j := 0; j < field.NumField(); j++ { expanded := os.ExpandEnv(field.Field(j).String()) field.Field(j).SetString(expanded) } } else { expanded := os.ExpandEnv(field.String()) field.SetString(expanded) os.Setenv(valOf.Type().Field(i).Name, field.String()) } } return *pkg }
func (e *registryEntry) createShims() { exeproxy := os.ExpandEnv("${ProgramFiles(x86)}\\exeproxy\\exeproxy.exe") if !pathExists(exeproxy) { return } if !pathExists(shimsPath) { os.MkdirAll(shimsPath, 0) } if shims, ok := e.Installer.options()["shims"]; ok { for _, v := range shims.([]interface{}) { shimTarget := strings.Replace(v.(string), "${version}", e.Version, -1) shimTarget = os.ExpandEnv(shimTarget) shim := filepath.Join(shimsPath, filepath.Base(shimTarget)) if pathExists(shim) { os.Remove(shim) } log.Printf("Creating shim for %s (%s)\n", shimTarget, shim) system(exeproxy, "exeproxy-copy", shim, shimTarget) } } }
func main() { var rootDir, folder string var err error flag.StringVar(&rootDir, "root", os.ExpandEnv("$HOME/Maildir"), "path to maildir") flag.StringVar(&folder, "folder", "", "maildir folder name to put email (empty for inbox)") flag.StringVar(&cache.path, "cache", os.ExpandEnv("$HOME/.cache/maildir-put.cache"), "path to store message-ids to drop duplicate messages") flag.BoolVar(&cache.useRedis, "redis", false, "use redis for cache storage") flag.StringVar(&cache.redisOptions.Addr, "redis-addr", "127.0.0.1:6379", "redis address") flag.Int64Var(&cache.redisOptions.DB, "redis-db", 0, "redis base") flag.StringVar(&cache.redisOptions.Password, "redis-password", "", "redis password") if flag.Parse(); !flag.Parsed() { flag.PrintDefaults() os.Exit(1) } if err = cache.OpenCache(); err != nil { log.Fatalf("Can't open cache: %s", err.Error()) } if hostname, err = os.Hostname(); err != nil { log.Fatalf("Can't get hostname: %s", err.Error()) } md, err := maildir.New(rootDir, true) if err != nil { log.Fatalf("Can't open maildir: %s", err.Error()) } for _, subfolder := range strings.Split(folder, "/") { if subfolder != "" { md, err = md.Child(subfolder, true) if err != nil { log.Fatalf("Can't open maildir: %s", err.Error()) } } } dec := json.NewDecoder(os.Stdin) for { msg := new(Message) err = dec.Decode(msg) if err == nil { err = msg.Process(md) } if err == io.EOF { break } else if err != nil { log.Printf("Cannot read input message: %s", err.Error()) } } if err = cache.Dump(); err != nil { log.Printf("warning: can't dump cache: %s", err.Error()) } }
func CreateDisk(sshKey string, size int) error { sshKey = os.ExpandEnv(sshKey) keyBytes, err := ioutil.ReadFile(sshKey) if err != nil { return err } buffer := new(bytes.Buffer) tarball := tar.NewWriter(buffer) files := []struct { Name string Body []byte }{ {"dhyve, please format-me", []byte("dhyve, please format-me")}, {".ssh/authorized_keys", keyBytes}, } for _, file := range files { if err = tarball.WriteHeader(&tar.Header{ Name: file.Name, Mode: 0644, Size: int64(len(file.Body)), }); err != nil { return err } if _, err = tarball.Write(file.Body); err != nil { return err } } if err = tarball.Close(); err != nil { return err } path := os.ExpandEnv("$HOME/.dlite/disk.img") f, err := os.Create(path) if err != nil { return err } defer f.Close() _, err = f.Write(buffer.Bytes()) if err != nil { return err } _, err = f.Seek(int64(size*1073741824-1), 0) if err != nil { return err } _, err = f.Write([]byte{0}) if err != nil { return err } return changePermissions(path) }
func installBox(ctx *cobra.Command, args []string) { if len(args) < 2 { ErrorExit(ctx, "Needs two arguments to install <BOX FILE|URL> as <BOX NAME>") } boxName := args[0] dstPath := os.ExpandEnv(BOX_ROOT_DIR + boxName + BOX_FILE_EXTENSION) if _, err := os.Lstat(dstPath); err == nil { if !boolForce { log.Fatalf("%s has already installed", boxName) } if err := os.Remove(dstPath); err != nil { log.Fatalf("Could not remove %s, error %s", boxName, err) } } if err := os.MkdirAll(os.ExpandEnv(BOX_ROOT_DIR), 0755); err != nil { log.Fatal(err) } dstFile, err := os.Create(dstPath) if err != nil { log.Fatalf("Could not create a file, error %s", err) } defer dstFile.Close() srcPath := args[1] if strings.HasPrefix(srcPath, "http://") || strings.HasPrefix(srcPath, "https://") { resp, err := http.Get(srcPath) if err != nil { log.Fatalf("Could not download: %s, error %s", srcPath, err) } defer resp.Body.Close() if resp.StatusCode >= 400 { log.Fatalf("Could not download: %s, HTTP status %s", srcPath, resp.Status) } if _, err := io.Copy(dstFile, resp.Body); err != nil { log.Fatalf("Could not download: %s, error %s", srcPath, err) } } else { srcPath = filepath.Clean(srcPath) srcFile, err := os.Open(srcPath) if err != nil { log.Fatalf("Could not open: %s, error %s", srcPath, err) } defer srcFile.Close() if _, err := io.Copy(dstFile, srcFile); err != nil { log.Fatalf("Could not download: %s, error %s", srcPath, err) } } fmt.Printf("%s: Installed %s\n", COMMAND, boxName) }
func (c *ConfigWrapper) Interpolate() { if c.Config != nil { c.Interface.Network.Host = os.ExpandEnv(c.Interface.Network.Host) c.Interface.Socket.Path = os.ExpandEnv(c.Interface.Socket.Path) c.Paths.StageDir = os.ExpandEnv(c.Paths.StageDir) c.Paths.StorageDir = os.ExpandEnv(c.Paths.StorageDir) } }
// DeleteOldest deletes the oldest file in the cache. func (c *Cache) DeleteOldest() error { files, _ := ioutil.ReadDir(os.ExpandEnv(viper.GetString("cache.directory"))) if len(files) > 0 { sort.Sort(SortFilesByAge(files)) os.Remove(fmt.Sprintf("%s/%s", os.ExpandEnv(viper.GetString("cache.directory")), files[0].Name())) return nil } return errors.New("There are no files currently cached") }
// registers all resource related steps func init() { RegisterSteps(func(c *Context) { c.When(`^I parse the file "(.+?)"$`, func(fileName string) { expandedFileName := os.ExpandEnv(fileName) if expandedFileName == "" { c.Fail("File name '%s' (expanded to '%s') is empty !", fileName, expandedFileName) return } if _, err := os.Stat(expandedFileName); err != nil { c.Fail("File '%s' (expanded to '%s') does not exists: %v", fileName, expandedFileName, err) return } _, err := c.ParseResource(expandedFileName) if err != nil { c.Fail("Failed to parse file '%s' (expanded to '%s'): %v", fileName, expandedFileName, err) return } }) c.When(`^I create resources from the file "(.+?)"$`, func(fileName string) { expandedFileName := os.ExpandEnv(fileName) if expandedFileName == "" { c.Fail("File name '%s' (expanded to '%s') is empty !", fileName, expandedFileName) return } if _, err := os.Stat(expandedFileName); err != nil { c.Fail("File '%s' (expanded to '%s') does not exists: %v", fileName, expandedFileName, err) return } r, err := c.ParseResource(expandedFileName) if err != nil { c.Fail("Failed to parse file '%s' (expanded to '%s'): %v", fileName, expandedFileName, err) return } if err = r.Visit(CreateResource); err != nil { c.Fail("Failed to create resource from file '%s' (expanded to '%s'): %v", fileName, expandedFileName, err) return } }) c.When(`^I delete all resources with "(.+?)"$`, func(selector string) { err := c.DeleteResourcesBySelector(selector) if err != nil { c.Fail("Failed to delete resources with '%s': %v", selector, err) return } }) }) }
func GenerateX509KeyPair(certpath string) tls.Certificate { certf := os.ExpandEnv(certpath + "/certificate.pem") keyf := os.ExpandEnv(certpath + "/key.pem") cert, err := tls.LoadX509KeyPair(certf, keyf) if err != nil { logger.Printf("GenerateX509KeyPair(%v): %v", certf, keyf) logger.Panic(err) } return cert }
func (self *Configuration) Init() error { if self.initialized { panic("view.Config already initialized") } if !self.IsProductionServer { addrs, err := net.InterfaceAddrs() if err != nil { return err } for _, addr := range addrs { if ipNet, ok := addr.(*net.IPNet); ok { ip := ipNet.IP.String() for _, prodIP := range Config.ProductionServerIPs { if ip == prodIP { self.IsProductionServer = true break } } } } } if !self.IsProductionServer { self.Debug.Mode = true } // Check if dirs exists and make them absolute for i := range Config.BaseDirs { dir, err := filepath.Abs(os.ExpandEnv(Config.BaseDirs[i])) if err != nil { return err } if !utils.DirExists(dir) { return errs.Format("BaseDir does not exist: %s", dir) } Config.BaseDirs[i] = dir fmt.Println("BaseDir:", dir) } for i := range Config.StaticDirs { Config.StaticDirs[i] = os.ExpandEnv(Config.StaticDirs[i]) fmt.Println("StaticDir:", Config.StaticDirs[i]) } for i := range Config.TemplateDirs { Config.TemplateDirs[i] = os.ExpandEnv(Config.TemplateDirs[i]) fmt.Println("TemplateDir:", Config.TemplateDirs[i]) } self.initialized = true return nil }
func loadEnvironment() (string, string, string) { from := os.ExpandEnv("${SENDGRID_FROM}") username := os.ExpandEnv("${SENDGRID_USER}") password := os.ExpandEnv("${SENDGRID_PASS}") if from == "" || username == "" || password == "" { log.Println("You need to define SENDGRID_FROM, SENDGRID_USER, SENDGRID_PASS in the environment.") os.Exit(1) } return from, username, password }
// extract configuration details from the given file func NewDBConf(p, env string, pgschema string) (*DBConf, error) { cfgFile := filepath.Join(p, "dbconf.yml") f, err := yaml.ReadFile(cfgFile) if err != nil { return nil, err } drv, err := f.Get(fmt.Sprintf("%s.driver", env)) if err != nil { return nil, err } drv = os.ExpandEnv(drv) open, err := f.Get(fmt.Sprintf("%s.open", env)) if err != nil { return nil, err } open = os.ExpandEnv(open) // Automatically parse postgres urls if drv == "postgres" { // Assumption: If we can parse the URL, we should if parsedURL, err := pq.ParseURL(open); err == nil && parsedURL != "" { open = parsedURL } } d := newDBDriver(drv, open) // allow the configuration to override the Import for this driver if imprt, err := f.Get(fmt.Sprintf("%s.import", env)); err == nil { d.Import = imprt } // allow the configuration to override the Dialect for this driver if dialect, err := f.Get(fmt.Sprintf("%s.dialect", env)); err == nil { d.Dialect = dialectByName(dialect) } if !d.IsValid() { return nil, errors.New(fmt.Sprintf("Invalid DBConf: %v", d)) } return &DBConf{ MigrationsDir: filepath.Join(p, "migrations"), Env: env, Driver: d, PgSchema: pgschema, }, nil }
func (s *configs) Set(value string) error { splitConfigDef := strings.Split(value, "=") if len(splitConfigDef) != 2 { return fmt.Errorf("Invalid config definition: ", value) } configDef := config{ template: os.ExpandEnv(splitConfigDef[0]), output: os.ExpandEnv(splitConfigDef[1]), } *s = append(*s, configDef) return nil }
func redisStandaloneClient() (*redis.Client, error) { host := os.ExpandEnv("$TODO_REDIS_STANDALONE_SERVICE_HOST") port := os.ExpandEnv("$TODO_REDIS_STANDALONE_SERVICE_PORT") addr := fmt.Sprintf("%s:%s", host, port) client := redis.NewTCPClient(&redis.Options{Addr: addr}) status := client.Ping() _, err := status.Result() if err != nil { return nil, err } return client, nil }
func init() { env.MustProcess(&DefaultConfig) if DefaultConfig.SecretKeyring != "" { DefaultConfig.SecretKeyring = os.ExpandEnv(DefaultConfig.SecretKeyring) } if DefaultConfig.Keyring != "" { DefaultConfig.Keyring = os.ExpandEnv(DefaultConfig.Keyring) } flagset.StringVar(&backendName, "backend", DefaultConfig.Backend, "backend provider") flagset.StringVar(&endpoint, "endpoint", DefaultConfig.Endpoint, "backend url") flagset.BoolVar(&plaintext, "plaintext", false, "skip encryption") }
func discoverSeedsFromKubernetesMaster() []net.IP { var seeds []net.IP kubeMaster := os.ExpandEnv("${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}") if len(os.Getenv("KUBERNETES_MASTER")) > 0 { kubeMaster = os.Getenv("KUBERNETES_MASTER") } kubeMaster = os.ExpandEnv(kubeMaster) if len(os.Getenv("KUBERNETES_SELECTOR")) > 0 && len(kubeMaster) > 0 { if !(strings.HasPrefix(kubeMaster, "http://") || strings.HasPrefix(kubeMaster, "https://")) { kubeMaster = "https://" + kubeMaster } insecure, _ := strconv.ParseBool(os.Getenv("KUBERNETES_INSECURE")) kubeClient := client.NewOrDie(&client.Config{ Host: os.ExpandEnv(kubeMaster), Insecure: len(os.Getenv("KUBERNETES_INSECURE")) > 0 && insecure, }) selector, err := labels.Parse(os.Getenv("KUBERNETES_SELECTOR")) if err != nil { log.Println(err) } else { namespace := os.Getenv("KUBERNETES_NAMESPACE") if len(namespace) == 0 { namespace = api.NamespaceDefault } podList, err := kubeClient.Pods(namespace).List(selector, fields.Everything()) if err != nil { log.Println(err) } else { currentHostname, err := os.Hostname() if err != nil { log.Println(err) } for _, pod := range podList.Items { if pod.Status.Phase == api.PodRunning && len(pod.Status.PodIP) > 0 && pod.Name != currentHostname { podIP := net.ParseIP(pod.Status.PodIP) if podIP != nil { seeds = append(seeds, podIP) } } } } } } return seeds }
func (e *registryEntry) install(installer string) { if e.Installer.Kind == "advancedinstaller" { system(installer, "/q", "/i") } else if e.Installer.Kind == "as-is" { system(installer) } else if e.Installer.Kind == "conemu" { if isAmd64 { system(installer, "/p:x64", "/q") } else { system(installer, "/p:x86", "/q") } } else if e.Installer.Kind == "custom" { var args []string for _, v := range e.Installer.options()["arguments"].([]interface{}) { current := strings.Replace(v.(string), "${installer}", installer, -1) current = os.ExpandEnv(current) args = append(args, current) } if len(args) == 0 { return } else if len(args) == 1 { system(args[0]) } else { system(args[0], args[1:]...) } } else if e.Installer.Kind == "easy_install_26" { system("\\Python26\\Scripts\\easy_install.exe", installer) } else if e.Installer.Kind == "easy_install_27" { system("\\Python27\\Scripts\\easy_install.exe", installer) } else if e.Installer.Kind == "innosetup" { system(installer, "/norestart", "/sp-", "/verysilent") } else if e.Installer.Kind == "msi" { system("msiexec.exe", "/q", "/i", installer, "REBOOT=ReallySuppress") } else if e.Installer.Kind == "nsis" { system(installer, "/S", "/NCRC") } else if e.Installer.Kind == "zip" { destination := os.ExpandEnv(e.Installer.options()["destination"].(string)) log.Println("Extracting to", destination) extractZip(installer, os.ExpandEnv(e.Installer.options()["destination"].(string))) } else { log.Fatalln("Unknown installer type:", e.Installer.Kind) } }
// Catenate a handful of install logs in to one for server upload. // Unfortunately, Dokan can generate UTF16 logs, so we test each file // and translate if necessary. func GetInstallLogPath() (string, error) { // Get the 3 newest keybase logs - sorting by name works because timestamp keybaseLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Keybase*.log"))) sort.Strings(keybaseLogFiles) if len(keybaseLogFiles) > 3 { keybaseLogFiles = keybaseLogFiles[:3] } // Get the 2 newest dokan logs - sorting by name works because timestamp dokanLogFiles, err := filepath.Glob(os.ExpandEnv(filepath.Join("${TEMP}", "Dokan*.log"))) sort.Strings(dokanLogFiles) if len(dokanLogFiles) > 2 { dokanLogFiles = dokanLogFiles[:2] } keybaseLogFiles = append(keybaseLogFiles, dokanLogFiles...) logName, logFile, err := libkb.OpenTempFile("KeybaseInstallUpload", ".log", 0) defer logFile.Close() if err != nil { return "", err } getVersionAndDrivers(logFile) if len(keybaseLogFiles) == 0 { fmt.Fprintf(logFile, " --- NO INSTALL LOGS FOUND!?! ---\n") } for _, path := range keybaseLogFiles { fmt.Fprintf(logFile, " --- %s ---\n", path) // We have to parse the contents and write them because some files need to // be decoded from utf16 s, err := newScannerUTF16or8(path) if err != nil { fmt.Fprintf(logFile, " --- NewScannerUTF16(%s) returns %v---\n", path, err) } else { scanner := bufio.NewScanner(s) for scanner.Scan() { fmt.Fprintln(logFile, scanner.Text()) // Println will add back the final '\n' } if err := scanner.Err(); err != nil { fmt.Fprintf(logFile, " --- error reading (%s): %v---\n", path, err) } } fmt.Fprint(logFile, "\n\n") } return logName, err }
func run_setup_auth(cmd *commander.Command, args []string) error { n := cmd.Name() // fmt.Printf("%s: args: %v\n", n, args) // fmt.Printf("%s: flags: %v\n", n, cmd.Flag.NArg()) dirname := os.ExpandEnv(ami.ConfigDir) if !path_exists(dirname) { err := os.MkdirAll(dirname, 0700) if err != nil { return err } } dirname = os.ExpandEnv(ami.CertDir) if !path_exists(dirname) { err := os.MkdirAll(dirname, 0700) if err != nil { return err } } cert_fname := cmd.Flag.Lookup("usercert").Value.Get().(string) if !path_exists(cert_fname) { fmt.Printf("%s: no such user certificate file [%s]\n", n, cert_fname) } key_fname := cmd.Flag.Lookup("userkey").Value.Get().(string) if !path_exists(key_fname) { fmt.Printf("%s: no such user key file [%s]\n", n, key_fname) } user_cert, user_key, err := ami.LoadCert(cert_fname, key_fname) if err != nil { return err } cert_fname = filepath.Join(dirname, "usercert.pem") err = ioutil.WriteFile(cert_fname, user_cert, 0600) if err != nil { return err } key_fname = filepath.Join(dirname, "userkey.pem") err = ioutil.WriteFile(key_fname, user_key, 0600) if err != nil { return err } return nil }
func (r RunParameters) VolumesFrom() []string { var volumesFrom []string for _, rawVolumesFrom := range r.RawVolumesFrom { volumesFrom = append(volumesFrom, os.ExpandEnv(rawVolumesFrom)) } return volumesFrom }
func (r RunParameters) SecurityOpt() []string { var securityOpt []string for _, rawSecurityOpt := range r.RawSecurityOpt { securityOpt = append(securityOpt, os.ExpandEnv(rawSecurityOpt)) } return securityOpt }
func (r RunParameters) Ulimit() []string { var ulimit []string for _, rawUlimit := range r.RawUlimit { ulimit = append(ulimit, os.ExpandEnv(rawUlimit)) } return ulimit }
func (r RunParameters) Publish() []string { var publish []string for _, rawPublish := range r.RawPublish { publish = append(publish, os.ExpandEnv(rawPublish)) } return publish }