mirror of
https://github.com/helm/helm.git
synced 2026-04-15 21:59:50 -04:00
chore: fix various warnings to reduce noise
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
This commit is contained in:
parent
490dffeb34
commit
0f6e14dfd3
11 changed files with 40 additions and 39 deletions
|
|
@ -236,12 +236,12 @@ func TestGenerateOCICreatedAnnotations(t *testing.T) {
|
|||
nowTime := time.Now()
|
||||
nowTimeString := nowTime.Format(time.RFC3339)
|
||||
|
||||
chart := &chart.Metadata{
|
||||
testChart := &chart.Metadata{
|
||||
Name: "oci",
|
||||
Version: "0.0.1",
|
||||
}
|
||||
|
||||
result := generateOCIAnnotations(chart, nowTimeString)
|
||||
result := generateOCIAnnotations(testChart, nowTimeString)
|
||||
|
||||
// Check that created annotation exists
|
||||
if _, ok := result[ocispec.AnnotationCreated]; !ok {
|
||||
|
|
@ -254,7 +254,7 @@ func TestGenerateOCICreatedAnnotations(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify default creation time set
|
||||
result = generateOCIAnnotations(chart, "")
|
||||
result = generateOCIAnnotations(testChart, "")
|
||||
|
||||
// Check that created annotation exists
|
||||
if _, ok := result[ocispec.AnnotationCreated]; !ok {
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ func (c *Client) Login(host string, options ...LoginOption) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintln(c.out, "Login Succeeded")
|
||||
_, _ = fmt.Fprintln(c.out, "Login Succeeded")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ func (c *Client) Logout(host string, opts ...LogoutOption) error {
|
|||
if err := credentials.Logout(context.Background(), c.credentialsStore, host); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(c.out, "Removing login credentials for %s\n", host)
|
||||
_, _ = fmt.Fprintf(c.out, "Removing login credentials for %s\n", host)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +453,7 @@ func (c *Client) processChartPull(genericResult *GenericPullResult, operation *p
|
|||
provDescriptor = &d
|
||||
case LegacyChartLayerMediaType:
|
||||
chartDescriptor = &d
|
||||
fmt.Fprintf(c.out, "Warning: chart media type %s is deprecated\n", LegacyChartLayerMediaType)
|
||||
_, _ = fmt.Fprintf(c.out, "Warning: chart media type %s is deprecated\n", LegacyChartLayerMediaType)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -526,12 +526,12 @@ func (c *Client) processChartPull(genericResult *GenericPullResult, operation *p
|
|||
result.Prov.Size = provDescriptor.Size
|
||||
}
|
||||
|
||||
fmt.Fprintf(c.out, "Pulled: %s\n", result.Ref)
|
||||
fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
_, _ = fmt.Fprintf(c.out, "Pulled: %s\n", result.Ref)
|
||||
_, _ = fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
|
||||
if strings.Contains(result.Ref, "_") {
|
||||
fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
_, _ = fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
_, _ = fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
@ -728,11 +728,11 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu
|
|||
Size: provDescriptor.Size,
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(c.out, "Pushed: %s\n", result.Ref)
|
||||
fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
_, _ = fmt.Fprintf(c.out, "Pushed: %s\n", result.Ref)
|
||||
_, _ = fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
if strings.Contains(parsedRef.orasReference.Reference, "_") {
|
||||
fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
_, _ = fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
_, _ = fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
}
|
||||
|
||||
return result, err
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func (suite *HTTPRegistryClientTestSuite) SetupSuite() {
|
|||
|
||||
func (suite *HTTPRegistryClientTestSuite) TearDownSuite() {
|
||||
teardown(&suite.TestRegistry)
|
||||
os.RemoveAll(suite.WorkspaceDir)
|
||||
_ = os.RemoveAll(suite.WorkspaceDir)
|
||||
}
|
||||
|
||||
func (suite *HTTPRegistryClientTestSuite) Test_0_Login() {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (suite *InsecureTLSRegistryClientTestSuite) SetupSuite() {
|
|||
|
||||
func (suite *InsecureTLSRegistryClientTestSuite) TearDownSuite() {
|
||||
teardown(&suite.TestRegistry)
|
||||
os.RemoveAll(suite.WorkspaceDir)
|
||||
_ = os.RemoveAll(suite.WorkspaceDir)
|
||||
}
|
||||
|
||||
func (suite *InsecureTLSRegistryClientTestSuite) Test_0_Login() {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func (suite *TLSRegistryClientTestSuite) SetupSuite() {
|
|||
|
||||
func (suite *TLSRegistryClientTestSuite) TearDownSuite() {
|
||||
teardown(&suite.TestRegistry)
|
||||
os.RemoveAll(suite.WorkspaceDir)
|
||||
_ = os.RemoveAll(suite.WorkspaceDir)
|
||||
}
|
||||
|
||||
func (suite *TLSRegistryClientTestSuite) Test_0_Login() {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func (c *GenericClient) PullGeneric(ref string, options GenericPullOptions) (*Ge
|
|||
memoryStore := memory.New()
|
||||
var descriptors []ocispec.Descriptor
|
||||
|
||||
// Set up repository with authentication and configuration
|
||||
// Set up a repository with authentication and configuration
|
||||
repository, err := remote.NewRepository(parsedRef.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -114,7 +114,7 @@ func (c *GenericClient) PullGeneric(ref string, options GenericPullOptions) (*Ge
|
|||
manifest, err := oras.Copy(ctx, repository, parsedRef.String(), memoryStore, "", oras.CopyOptions{
|
||||
CopyGraphOptions: oras.CopyGraphOptions{
|
||||
PreCopy: func(ctx context.Context, desc ocispec.Descriptor) error {
|
||||
// Apply custom PreCopy function if provided
|
||||
// Apply a custom PreCopy function if provided
|
||||
if options.PreCopy != nil {
|
||||
if err := options.PreCopy(ctx, desc); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -147,15 +147,15 @@ func (c *Client) processPluginPull(genericResult *GenericPullResult, pluginName
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(c.out, "Pulled plugin: %s\n", result.Ref)
|
||||
fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
_, _ = fmt.Fprintf(c.out, "Pulled plugin: %s\n", result.Ref)
|
||||
_, _ = fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest)
|
||||
if result.Prov.Data != nil {
|
||||
fmt.Fprintf(c.out, "Provenance: %s\n", foundProvenanceName)
|
||||
_, _ = fmt.Fprintf(c.out, "Provenance: %s\n", foundProvenanceName)
|
||||
}
|
||||
|
||||
if strings.Contains(result.Ref, "_") {
|
||||
fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
_, _ = fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref)
|
||||
_, _ = fmt.Fprint(c.out, registryUnderscoreMessage+"\n")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ type reference struct {
|
|||
}
|
||||
|
||||
// newReference will parse and validate the reference, and clean tags when
|
||||
// applicable tags are only cleaned when plus (+) signs are present, and are
|
||||
// applicable tags are only cleaned when plus (+) signs are present and are
|
||||
// converted to underscores (_) before pushing
|
||||
// See https://github.com/helm/helm/issues/10166
|
||||
func newReference(raw string) (result reference, err error) {
|
||||
// Remove oci:// prefix if it is there
|
||||
// Remove the oci:// prefix if it is there
|
||||
raw = strings.TrimPrefix(raw, OCIScheme+"://")
|
||||
|
||||
// The sole possible reference modification is replacing plus (+) signs
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/distribution/distribution/v3/registry"
|
||||
_ "github.com/distribution/distribution/v3/registry/auth/htpasswd"
|
||||
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
|
|
@ -68,13 +69,13 @@ type TestRegistry struct {
|
|||
|
||||
func setup(suite *TestRegistry, tlsEnabled, insecure bool) {
|
||||
suite.WorkspaceDir = testWorkspaceDir
|
||||
os.RemoveAll(suite.WorkspaceDir)
|
||||
os.Mkdir(suite.WorkspaceDir, 0700)
|
||||
err := os.RemoveAll(suite.WorkspaceDir)
|
||||
require.NoError(suite.T(), err, "no error removing test workspace dir")
|
||||
err = os.Mkdir(suite.WorkspaceDir, 0700)
|
||||
require.NoError(suite.T(), err, "no error creating test workspace dir")
|
||||
|
||||
var out bytes.Buffer
|
||||
|
||||
var (
|
||||
out bytes.Buffer
|
||||
err error
|
||||
)
|
||||
suite.Out = &out
|
||||
credentialsFile := filepath.Join(suite.WorkspaceDir, CredentialsFileBasename)
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ func setup(suite *TestRegistry, tlsEnabled, insecure bool) {
|
|||
config := &configuration.Configuration{}
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
suite.Nil(err, "no error finding free port for test registry")
|
||||
defer ln.Close()
|
||||
defer func() { _ = ln.Close() }()
|
||||
|
||||
// Change the registry host to another host which is not localhost.
|
||||
// This is required because Docker enforces HTTP if the registry
|
||||
|
|
@ -176,7 +177,7 @@ func initCompromisedRegistryTestServer() string {
|
|||
w.Header().Set("Content-Type", "application/vnd.oci.image.manifest.v1+json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `{ "schemaVersion": 2, "config": {
|
||||
_, _ = fmt.Fprintf(w, `{ "schemaVersion": 2, "config": {
|
||||
"mediaType": "%s",
|
||||
"digest": "sha256:a705ee2789ab50a5ba20930f246dbd5cc01ff9712825bb98f57ee8414377f133",
|
||||
"size": 181
|
||||
|
|
@ -192,13 +193,13 @@ func initCompromisedRegistryTestServer() string {
|
|||
} else if r.URL.Path == "/v2/testrepo/supposedlysafechart/blobs/sha256:a705ee2789ab50a5ba20930f246dbd5cc01ff9712825bb98f57ee8414377f133" {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("{\"name\":\"mychart\",\"version\":\"0.1.0\",\"description\":\"A Helm chart for Kubernetes\\n" +
|
||||
_, _ = w.Write([]byte("{\"name\":\"mychart\",\"version\":\"0.1.0\",\"description\":\"A Helm chart for Kubernetes\\n" +
|
||||
"an 'application' or a 'library' chart.\",\"apiVersion\":\"v2\",\"appVersion\":\"1.16.0\",\"type\":" +
|
||||
"\"application\"}"))
|
||||
} else if r.URL.Path == "/v2/testrepo/supposedlysafechart/blobs/sha256:ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb" {
|
||||
w.Header().Set("Content-Type", ChartLayerMediaType)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("b"))
|
||||
_, _ = w.Write([]byte("b"))
|
||||
} else {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import (
|
|||
func GetTagMatchingVersionOrConstraint(tags []string, versionString string) (string, error) {
|
||||
var constraint *semver.Constraints
|
||||
if versionString == "" {
|
||||
// If string is empty, set wildcard constraint
|
||||
// If the string is empty, set a wildcard constraint
|
||||
constraint, _ = semver.NewConstraint("*")
|
||||
} else {
|
||||
// when customer inputs specific version, check whether there's an exact match first
|
||||
// when customer inputs a specific version, check whether there's an exact match first
|
||||
for _, v := range tags {
|
||||
if versionString == v {
|
||||
return v, nil
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func (t *LoggingTransport) RoundTrip(req *http.Request) (resp *http.Response, er
|
|||
// logHeader prints out the provided header keys and values, with auth header scrubbed.
|
||||
func logHeader(header http.Header) string {
|
||||
if len(header) > 0 {
|
||||
headers := []string{}
|
||||
var headers []string
|
||||
for k, v := range header {
|
||||
for _, h := range toScrub {
|
||||
if strings.EqualFold(k, h) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue