Skip to content

Commit

Permalink
Merge pull request #1982 from hirsim/fix-issue-1981
Browse files Browse the repository at this point in the history
Fix issue 1981
  • Loading branch information
r2d4 authored Sep 19, 2017
2 parents c1c4455 + 442f746 commit 93f6eb2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/minikube/bootstrapper/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package bootstrapper

import (
"net"
"path"
"path/filepath"
"strings"

Expand All @@ -44,7 +45,7 @@ var (
// SetupCerts gets the generated credentials required to talk to the APIServer.
func SetupCerts(cmd CommandRunner, k8s KubernetesConfig) error {
localPath := constants.GetMinipath()
glog.Infoln("Setting up certificates for IP: %s", k8s.NodeIP)
glog.Infof("Setting up certificates for IP: %s\n", k8s.NodeIP)

if err := generateCerts(k8s); err != nil {
return errors.Wrap(err, "Error generating certs")
Expand All @@ -68,9 +69,9 @@ func SetupCerts(cmd CommandRunner, k8s KubernetesConfig) error {
kubeCfgSetup := &kubeconfig.KubeConfigSetup{
ClusterName: k8s.NodeName,
ClusterServerAddress: "https://localhost:8443",
ClientCertificate: filepath.Join(util.DefaultCertPath, "apiserver.crt"),
ClientKey: filepath.Join(util.DefaultCertPath, "apiserver.key"),
CertificateAuthority: filepath.Join(util.DefaultCertPath, "ca.crt"),
ClientCertificate: path.Join(util.DefaultCertPath, "apiserver.crt"),
ClientKey: path.Join(util.DefaultCertPath, "apiserver.key"),
CertificateAuthority: path.Join(util.DefaultCertPath, "ca.crt"),
KeepContext: false,
}

Expand Down
30 changes: 30 additions & 0 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"

"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -96,9 +97,31 @@ func LoadImages(cmd bootstrapper.CommandRunner, images []string, cacheDir string

// # ParseReference cannot have a : in the directory path
func sanitizeCacheDir(image string) string {
if hasWindowsDriveLetter(image) {
// not sanitize Windows drive letter.
return image[:2] + strings.Replace(image[2:], ":", "_", -1)
}
return strings.Replace(image, ":", "_", -1)
}

func hasWindowsDriveLetter(s string) bool {
if runtime.GOOS != "windows" {
return false
}
if len(s) < 3 {
return false
}

drive := s[:3]
for _, b := range "CDEFGHIJKLMNOPQRSTUVWXYZAB" {
if d := string(b) + ":"; drive == d+`\` || drive == d+`/` {
return true
}
}

return false
}

func LoadFromCacheBlocking(cmd bootstrapper.CommandRunner, src string) error {
glog.Infoln("Loading image from cache at ", src)
filename := filepath.Base(src)
Expand Down Expand Up @@ -156,6 +179,13 @@ func CacheImage(image, dst string) error {
return errors.Wrapf(err, "making cache image directory: %s", dst)
}

// TODO: support Windows drive letter.
// L:164 ParseReference does not support Windows drive letter.
// If contains Windows drive letter, it disable cache image for now.
if hasWindowsDriveLetter(dst) {
return nil
}

srcRef, err := getSrcRef(image)
if err != nil {
return errors.Wrap(err, "creating docker image src ref")
Expand Down

0 comments on commit 93f6eb2

Please sign in to comment.