diff --git a/pkg/cnab/cnab-to-oci/registry.go b/pkg/cnab/cnab-to-oci/registry.go index b25f7bce5..d15e97bc8 100644 --- a/pkg/cnab/cnab-to-oci/registry.go +++ b/pkg/cnab/cnab-to-oci/registry.go @@ -17,8 +17,8 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/pkg/jsonmessage" - "github.com/docker/docker/pkg/term" "github.com/google/go-containerregistry/pkg/crane" + "github.com/moby/term" "github.com/opencontainers/go-digest" ) diff --git a/pkg/cnab/provider/runtime.go b/pkg/cnab/provider/runtime.go index e26a5f993..5e8557c71 100644 --- a/pkg/cnab/provider/runtime.go +++ b/pkg/cnab/provider/runtime.go @@ -13,7 +13,8 @@ var _ CNABProvider = &Runtime{} type Runtime struct { *config.Config - credentials storage.CredentialSetProvider + credentials storage.CredentialSetProvider + //lint:ignore U1000 unused at the moment, will be used in the future parameters storage.ParameterSetProvider secrets secrets.Store installations storage.InstallationProvider diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 90200713e..958c6e19b 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -48,6 +48,7 @@ func LoadFromViper(viperCfg func(v *viper.Viper)) DataStoreLoaderFunc { return func(ctx context.Context, cfg *Config, templateData map[string]interface{}) error { home, _ := cfg.GetHomeDir() + //lint:ignore SA4006 ignore unused context for now ctx, log := tracing.StartSpanWithName(ctx, "LoadFromViper", attribute.String("porter.PORTER_HOME", home)) defer log.EndSpan() diff --git a/pkg/plugins/pluggable/loader.go b/pkg/plugins/pluggable/loader.go index 5d5950d60..29a4b04ed 100644 --- a/pkg/plugins/pluggable/loader.go +++ b/pkg/plugins/pluggable/loader.go @@ -88,6 +88,7 @@ func (l *PluginLoader) Load(ctx context.Context, pluginType PluginTypeConfig) (* // selectPlugin picks the plugin to use and loads its configuration. func (l *PluginLoader) selectPlugin(ctx context.Context, cfg PluginTypeConfig) error { + //lint:ignore SA4006 ignore unused ctx for now. ctx, span := tracing.StartSpan(ctx) defer span.EndSpan() diff --git a/pkg/porter/helpers.go b/pkg/porter/helpers.go index f97cb4425..ec1a9af19 100644 --- a/pkg/porter/helpers.go +++ b/pkg/porter/helpers.go @@ -235,7 +235,6 @@ func (p *TestPorter) CompareGoldenFile(goldenFile string, got string) { // CreateInstallation saves an installation record into claim store and store // sensitive parameters into secret store. func (p *TestPorter) SanitizeParameters(raw []secrets.Strategy, recordID string, bun cnab.ExtendedBundle) []secrets.Strategy { - strategies := make([]secrets.Strategy, 0, len(raw)) strategies, err := p.Sanitizer.CleanParameters(context.Background(), raw, bun, recordID) require.NoError(p.T(), err) diff --git a/pkg/porter/lifecycle_integration_test.go b/pkg/porter/lifecycle_integration_test.go index 2a3a91e32..b6ceb8c1b 100644 --- a/pkg/porter/lifecycle_integration_test.go +++ b/pkg/porter/lifecycle_integration_test.go @@ -15,6 +15,10 @@ import ( "github.com/stretchr/testify/require" ) +var ( + kahnlatestHash = "fd4bbe38665531d10bb653140842a370" +) + func TestResolveBundleReference(t *testing.T) { t.Parallel() t.Run("current bundle source", func(t *testing.T) { diff --git a/pkg/porter/lifecycle_test.go b/pkg/porter/lifecycle_test.go index c763d3e97..8610d348d 100644 --- a/pkg/porter/lifecycle_test.go +++ b/pkg/porter/lifecycle_test.go @@ -14,10 +14,7 @@ import ( ) var ( - kahn1dot0Hash = "887e7e65e39277f8744bd00278760b06" - kahn1dot01 = cnab.MustParseOCIReference("deislabs/kubekahn:1.0") - kahnlatestHash = "fd4bbe38665531d10bb653140842a370" - kahnlatest = cnab.MustParseOCIReference("deislabs/kubekahn:latest") + kahnlatest = cnab.MustParseOCIReference("deislabs/kubekahn:latest") ) func TestInstallFromTagIgnoresCurrentBundle(t *testing.T) { diff --git a/pkg/porter/parameters.go b/pkg/porter/parameters.go index c3309f529..efd6789c6 100644 --- a/pkg/porter/parameters.go +++ b/pkg/porter/parameters.go @@ -397,16 +397,6 @@ func (p *Porter) loadParameterSets(ctx context.Context, bun cnab.ExtendedBundle, return resolvedParameters, nil } -func (p *Porter) loadParameterFromFile(path string) (storage.ParameterSet, error) { - var cs storage.ParameterSet - err := encoding.UnmarshalFile(p.FileSystem, path, &cs) - if err != nil { - return cs, fmt.Errorf("error loading parameter set in %s: %w", path, err) - } - - return cs, nil -} - type DisplayValue struct { Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` diff --git a/pkg/porter/stamp.go b/pkg/porter/stamp.go index 6017695c1..527a85d8b 100644 --- a/pkg/porter/stamp.go +++ b/pkg/porter/stamp.go @@ -82,7 +82,7 @@ func (p *Porter) IsBundleUpToDate(ctx context.Context, opts bundleFileOptions) ( if !isImageCached { if p.Debug { - fmt.Fprintln(p.Err, errors.New(fmt.Sprintf("Invocation image %s doesn't exist in the local image cache, will need to build first", invocationImage.Image))) + fmt.Fprintln(p.Err, fmt.Errorf("Invocation image %s doesn't exist in the local image cache, will need to build first", invocationImage.Image)) } return false, nil } diff --git a/pkg/porter/upgrade.go b/pkg/porter/upgrade.go index b4f977458..2e97e2ccf 100644 --- a/pkg/porter/upgrade.go +++ b/pkg/porter/upgrade.go @@ -35,6 +35,7 @@ func (o UpgradeOptions) Validate(ctx context.Context, args []string, p *Porter) if err != nil { return errors.New("invalid bundle version --version. Must be a semantic version, for example 1.2.3") } + //lint:ignore SA4005 the bundle options are validated below, so ignore ineffective assignment warning o.Version = v.String() } diff --git a/pkg/runtime/runtime-manifest.go b/pkg/runtime/runtime-manifest.go index 9b7649e52..82830aa97 100644 --- a/pkg/runtime/runtime-manifest.go +++ b/pkg/runtime/runtime-manifest.go @@ -216,6 +216,7 @@ func (m *RuntimeManifest) ApplyStepOutputs(assignments map[string]string) error type StepOutput struct { // The final value of the output returned by the mixin after executing + //lint:ignore U1000 ignore unused warning value string Name string `yaml:"name"` diff --git a/pkg/runtime/runtime-manifest_test.go b/pkg/runtime/runtime-manifest_test.go index 57f30357c..4b8aa0639 100644 --- a/pkg/runtime/runtime-manifest_test.go +++ b/pkg/runtime/runtime-manifest_test.go @@ -409,7 +409,7 @@ func TestResolveInMainDict(t *testing.T) { t.Logf("install data %v", installStep.Data) exec := installStep.Data["exec"].(map[string]interface{}) assert.NotNil(t, exec) - command := exec["command"].(interface{}) + command := exec["command"] assert.NotNil(t, command) cmdVal, ok := command.(string) assert.True(t, ok) diff --git a/pkg/secrets/plugins/filesystem/store.go b/pkg/secrets/plugins/filesystem/store.go index a6cfb5709..4acda29eb 100644 --- a/pkg/secrets/plugins/filesystem/store.go +++ b/pkg/secrets/plugins/filesystem/store.go @@ -48,6 +48,7 @@ func (s *Store) Connect(ctx context.Context) error { return nil } + //lint:ignore SA4006 ignore unused ctx for now ctx, log := tracing.StartSpan(ctx) defer log.EndSpan() diff --git a/pkg/storage/installation_store_test.go b/pkg/storage/installation_store_test.go index 58b4c8f88..0caa2306c 100644 --- a/pkg/storage/installation_store_test.go +++ b/pkg/storage/installation_store_test.go @@ -2,7 +2,6 @@ package storage import ( "context" - "encoding/base64" "testing" "get.porter.sh/porter/pkg/cnab" @@ -15,18 +14,6 @@ import ( var _ InstallationProvider = InstallationStore{} -var b64encode = func(src []byte) ([]byte, error) { - dst := make([]byte, base64.StdEncoding.EncodedLen(len(src))) - base64.StdEncoding.Encode(dst, src) - return dst, nil -} - -var b64decode = func(src []byte) ([]byte, error) { - dst := make([]byte, base64.StdEncoding.DecodedLen(len(src))) - n, err := base64.StdEncoding.Decode(dst, src) - return dst[:n], err -} - var exampleBundle = bundle.Bundle{ SchemaVersion: "schemaVersion", Name: "mybun", diff --git a/pkg/storage/migrations/manager.go b/pkg/storage/migrations/manager.go index c87fc0368..dfe6d62f3 100644 --- a/pkg/storage/migrations/manager.go +++ b/pkg/storage/migrations/manager.go @@ -369,6 +369,7 @@ func (m *Manager) migrateParameters(w io.Writer) error { } // getSchemaVersion attempts to read the schemaVersion stamped on a document. +//lint:ignore U1000 ignore unused function warning func getSchemaVersion(data []byte) string { var peek struct { SchemaVersion schema.Version `json:"schemaVersion"` diff --git a/pkg/storage/parameter_store_test.go b/pkg/storage/parameter_store_test.go index 055390a64..d91f39084 100644 --- a/pkg/storage/parameter_store_test.go +++ b/pkg/storage/parameter_store_test.go @@ -83,10 +83,10 @@ func TestParameterStore_CRUD(t *testing.T) { require.NoError(t, err) require.Empty(t, params, "List should return no entries") - pset, err = paramStore.GetParameterSet(ctx, "", myParamSet.Name) + _, err = paramStore.GetParameterSet(ctx, "", myParamSet.Name) require.ErrorIs(t, err, ErrNotFound{}) - pset, err = paramStore.GetParameterSet(ctx, "", myParamSet2.Name) + _, err = paramStore.GetParameterSet(ctx, "", myParamSet2.Name) require.ErrorIs(t, err, ErrNotFound{}) } diff --git a/pkg/storage/plugins/mongodb/mongodb.go b/pkg/storage/plugins/mongodb/mongodb.go index 441ed0ddb..5f0700fbe 100644 --- a/pkg/storage/plugins/mongodb/mongodb.go +++ b/pkg/storage/plugins/mongodb/mongodb.go @@ -145,7 +145,6 @@ func (s *Store) EnsureIndex(ctx context.Context, opts plugins.EnsureIndexOptions Options: options.Index(), } model.Options.SetUnique(index.Unique) - model.Options.SetBackground(true) c, ok := indices[index.Collection] if !ok { diff --git a/pkg/test/logger.go b/pkg/test/logger.go index b394f8633..0908f4377 100644 --- a/pkg/test/logger.go +++ b/pkg/test/logger.go @@ -9,6 +9,7 @@ type Logger struct { func (l Logger) Write(p []byte) (n int, err error) { defer func() { + //lint:ignore SA9003 ignore empty branch if err := recover(); err != nil { // ignore logs written after the test is complete, don't panic } diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 000000000..c03047de4 --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1,4 @@ +# Default Config +checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023", "-ST1005"] +initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] +http_status_code_whitelist = ["200", "400", "404", "500"] diff --git a/tests/tester/helpers.go b/tests/tester/helpers.go index 6b264dc36..8b8e36fc8 100644 --- a/tests/tester/helpers.go +++ b/tests/tester/helpers.go @@ -15,8 +15,6 @@ import ( "github.com/stretchr/testify/require" ) -var testBundleBuilt = false - // PrepareTestBundle ensures that the mybuns test bundle has been built. func (t Tester) PrepareTestBundle() { // These are environment variables referenced by the mybuns credential set