Skip to content

Commit

Permalink
Merge pull request #967 from 24sama/v2.0.0
Browse files Browse the repository at this point in the history
artifact supports pulling images with skipping SSL certificate validation
  • Loading branch information
ks-ci-bot committed Jan 10, 2022
2 parents 7056710 + a1f51ad commit 79ff215
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/artifact/containerd.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 79ff215

Please sign in to comment.