Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

artifact supports pulling images with skipping SSL certificate validation #967

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions pkg/artifact/containerd.go
@@ -0,0 +1,45 @@
/*
Copyright 2022 The KubeSphere Authors.

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 artifact

import (
"context"
"crypto/tls"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/containerd/remotes/docker/config"
)

// PushTracker returns a new InMemoryTracker which tracks the ref status
var PushTracker = docker.NewInMemoryTracker()

func GetResolver(ctx context.Context) remotes.Resolver {
options := docker.ResolverOptions{
Tracker: PushTracker,
}

hostOptions := config.HostOptions{}

defaultConfig := &tls.Config{
InsecureSkipVerify: true,
}

hostOptions.DefaultTLS = defaultConfig

options.Hosts = config.ConfigureHosts(ctx, hostOptions)
return docker.NewResolver(options)
}
1 change: 1 addition & 0 deletions pkg/artifact/tasks.go
Expand Up @@ -89,6 +89,7 @@ func (p *PullImages) Execute(_ connector.Runtime) error {
})

opts := []containerd.RemoteOpt{
containerd.WithResolver(GetResolver(ctx)),
containerd.WithImageHandler(h),
containerd.WithSchema1Conversion,
}
Expand Down