Skip to content

Commit

Permalink
openshift cluster: remove .docker directory on teardown
Browse files Browse the repository at this point in the history
Remove the $HOME/.docker directory when tearing down a cluster,
so that subsequent cluster creations can be carried out successfully.

Signed-off-by: Marco Vedovati <[email protected]>
  • Loading branch information
marcov authored and flavio committed Nov 26, 2019
1 parent ce6ec77 commit 544fd2e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions integration/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var adminKUBECONFIG = map[string]string{
// running on localhost.
type openshiftCluster struct {
workingDir string
dockerDir string
processes []*exec.Cmd // Processes to terminate on teardown; append to the end, terminate from end to the start.
}

Expand Down Expand Up @@ -211,8 +212,8 @@ func (cluster *openshiftCluster) ocLoginToProject(c *check.C) {
// dockerLogin simulates (docker login) to the cluster, or terminates on failure.
// We do not run (docker login) directly, because that requires a running daemon and a docker package.
func (cluster *openshiftCluster) dockerLogin(c *check.C) {
dockerDir := filepath.Join(homedir.Get(), ".docker")
err := os.Mkdir(dockerDir, 0700)
cluster.dockerDir = filepath.Join(homedir.Get(), ".docker")
err := os.Mkdir(cluster.dockerDir, 0700)
c.Assert(err, check.IsNil)

out := combinedOutputOfCommand(c, "oc", "config", "view", "-o", "json", "-o", "jsonpath={.users[*].user.token}")
Expand All @@ -226,7 +227,7 @@ func (cluster *openshiftCluster) dockerLogin(c *check.C) {
}`, port, authValue))
}
configJSON := `{"auths": {` + strings.Join(auths, ",") + `}}`
err = ioutil.WriteFile(filepath.Join(dockerDir, "config.json"), []byte(configJSON), 0600)
err = ioutil.WriteFile(filepath.Join(cluster.dockerDir, "config.json"), []byte(configJSON), 0600)
c.Assert(err, check.IsNil)
}

Expand All @@ -249,4 +250,7 @@ func (cluster *openshiftCluster) tearDown(c *check.C) {
if cluster.workingDir != "" {
os.RemoveAll(cluster.workingDir)
}
if cluster.dockerDir != "" {
os.RemoveAll(cluster.dockerDir)
}
}

0 comments on commit 544fd2e

Please sign in to comment.