| ... | ... |
@@ -165,6 +165,7 @@ func (h *HostHelper) CopyMasterConfigToHost(sourceFile, destDir string) error {
|
| 165 | 165 |
if err != nil {
|
| 166 | 166 |
return err |
| 167 | 167 |
} |
| 168 |
+ defer os.RemoveAll(localDir) |
|
| 168 | 169 |
tarHelper := tarhelper.New() |
| 169 | 170 |
tarHelper.SetExclusionPattern(nil) |
| 170 | 171 |
var tarLog io.Writer |
| ... | ... |
@@ -176,6 +177,7 @@ func (h *HostHelper) CopyMasterConfigToHost(sourceFile, destDir string) error {
|
| 176 | 176 |
return err |
| 177 | 177 |
} |
| 178 | 178 |
localTarClosed := false |
| 179 |
+ defer os.Remove(localTarFile.Name()) |
|
| 179 | 180 |
defer func() {
|
| 180 | 181 |
if !localTarClosed {
|
| 181 | 182 |
errors.LogError(localTarFile.Close()) |
| ... | ... |
@@ -441,7 +441,41 @@ func (h *Helper) copyConfig(hostDir string) (string, error) {
|
| 441 | 441 |
} |
| 442 | 442 |
return "", err |
| 443 | 443 |
} |
| 444 |
- return filepath.Join(tempDir, filepath.Base(hostDir)), nil |
|
| 444 |
+ |
|
| 445 |
+ // The configuration dir comes in as something like /tmp/openshift-config%d/openshift.local.config/... . |
|
| 446 |
+ // Remove the intermediate openshift.local.config directory and reparent its files. |
|
| 447 |
+ // Thus the return value of this function represents both the configuration |
|
| 448 |
+ // directory as well as the temporary directory which should be removed at exit. |
|
| 449 |
+ |
|
| 450 |
+ subDirPath := filepath.Join(tempDir, filepath.Base(hostDir)) |
|
| 451 |
+ subDir, err := os.Open(subDirPath) |
|
| 452 |
+ if err != nil {
|
|
| 453 |
+ glog.V(2).Infof("Error opening temporary config dir %s: %v", subDir, err)
|
|
| 454 |
+ return "", err |
|
| 455 |
+ } |
|
| 456 |
+ |
|
| 457 |
+ names, err := subDir.Readdirnames(0) |
|
| 458 |
+ if err != nil {
|
|
| 459 |
+ glog.V(2).Infof("Error listing temporary config dir %s: %v", subDir, err)
|
|
| 460 |
+ return "", err |
|
| 461 |
+ } |
|
| 462 |
+ |
|
| 463 |
+ for _, name := range names {
|
|
| 464 |
+ err = os.Rename(filepath.Join(subDirPath, name), filepath.Join(tempDir, name)) |
|
| 465 |
+ if err != nil {
|
|
| 466 |
+ glog.V(2).Infof("Error moving file/dir %s: %v", filepath.Join(subDirPath, name), err)
|
|
| 467 |
+ return "", err |
|
| 468 |
+ } |
|
| 469 |
+ } |
|
| 470 |
+ |
|
| 471 |
+ subDir.Close() |
|
| 472 |
+ |
|
| 473 |
+ err = os.Remove(subDirPath) |
|
| 474 |
+ if err != nil {
|
|
| 475 |
+ glog.V(2).Infof("Error removing temporary config dir %s: %v", subDirPath, err)
|
|
| 476 |
+ } |
|
| 477 |
+ |
|
| 478 |
+ return tempDir, nil |
|
| 445 | 479 |
} |
| 446 | 480 |
|
| 447 | 481 |
func (h *Helper) updateConfig(configDir, hostDir, routerIP, metricsHost string) error {
|
| ... | ... |
@@ -290,6 +290,9 @@ func (c *ClientStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command) |
| 290 | 290 |
// Create an initial project |
| 291 | 291 |
c.addTask(fmt.Sprintf("Creating initial project %q", initialProjectName), c.CreateProject)
|
| 292 | 292 |
|
| 293 |
+ // Remove temporary directory |
|
| 294 |
+ c.addTask("Removing temporary directory", c.RemoveTemporaryDirectory)
|
|
| 295 |
+ |
|
| 293 | 296 |
// Display server information |
| 294 | 297 |
c.addTask("Server Information", c.ServerInfo)
|
| 295 | 298 |
|
| ... | ... |
@@ -691,7 +694,11 @@ func (c *ClientStartConfig) Login(out io.Writer) error {
|
| 691 | 691 |
// CreateProject creates a new project for the current user |
| 692 | 692 |
func (c *ClientStartConfig) CreateProject(out io.Writer) error {
|
| 693 | 693 |
return openshift.CreateProject(initialProjectName, initialProjectDisplay, initialProjectDesc, "oc", out) |
| 694 |
+} |
|
| 694 | 695 |
|
| 696 |
+// RemoveTemporaryDirectory removes the local configuration directory |
|
| 697 |
+func (c *ClientStartConfig) RemoveTemporaryDirectory(out io.Writer) error {
|
|
| 698 |
+ return os.RemoveAll(c.LocalConfigDir) |
|
| 695 | 699 |
} |
| 696 | 700 |
|
| 697 | 701 |
// ServerInfo displays server information after a successful start |