diff --git a/pkg/kubelet/rkt/pull.go b/pkg/kubelet/rkt/pull.go new file mode 100644 index 00000000000..4753d57f556 --- /dev/null +++ b/pkg/kubelet/rkt/pull.go @@ -0,0 +1,110 @@ +/* +Copyright 2015 Google Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package rkt + +import ( + "fmt" + "os" + "path" + "strings" + + "github.com/docker/docker/pkg/parsers" + docker "github.com/fsouza/go-dockerclient" + "github.com/golang/glog" +) + +const ( + authDir = "auth.d" + dockerAuthTemplate = `{"rktKind":"dockerAuth","rktVersion":"v1","registries":[%q],"credentials":{"user":%q,"password":%q}}` +) + +// writeDockerAuthConfig writes the docker credentials to rkt auth config files. +// This enables rkt to pull docker images from docker registry with credentials. +func (r *Runtime) writeDockerAuthConfig(image string, creds docker.AuthConfiguration) error { + registry := "index.docker.io" + // Image spec: [/]/[: