Upgrade k8s package verison (#5358)
* upgrade k8s package version Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> * Script upgrade and code formatting. Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
21
vendor/helm.sh/helm/v3/pkg/pusher/doc.go
vendored
Normal file
21
vendor/helm.sh/helm/v3/pkg/pusher/doc.go
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright The Helm 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 pusher provides a generalized tool for uploading data by scheme.
|
||||
This provides a method by which the plugin system can load arbitrary protocol
|
||||
handlers based upon a URL scheme.
|
||||
*/
|
||||
package pusher
|
||||
104
vendor/helm.sh/helm/v3/pkg/pusher/ocipusher.go
vendored
Normal file
104
vendor/helm.sh/helm/v3/pkg/pusher/ocipusher.go
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright The Helm 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 pusher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"helm.sh/helm/v3/pkg/chart/loader"
|
||||
"helm.sh/helm/v3/pkg/registry"
|
||||
)
|
||||
|
||||
// OCIPusher is the default OCI backend handler
|
||||
type OCIPusher struct {
|
||||
opts options
|
||||
}
|
||||
|
||||
// Push performs a Push from repo.Pusher.
|
||||
func (pusher *OCIPusher) Push(chartRef, href string, options ...Option) error {
|
||||
for _, opt := range options {
|
||||
opt(&pusher.opts)
|
||||
}
|
||||
return pusher.push(chartRef, href)
|
||||
}
|
||||
|
||||
func (pusher *OCIPusher) push(chartRef, href string) error {
|
||||
stat, err := os.Stat(chartRef)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return errors.Errorf("%s: no such file", chartRef)
|
||||
}
|
||||
return err
|
||||
}
|
||||
if stat.IsDir() {
|
||||
return errors.New("cannot push directory, must provide chart archive (.tgz)")
|
||||
}
|
||||
|
||||
meta, err := loader.Load(chartRef)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := pusher.opts.registryClient
|
||||
|
||||
chartBytes, err := ioutil.ReadFile(chartRef)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var pushOpts []registry.PushOption
|
||||
provRef := fmt.Sprintf("%s.prov", chartRef)
|
||||
if _, err := os.Stat(provRef); err == nil {
|
||||
provBytes, err := ioutil.ReadFile(provRef)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pushOpts = append(pushOpts, registry.PushOptProvData(provBytes))
|
||||
}
|
||||
|
||||
ref := fmt.Sprintf("%s:%s",
|
||||
path.Join(strings.TrimPrefix(href, fmt.Sprintf("%s://", registry.OCIScheme)), meta.Metadata.Name),
|
||||
meta.Metadata.Version)
|
||||
|
||||
_, err = client.Push(chartBytes, ref, pushOpts...)
|
||||
return err
|
||||
}
|
||||
|
||||
// NewOCIPusher constructs a valid OCI client as a Pusher
|
||||
func NewOCIPusher(ops ...Option) (Pusher, error) {
|
||||
registryClient, err := registry.NewClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := OCIPusher{
|
||||
opts: options{
|
||||
registryClient: registryClient,
|
||||
},
|
||||
}
|
||||
|
||||
for _, opt := range ops {
|
||||
opt(&client.opts)
|
||||
}
|
||||
|
||||
return &client, nil
|
||||
}
|
||||
95
vendor/helm.sh/helm/v3/pkg/pusher/pusher.go
vendored
Normal file
95
vendor/helm.sh/helm/v3/pkg/pusher/pusher.go
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright The Helm 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 pusher
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"helm.sh/helm/v3/pkg/cli"
|
||||
"helm.sh/helm/v3/pkg/registry"
|
||||
)
|
||||
|
||||
// options are generic parameters to be provided to the pusher during instantiation.
|
||||
//
|
||||
// Pushers may or may not ignore these parameters as they are passed in.
|
||||
type options struct {
|
||||
registryClient *registry.Client
|
||||
}
|
||||
|
||||
// Option allows specifying various settings configurable by the user for overriding the defaults
|
||||
// used when performing Push operations with the Pusher.
|
||||
type Option func(*options)
|
||||
|
||||
// WithRegistryClient sets the registryClient option.
|
||||
func WithRegistryClient(client *registry.Client) Option {
|
||||
return func(opts *options) {
|
||||
opts.registryClient = client
|
||||
}
|
||||
}
|
||||
|
||||
// Pusher is an interface to support upload to the specified URL.
|
||||
type Pusher interface {
|
||||
// Push file content by url string
|
||||
Push(chartRef, url string, options ...Option) error
|
||||
}
|
||||
|
||||
// Constructor is the function for every pusher which creates a specific instance
|
||||
// according to the configuration
|
||||
type Constructor func(options ...Option) (Pusher, error)
|
||||
|
||||
// Provider represents any pusher and the schemes that it supports.
|
||||
type Provider struct {
|
||||
Schemes []string
|
||||
New Constructor
|
||||
}
|
||||
|
||||
// Provides returns true if the given scheme is supported by this Provider.
|
||||
func (p Provider) Provides(scheme string) bool {
|
||||
for _, i := range p.Schemes {
|
||||
if i == scheme {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Providers is a collection of Provider objects.
|
||||
type Providers []Provider
|
||||
|
||||
// ByScheme returns a Provider that handles the given scheme.
|
||||
//
|
||||
// If no provider handles this scheme, this will return an error.
|
||||
func (p Providers) ByScheme(scheme string) (Pusher, error) {
|
||||
for _, pp := range p {
|
||||
if pp.Provides(scheme) {
|
||||
return pp.New()
|
||||
}
|
||||
}
|
||||
return nil, errors.Errorf("scheme %q not supported", scheme)
|
||||
}
|
||||
|
||||
var ociProvider = Provider{
|
||||
Schemes: []string{registry.OCIScheme},
|
||||
New: NewOCIPusher,
|
||||
}
|
||||
|
||||
// All finds all of the registered pushers as a list of Provider instances.
|
||||
// Currently, just the built-in pushers are collected.
|
||||
func All(settings *cli.EnvSettings) Providers {
|
||||
result := Providers{ociProvider}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user