本文整理匯總了Golang中k8s/io/kubernetes/pkg/credentialprovider.NewDockerKeyring函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewDockerKeyring函數的具體用法?Golang NewDockerKeyring怎麽用?Golang NewDockerKeyring使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewDockerKeyring函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Complete
func (o *DockerbuildOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string) error {
paths, envArgs, ok := cmdutil.SplitEnvironmentFromResources(args)
if !ok {
return kcmdutil.UsageError(cmd, "context directory must be specified before environment changes: %s", strings.Join(args, " "))
}
if len(paths) != 2 {
return kcmdutil.UsageError(cmd, "the directory to build and tag must be specified")
}
o.Arguments, _, _ = cmdutil.ParseEnvironmentArguments(envArgs)
o.Directory = paths[0]
o.Tag = paths[1]
if len(o.DockerfilePath) == 0 {
o.DockerfilePath = filepath.Join(o.Directory, "Dockerfile")
}
var mounts []dockerbuilder.Mount
for _, s := range o.MountSpecs {
segments := strings.Split(s, ":")
if len(segments) != 2 {
return kcmdutil.UsageError(cmd, "--mount must be of the form SOURCE:DEST")
}
mounts = append(mounts, dockerbuilder.Mount{SourcePath: segments[0], DestinationPath: segments[1]})
}
o.Mounts = mounts
client, err := docker.NewClientFromEnv()
if err != nil {
return err
}
o.Client = client
o.Keyring = credentialprovider.NewDockerKeyring()
return nil
}
示例2: New
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
volumeGetter volumeGetter,
imageBackOff *util.Backoff,
serializeImagePulls bool,
) (*Runtime, error) {
// Create dbus connection.
systemd, err := newSystemd()
if err != nil {
return nil, fmt.Errorf("rkt: cannot create systemd interface: %v", err)
}
// TODO(yifan): Use secure connection.
apisvcConn, err := grpc.Dial(defaultRktAPIServiceAddr, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("rkt: cannot connect to rkt api service: %v", err)
}
rktBinAbsPath := config.Path
if rktBinAbsPath == "" {
// No default rkt path was set, so try to find one in $PATH.
var err error
rktBinAbsPath, err = exec.LookPath("rkt")
if err != nil {
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
}
}
rkt := &Runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
apisvcConn: apisvcConn,
apisvc: rktapi.NewPublicAPIClient(apisvcConn),
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
generator: generator,
recorder: recorder,
livenessManager: livenessManager,
volumeGetter: volumeGetter,
}
if serializeImagePulls {
rkt.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, rkt, imageBackOff)
} else {
rkt.imagePuller = kubecontainer.NewImagePuller(recorder, rkt, imageBackOff)
}
if err := rkt.checkVersion(minimumRktBinVersion, recommendedRktBinVersion, minimumAppcVersion, minimumRktApiVersion, minimumSystemdVersion); err != nil {
// TODO(yifan): Latest go-systemd version have the ability to close the
// dbus connection. However the 'docker/libcontainer' package is using
// the older go-systemd version, so we can't update the go-systemd version.
rkt.apisvcConn.Close()
return nil, err
}
return rkt, nil
}
示例3: New
// New creates the hyper container runtime which implements the container runtime interface.
func New(generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
networkPlugin network.NetworkPlugin,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
volumeGetter volumeGetter,
kubeClient client.Interface,
imageBackOff *util.Backoff,
serializeImagePulls bool,
httpClient kubetypes.HttpGetter,
disableHyperInternalService bool,
containerLogsDir string,
os kubecontainer.OSInterface,
) (kubecontainer.Runtime, error) {
// check hyper has already installed
hyperBinAbsPath, err := exec.LookPath(hyperBinName)
if err != nil {
glog.Errorf("Hyper: can't find hyper binary")
return nil, fmt.Errorf("cannot find hyper binary: %v", err)
}
hyper := &runtime{
hyperBinAbsPath: hyperBinAbsPath,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerLogsDir: containerLogsDir,
containerRefManager: containerRefManager,
generator: generator,
livenessManager: livenessManager,
os: os,
recorder: recorder,
networkPlugin: networkPlugin,
volumeGetter: volumeGetter,
hyperClient: NewHyperClient(),
kubeClient: kubeClient,
disableHyperInternalService: disableHyperInternalService,
}
if serializeImagePulls {
hyper.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, hyper, imageBackOff)
} else {
hyper.imagePuller = kubecontainer.NewImagePuller(recorder, hyper, imageBackOff)
}
version, err := hyper.hyperClient.Version()
if err != nil {
return nil, fmt.Errorf("cannot get hyper version: %v", err)
}
hyperVersion, err := parseVersion(version)
if err != nil {
return nil, fmt.Errorf("cannot get hyper version: %v", err)
}
hyper.version = hyperVersion
hyper.runner = lifecycle.NewHandlerRunner(httpClient, hyper, hyper)
return hyper, nil
}
示例4: New
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
readinessManager *kubecontainer.ReadinessManager,
volumeGetter volumeGetter) (kubecontainer.Runtime, error) {
systemdVersion, err := getSystemdVersion()
if err != nil {
return nil, err
}
result, err := systemdVersion.Compare(systemdMinimumVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: systemd version is too old, requires at least %v", systemdMinimumVersion)
}
systemd, err := dbus.New()
if err != nil {
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
}
// Test if rkt binary is in $PATH.
// TODO(yifan): Use a kubelet flag to read the path.
rktBinAbsPath, err := exec.LookPath("rkt")
if err != nil {
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
}
rkt := &runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
generator: generator,
recorder: recorder,
readinessManager: readinessManager,
volumeGetter: volumeGetter,
}
rkt.prober = prober.New(rkt, readinessManager, containerRefManager, recorder)
// Test the rkt version.
version, err := rkt.Version()
if err != nil {
return nil, err
}
result, err = version.Compare(rktMinimumVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: Version is too old, requires at least %v", rktMinimumVersion)
}
return rkt, nil
}
示例5: New
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
runtimeHelper kubecontainer.RuntimeHelper,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
volumeGetter volumeGetter,
imageBackOff *util.Backoff,
serializeImagePulls bool,
) (*Runtime, error) {
// Create dbus connection.
systemd, err := newSystemd()
if err != nil {
return nil, fmt.Errorf("rkt: cannot create systemd interface: %v", err)
}
// TODO(yifan): Use secure connection.
apisvcConn, err := grpc.Dial(defaultRktAPIServiceAddr, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("rkt: cannot connect to rkt api service: %v", err)
}
rktBinAbsPath := config.Path
if rktBinAbsPath == "" {
// No default rkt path was set, so try to find one in $PATH.
var err error
rktBinAbsPath, err = exec.LookPath("rkt")
if err != nil {
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
}
}
rkt := &Runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
apisvcConn: apisvcConn,
apisvc: rktapi.NewPublicAPIClient(apisvcConn),
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
runtimeHelper: runtimeHelper,
recorder: recorder,
livenessManager: livenessManager,
volumeGetter: volumeGetter,
}
if serializeImagePulls {
rkt.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, rkt, imageBackOff)
} else {
rkt.imagePuller = kubecontainer.NewImagePuller(recorder, rkt, imageBackOff)
}
if err := rkt.getVersions(); err != nil {
return nil, fmt.Errorf("rkt: error getting version info: %v", err)
}
return rkt, nil
}
示例6: New
// New creates the hyper container runtime which implements the container runtime interface.
func New(runtimeHelper kubecontainer.RuntimeHelper,
recorder record.EventRecorder,
networkPlugin network.NetworkPlugin,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
kubeClient clientset.Interface,
imageBackOff *flowcontrol.Backoff,
serializeImagePulls bool,
httpClient kubetypes.HttpGetter,
disableHyperInternalService bool,
containerLogsDir string,
os kubecontainer.OSInterface,
) (kubecontainer.Runtime, error) {
hyperClient, err := NewHyperClient()
if err != nil {
return nil, err
}
hyper := &runtime{
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerLogsDir: containerLogsDir,
containerRefManager: containerRefManager,
runtimeHelper: runtimeHelper,
livenessManager: livenessManager,
os: os,
recorder: recorder,
networkPlugin: networkPlugin,
hyperClient: hyperClient,
kubeClient: kubeClient,
disableHyperInternalService: disableHyperInternalService,
}
if serializeImagePulls {
hyper.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, hyper, imageBackOff)
} else {
hyper.imagePuller = kubecontainer.NewImagePuller(recorder, hyper, imageBackOff)
}
version, err := hyper.hyperClient.Version()
if err != nil {
return nil, fmt.Errorf("cannot get hyper version: %v", err)
}
hyperVersion, err := parseVersion(version)
if err != nil {
return nil, fmt.Errorf("cannot get hyper version: %v", err)
}
hyper.version = hyperVersion
hyper.runner = lifecycle.NewHandlerRunner(httpClient, hyper, hyper)
return hyper, nil
}
示例7: newDockerPuller
// newDockerPuller creates a new instance of the default implementation of DockerPuller.
func newDockerPuller(client DockerInterface, qps float32, burst int) DockerPuller {
dp := dockerPuller{
client: client,
keyring: credentialprovider.NewDockerKeyring(),
}
if qps == 0.0 {
return dp
}
return &throttledDockerPuller{
puller: dp,
limiter: util.NewTokenBucketRateLimiter(qps, burst),
}
}
示例8: New
// New creates the hyper container runtime which implements the container runtime interface.
func New(generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
networkPlugin network.NetworkPlugin,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
volumeGetter volumeGetter,
kubeClient client.Interface,
imageBackOff *util.Backoff,
serializeImagePulls bool) (kubecontainer.Runtime, error) {
// check hyper has already installed
hyperBinAbsPath, err := exec.LookPath(hyperBinName)
if err != nil {
glog.Errorf("Hyper: can't find hyper binary")
return nil, fmt.Errorf("cannot find hyper binary: %v", err)
}
hyper := &runtime{
hyperBinAbsPath: hyperBinAbsPath,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
generator: generator,
livenessManager: livenessManager,
recorder: recorder,
networkPlugin: networkPlugin,
volumeGetter: volumeGetter,
hyperClient: NewHyperClient(),
kubeClient: kubeClient,
}
if serializeImagePulls {
hyper.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, hyper, imageBackOff)
} else {
hyper.imagePuller = kubecontainer.NewImagePuller(recorder, hyper, imageBackOff)
}
return hyper, nil
}
示例9: Complete
func (o *DockerbuildOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string) error {
paths, envArgs, ok := cmdutil.SplitEnvironmentFromResources(args)
if !ok {
return kcmdutil.UsageError(cmd, "context directory must be specified before environment changes: %s", strings.Join(args, " "))
}
if len(paths) != 2 {
return kcmdutil.UsageError(cmd, "the directory to build and tag must be specified")
}
o.Arguments, _, _ = cmdutil.ParseEnvironmentArguments(envArgs)
o.Directory = paths[0]
o.Tag = paths[1]
if len(o.DockerfilePath) == 0 {
o.DockerfilePath = filepath.Join(o.Directory, "Dockerfile")
}
client, err := docker.NewClientFromEnv()
if err != nil {
return err
}
o.Client = client
o.Keyring = credentialprovider.NewDockerKeyring()
return nil
}
示例10: New
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
readinessManager *kubecontainer.ReadinessManager,
volumeGetter volumeGetter,
serializeImagePulls bool,
) (kubecontainer.Runtime, error) {
systemdVersion, err := getSystemdVersion()
if err != nil {
return nil, err
}
result, err := systemdVersion.Compare(systemdMinimumVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: systemd version is too old, requires at least %v", systemdMinimumVersion)
}
systemd, err := dbus.New()
if err != nil {
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
}
rktBinAbsPath := config.Path
if rktBinAbsPath == "" {
// No default rkt path was set, so try to find one in $PATH.
var err error
rktBinAbsPath, err = exec.LookPath("rkt")
if err != nil {
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
}
}
rkt := &runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
generator: generator,
recorder: recorder,
readinessManager: readinessManager,
volumeGetter: volumeGetter,
}
rkt.prober = prober.New(rkt, readinessManager, containerRefManager, recorder)
if serializeImagePulls {
rkt.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, rkt)
} else {
rkt.imagePuller = kubecontainer.NewImagePuller(recorder, rkt)
}
// Test the rkt version.
version, err := rkt.Version()
if err != nil {
return nil, err
}
result, err = version.Compare(rktMinimumVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: Version is too old, requires at least %v", rktMinimumVersion)
}
return rkt, nil
}
示例11: NewKubeGenericRuntimeManager
// NewKubeGenericRuntimeManager creates a new kubeGenericRuntimeManager
func NewKubeGenericRuntimeManager(
recorder record.EventRecorder,
livenessManager proberesults.Manager,
containerRefManager *kubecontainer.RefManager,
osInterface kubecontainer.OSInterface,
networkPlugin network.NetworkPlugin,
runtimeHelper kubecontainer.RuntimeHelper,
httpClient types.HttpGetter,
imageBackOff *flowcontrol.Backoff,
serializeImagePulls bool,
cpuCFSQuota bool,
runtimeService internalApi.RuntimeService,
imageService internalApi.ImageManagerService,
) (*kubeGenericRuntimeManager, error) {
kubeRuntimeManager := &kubeGenericRuntimeManager{
recorder: recorder,
cpuCFSQuota: cpuCFSQuota,
livenessManager: livenessManager,
containerRefManager: containerRefManager,
osInterface: osInterface,
networkPlugin: networkPlugin,
runtimeHelper: runtimeHelper,
runtimeService: runtimeService,
imageService: imageService,
keyring: credentialprovider.NewDockerKeyring(),
}
typedVersion, err := kubeRuntimeManager.runtimeService.Version(kubeRuntimeAPIVersion)
if err != nil {
glog.Errorf("Get runtime version failed: %v", err)
return nil, err
}
// Only matching kubeRuntimeAPIVersion is supported now
// TODO: Runtime API machinery is under discussion at https://github.com/kubernetes/kubernetes/issues/28642
if typedVersion.GetVersion() != kubeRuntimeAPIVersion {
glog.Errorf("Runtime api version %s is not supported, only %s is supported now",
typedVersion.GetVersion(),
kubeRuntimeAPIVersion)
return nil, ErrVersionNotSupported
}
kubeRuntimeManager.runtimeName = typedVersion.GetRuntimeName()
glog.Infof("Container runtime %s initialized, version: %s, apiVersion: %s",
typedVersion.GetRuntimeName(),
typedVersion.GetRuntimeVersion(),
typedVersion.GetRuntimeApiVersion())
// If the container logs directory does not exist, create it.
// TODO: create podLogsRootDirectory at kubelet.go when kubelet is refactored to
// new runtime interface
if _, err := osInterface.Stat(podLogsRootDirectory); os.IsNotExist(err) {
if err := osInterface.MkdirAll(podLogsRootDirectory, 0755); err != nil {
glog.Errorf("Failed to create directory %q: %v", podLogsRootDirectory, err)
}
}
kubeRuntimeManager.imagePuller = images.NewImageManager(
kubecontainer.FilterEventRecorder(recorder),
kubeRuntimeManager,
imageBackOff,
serializeImagePulls)
kubeRuntimeManager.runner = lifecycle.NewHandlerRunner(httpClient, kubeRuntimeManager, kubeRuntimeManager)
return kubeRuntimeManager, nil
}
示例12: newDockerPuller
// newDockerPuller creates a new instance of the default implementation of DockerPuller.
func newDockerPuller(client DockerInterface) DockerPuller {
return &dockerPuller{
client: client,
keyring: credentialprovider.NewDockerKeyring(),
}
}
示例13: New
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
livenessManager proberesults.Manager,
volumeGetter volumeGetter,
imageBackOff *util.Backoff,
serializeImagePulls bool,
) (*Runtime, error) {
systemdVersion, err := getSystemdVersion()
if err != nil {
return nil, err
}
result, err := systemdVersion.Compare(systemdMinimumVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: systemd version is too old, requires at least %v", systemdMinimumVersion)
}
systemd, err := dbus.New()
if err != nil {
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
}
rktBinAbsPath := config.Path
if rktBinAbsPath == "" {
// No default rkt path was set, so try to find one in $PATH.
var err error
rktBinAbsPath, err = exec.LookPath("rkt")
if err != nil {
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
}
}
rkt := &Runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
containerRefManager: containerRefManager,
generator: generator,
recorder: recorder,
livenessManager: livenessManager,
volumeGetter: volumeGetter,
}
if serializeImagePulls {
rkt.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, rkt, imageBackOff)
} else {
rkt.imagePuller = kubecontainer.NewImagePuller(recorder, rkt, imageBackOff)
}
// Test the rkt version.
version, err := rkt.Version()
if err != nil {
return nil, err
}
result, err = version.Compare(minimumRktVersion)
if err != nil {
return nil, err
}
if result < 0 {
return nil, fmt.Errorf("rkt: version is too old, requires at least %v", minimumRktVersion)
}
result, err = version.Compare(recommendRktVersion)
if err != nil {
return nil, err
}
if result != 0 {
// TODO(yifan): Record an event to expose the information.
glog.Warningf("rkt: current version %q is not recommended (recommended version %q)", version, recommendRktVersion)
}
return rkt, nil
}
示例14: NewLocalCredentials
func NewLocalCredentials() auth.CredentialStore {
return &keyringCredentialStore{credentialprovider.NewDockerKeyring()}
}