|
5 | 5 | "io/ioutil" |
6 | 6 | "os" |
7 | 7 | "os/exec" |
| 8 | + "os/user" |
8 | 9 | "path/filepath" |
9 | 10 | "strings" |
10 | 11 | "time" |
@@ -59,18 +60,21 @@ type ( |
59 | 60 | func (p Plugin) Exec() error { |
60 | 61 | // Create Auth Config File |
61 | 62 | if p.Login.Config != "" { |
62 | | - homeDir, err := os.UserHomeDir() |
| 63 | + user, err := user.Current() |
63 | 64 | if err != nil { |
64 | | - return fmt.Errorf("failed to find home directory: %s", err) |
| 65 | + return fmt.Errorf("Error getting the current user: %s", err) |
| 66 | + } |
| 67 | + root := fmt.Sprintf("/var/tmp/%s/containers/containers/", user.Uid) |
| 68 | + if err := os.MkdirAll(root, 0777); err != nil { |
| 69 | + return fmt.Errorf("Error writing runtime dir: %s", err) |
65 | 70 | } |
66 | | - dockerHome := fmt.Sprintf("%s/.docker/config.json", homeDir) |
67 | | - os.MkdirAll(dockerHome, 0600) |
68 | 71 |
|
69 | | - path := filepath.Join(dockerHome, "config.json") |
70 | | - err = ioutil.WriteFile(path, []byte(p.Login.Config), 0600) |
71 | | - if err != nil { |
72 | | - return fmt.Errorf("Error writing config.json: %s", err) |
| 72 | + path := filepath.Join(root, "auth.json") |
| 73 | + if err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600); err != nil { |
| 74 | + return fmt.Errorf("Error writing auth.json: %s", err) |
73 | 75 | } |
| 76 | + |
| 77 | + fmt.Printf("Config written to %s\n", path) |
74 | 78 | } |
75 | 79 |
|
76 | 80 | // login to the Docker registry |
|
0 commit comments