Repository: kurtosis-tech/kurtosis
Pull request #1003 (2023-07-27 15:23:00)

chore: Enable staticcheck linter
## Description:
<!-- Describe this change, how it works, and the motivation behind it. -->
This PR enables the Golint with https://staticcheck.dev/docs/checks/

This linter will catch an amazing range of bugs or possible future bugs, like:
- Unchecked error
- Misuses of stdlib
- Misuse of contexts
- Use of deprecated stdlib functions

## Is this change user facing?
NO
<!-- If yes, please add the "user facing" label to the PR -->
<!-- If yes, don't forget to include docs changes where relevant -->

## References (if applicable):
<!-- Add relevant Github Issues, Discord threads, or other helpful information. -->


h4ck3rk3y: @victorcolombo will review when this isn't a draft 

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 7c60d1aed..d76076a47 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,7 +1,5 @@
 linters:
   enable:
-    - exhaustruct
-  disable:
-    - staticcheck # TODO(vcolombo): Remove this
+    - staticcheck
   max-issues-per-linter: 0
   sort-results: true
diff --git a/api/golang/core/lib/enclaves/kurtosis_yaml.go b/api/golang/core/lib/enclaves/kurtosis_yaml.go
index 5d7ac94d4..5f984cef1 100644
--- a/api/golang/core/lib/enclaves/kurtosis_yaml.go
+++ b/api/golang/core/lib/enclaves/kurtosis_yaml.go
@@ -3,7 +3,6 @@ package enclaves
 import (
 	"github.com/go-yaml/yaml"
 	"github.com/kurtosis-tech/stacktrace"
-	"io/ioutil"
 	"os"
 )
 
@@ -17,7 +16,7 @@ type KurtosisYaml struct {
 }
 
 func ParseKurtosisYaml(kurtosisYamlFilepath string) (*KurtosisYaml, error) {
-	kurtosisYamlContents, err := ioutil.ReadFile(kurtosisYamlFilepath)
+	kurtosisYamlContents, err := os.ReadFile(kurtosisYamlFilepath)
 	if err != nil {
 		if os.IsNotExist(err) {
 			return nil, stacktrace.NewError("Couldn't find a '%v' in the root of the package at '%v'. Packages are expected to have a '%v' at root; have a look at '%v' for more", kurtosisYamlFilename, kurtosisYamlFilepath, kurtosisYamlFilename, packagesUrl)
diff --git a/cli/cli/command_framework/highlevel/engine_consuming_kurtosis_command/engine_consuming_kurtosis_command.go b/cli/cli/command_framework/highlevel/engine_consuming_kurtosis_command/engine_consuming_kurtosis_command.go
index c0d89155e..923c913b3 100644
--- a/cli/cli/command_framework/highlevel/engine_consuming_kurtosis_command/engine_consuming_kurtosis_command.go
+++ b/cli/cli/command_framework/highlevel/engine_consuming_kurtosis_command/engine_consuming_kurtosis_command.go
@@ -21,10 +21,12 @@ import (
 	"github.com/spf13/cobra"
 )
 
+type EngineContextKey string
+
 const (
-	engineClientCloseFuncCtxKey     = "engine-client-close-func"
-	metricsClientKey                = "metrics-client-key"
-	metricsClientClosingFunctionKey = "metrics-client-closing-func"
+	engineClientCloseFuncCtxKey     EngineContextKey = "engine-client-close-func"
+	metricsClientKey                EngineContextKey = "metrics-client-key"
+	metricsClientClosingFunctionKey EngineContextKey = "metrics-client-closing-func"
 )
 
 // This is a convenience KurtosisCommand for commands that interact with the engine
@@ -38,14 +40,14 @@ type EngineConsumingKurtosisCommand struct {
 	LongDescription string
 
 	// The name of the key that will be set during PreValidationAndRun where the KurtosisBackend can be found
-	KurtosisBackendContextKey string
+	KurtosisBackendContextKey EngineContextKey
 
 	// TODO Replace with KurtosisContext!!! This will:
 	//  1) be easier to work with and
 	//  2) force us to use the same SDK we give to users, so there's no "secret" or "private" API, which will force
 	//     us to improve the SDK
 	// The name of the key that will be set during PreValidationAndRun where the engine client will be made available
-	EngineClientContextKey string
+	EngineClientContextKey EngineContextKey
 
 	// Order isn't important here
 	Flags []*flags.FlagConfig
diff --git a/cli/cli/command_framework/lowlevel/args/parsed_args.go b/cli/cli/command_framework/lowlevel/args/parsed_args.go
index 8d9f3ec70..7cf352dc6 100644
--- a/cli/cli/command_framework/lowlevel/args/parsed_args.go
+++ b/cli/cli/command_framework/lowlevel/args/parsed_args.go
@@ -34,7 +34,6 @@ func ParseArgsForCompletion(argConfigs []*ArgConfig, input []string) (*ParsedArg
 		// Greedy case (arg must always be last)
 		if config.IsGreedy {
 			greedyArgValues[key] = input[inputIdx:]
-			inputIdx += len(input) - inputIdx
 			nextArg = config // Greedy args must always be at the end, so they'll be infinitely-completable
 			break
 		}
@@ -93,7 +92,6 @@ func ParseArgsForValidation(argConfigs []*ArgConfig, input []string) (*ParsedArg
 		// Greedy case (arg must always be last)
 		if config.IsGreedy {
 			greedyArgValues[key] = input[inputIdx:]
-			inputIdx += len(input) - inputIdx
 			break
 		}
 
diff --git a/cli/cli/commands/enclave/inspect/user_services.go b/cli/cli/commands/enclave/inspect/user_services.go
index acdcc3ad4..2a0fee9d1 100644
--- a/cli/cli/commands/enclave/inspect/user_services.go
+++ b/cli/cli/commands/enclave/inspect/user_services.go
@@ -143,7 +143,7 @@ func getUserServicePortBindingStrings(userService *service.Service,
 	maybePublicPortMapFromAPIC map[string]*kurtosis_core_rpc_api_bindings.Port,
 	maybePublicIpAddrFromAPIC string) ([]string, error) {
 	privatePorts := userService.GetPrivatePorts()
-	if privatePorts == nil || len(privatePorts) == 0 {
+	if len(privatePorts) == 0 {
 		return []string{missingPortPlaceholder}, nil
 	}
 
diff --git a/cli/cli/commands/root.go b/cli/cli/commands/root.go
index e6eb8a091..1f37d1af4 100644
--- a/cli/cli/commands/root.go
+++ b/cli/cli/commands/root.go
@@ -44,7 +44,6 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/spf13/pflag"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"os"
 	"strings"
@@ -303,7 +302,7 @@ func getLatestCLIReleaseVersionFromGitHub() (string, error) {
 		}
 	}()
 
-	bodyBytes, err := ioutil.ReadAll(response.Body)
+	bodyBytes, err := io.ReadAll(response.Body)
 	if err != nil {
 		return "", stacktrace.Propagate(err, "An error occurred reading the HTTP response body")
 	}
@@ -328,7 +327,7 @@ func saveLatestCLIReleaseVersionInCacheFile(filepath, latestReleaseVersion strin
 	fileContent := []byte(content)
 
 	logrus.Debugf("Saving content '%v' in cache file...", content)
-	if err := ioutil.WriteFile(filepath, fileContent, getLatestCLIReleaseCacheFilePermissions); err != nil {
+	if err := os.WriteFile(filepath, fileContent, getLatestCLIReleaseCacheFilePermissions); err != nil {
 		return stacktrace.Propagate(err, "An error occurred saving content '%v' in latest release version cache file", content)
 	}
 	logrus.Debugf("Content successfully saved in cache file")
@@ -351,7 +350,7 @@ func getLatestCLIReleaseVersionFromCacheFile(filepath string) (string, error) {
 		}
 	}()
 
-	fileContentBytes, err := ioutil.ReadAll(cacheFile)
+	fileContentBytes, err := io.ReadAll(cacheFile)
 	if err != nil {
 		return "", stacktrace.Propagate(err, "An error occurred reading cache file")
 	}
diff --git a/cli/cli/helpers/metrics_user_id_store/metrics_user_id_store.go b/cli/cli/helpers/metrics_user_id_store/metrics_user_id_store.go
index e9c50ac40..a64d801df 100644
--- a/cli/cli/helpers/metrics_user_id_store/metrics_user_id_store.go
+++ b/cli/cli/helpers/metrics_user_id_store/metrics_user_id_store.go
@@ -5,7 +5,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/cli/cli/helpers/host_machine_directories"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
-	"io/ioutil"
 	"os"
 	"sync"
 )
@@ -97,7 +96,7 @@ func (store *MetricsUserIDStore) getMetricsUserIDFromFile() (string, error) {
 	}
 	logrus.Debugf("Metrics user id filepath: '%v'", filepath)
 
-	fileContentBytes, err := ioutil.ReadFile(filepath)
+	fileContentBytes, err := os.ReadFile(filepath)
 	if err != nil {
 		return "", stacktrace.Propagate(err, "An error occurred reading metrics user id file")
 	}
@@ -118,7 +117,7 @@ func (store *MetricsUserIDStore) saveMetricsUserIdFile(metricsUserId string) err
 		return stacktrace.Propagate(err, "An error occurred getting the metrics user id filepath")
 	}
 
-	err = ioutil.WriteFile(filepath, fileContent, metricsUserIDFilePermissions)
+	err = os.WriteFile(filepath, fileContent, metricsUserIDFilePermissions)
 	if err != nil {
 		return stacktrace.Propagate(err, "An error occurred writing metrics user id file '%v'", filepath)
 	}
diff --git a/cli/cli/helpers/user_send_metrics_election/user_metrics_election_event_backlog/user_metrics_election_event_backlog.go b/cli/cli/helpers/user_send_metrics_election/user_metrics_election_event_backlog/user_metrics_election_event_backlog.go
index a1122b9a0..2b944a8ff 100644
--- a/cli/cli/helpers/user_send_metrics_election/user_metrics_election_event_backlog/user_metrics_election_event_backlog.go
+++ b/cli/cli/helpers/user_send_metrics_election/user_metrics_election_event_backlog/user_metrics_election_event_backlog.go
@@ -4,7 +4,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/cli/cli/helpers/host_machine_directories"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
-	"io/ioutil"
 	"os"
 	"strconv"
 	"sync"
@@ -48,7 +47,7 @@ func (eventBacklog *userMetricsElectionEventBacklog) Set(shouldSendMetrics bool)
 		logrus.Debugf("An error occurred getting the user-send-metrics-election filepath\n%v", err)
 	}
 
-	if err := ioutil.WriteFile(filepath, fileContent, filePermissions); err != nil {
+	if err := os.WriteFile(filepath, fileContent, filePermissions); err != nil {
 		return stacktrace.Propagate(err, "An error occurred writing file '%v'", filepath)
 	}
 
@@ -65,7 +64,7 @@ func (eventBacklog *userMetricsElectionEventBacklog) Get() (shouldSendMetrics bo
 		logrus.Debugf("An error occurred getting the user-send-metrics-election filepath\n%v", err)
 	}
 
-	fileContent, err := ioutil.ReadFile(filepath)
+	fileContent, err := os.ReadFile(filepath)
 	if err != nil {
 		if os.IsNotExist(err) {
 			return false, false, nil
diff --git a/cli/cli/kurtosis_cluster_setting/kurtosis_cluster_setting_store.go b/cli/cli/kurtosis_cluster_setting/kurtosis_cluster_setting_store.go
index 16b853809..db66dd170 100644
--- a/cli/cli/kurtosis_cluster_setting/kurtosis_cluster_setting_store.go
+++ b/cli/cli/kurtosis_cluster_setting/kurtosis_cluster_setting_store.go
@@ -4,7 +4,6 @@ import (
 	"github.com/kurtosis-tech/kurtosis/cli/cli/helpers/host_machine_directories"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
-	"io/ioutil"
 	"os"
 	"sync"
 )
@@ -86,7 +85,7 @@ func (settingStore *kurtosisClusterSettingStore) getClusterSettingFromFile() (st
 	}
 	logrus.Debugf("Cluster setting filepath: '%v'", filepath)
 
-	fileContentBytes, err := ioutil.ReadFile(filepath)
+	fileContentBytes, err := os.ReadFile(filepath)
 	if err != nil {
 		return "", stacktrace.Propagate(err, "An error occurred reading cluster setting file")
 	}
@@ -106,7 +105,7 @@ func (settingStore *kurtosisClusterSettingStore) saveClusterSettingFile(clusterN
 		return stacktrace.Propagate(err, "An error occurred getting the cluster setting filepath")
 	}
 
-	err = ioutil.WriteFile(filepath, fileContent, kurtosisClusterSettingFilePermissions)
+	err = os.WriteFile(filepath, fileContent, kurtosisClusterSettingFilePermissions)
 	if err != nil {
 		return stacktrace.Propagate(err, "An error occurred writing cluster setting file '%v'", filepath)
 	}
diff --git a/cli/cli/kurtosis_config/kurtosis_config_store.go b/cli/cli/kurtosis_config/kurtosis_config_store.go
index 84f4cf6da..c4eb34687 100644
--- a/cli/cli/kurtosis_config/kurtosis_config_store.go
+++ b/cli/cli/kurtosis_config/kurtosis_config_store.go
@@ -9,7 +9,7 @@ import (
 	"github.com/kurtosis-tech/kurtosis/cli/cli/kurtosis_config/resolved_config"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
-	"io/ioutil"
+	"io"
 	"os"
 	"sync"
 )
@@ -109,7 +109,7 @@ func (configStore *kurtosisConfigStore) saveKurtosisConfigYAMLFile(kurtosisConfi
 		return stacktrace.Propagate(err, "An error occurred getting the Kurtosis config YAML filepath")
 	}
 
-	err = ioutil.WriteFile(kurtosisConfigYAMLFilepath, kurtosisConfigYAMLContent, kurtosisConfigFilePermissions)
+	err = os.WriteFile(kurtosisConfigYAMLFilepath, kurtosisConfigYAMLContent, kurtosisConfigFilePermissions)
 	if err != nil {
 		return stacktrace.Propagate(err, "An error occurred writing Kurtosis config YAML file '%v'", kurtosisConfigYAMLFilepath)
 	}
@@ -157,7 +157,7 @@ func (configStore *kurtosisConfigStore) readConfigFileBytes() ([]byte, error) {
 		}
 	}()
 
-	fileContentBytes, err := ioutil.ReadAll(kurtosisConfigYAMLFile)
+	fileContentBytes, err := io.ReadAll(kurtosisConfigYAMLFile)
 	if err != nil {
 		return nil, stacktrace.Propagate(err, "An error occurred reading Kurtosis config YAML file")
 	}
diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go
index cdd10e069..b1296a84e 100644
--- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go
+++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go
@@ -21,7 +21,6 @@ import (
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
 	"io"
-	"io/ioutil"
 	"net"
 	"os"
 	"path"
@@ -257,7 +256,7 @@ func GetIpAndPortInfoFromContainer(
 
 	var containerPublicIp net.IP
 	var publicPortSpecs map[string]*port_spec.PortSpec
-	if hostMachinePortBindings == nil || len(hostMachinePortBindings) == 0 {
+	if len(hostMachinePortBindings) == 0 {
 		return privateIp, privatePortSpecs, containerPublicIp, publicPortSpecs, nil
 	}
 
@@ -570,7 +569,7 @@ func getMatchingUserServiceDockerResources(
 		}
 		serviceUuid := service.ServiceUUID(serviceUuidStr)
 
-		if maybeUuidsToMatch != nil && len(maybeUuidsToMatch) > 0 {
+		if len(maybeUuidsToMatch) > 0 {
 			if _, found := maybeUuidsToMatch[serviceUuid]; !found {
 				continue
 			}
@@ -605,7 +604,7 @@ func getMatchingUserServiceDockerResources(
 		}
 		serviceUuid := service.ServiceUUID(serviceUuidStr)
 
-		if maybeUuidsToMatch != nil && len(maybeUuidsToMatch) > 0 {
+		if len(maybeUuidsToMatch) > 0 {
 			if _, found := maybeUuidsToMatch[serviceUuid]; !found {
 				continue
 			}
@@ -743,7 +742,7 @@ func dumpContainerInfo(
 		return stacktrace.Propagate(err, "An error occurred serializing the results of inspecting container with ID '%v' to JSON", containerId)
 	}
 	specOutputFilepath := path.Join(containerOutputDirpath, containerInspectResultFilename)
-	if err := ioutil.WriteFile(specOutputFilepath, jsonSerializedInspectResultBytes, createdFilePerms); err != nil {
+	if err := os.WriteFile(specOutputFilepath, jsonSerializedInspectResultBytes, createdFilePerms); err != nil {
 		return stacktrace.Propagate(
 			err,
 			"An error occurred writing the inspect output of container with name '%v' and ID '%v' to file '%v'",
diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/get_shell_on_user_service.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/get_shell_on_user_service.go
index fb2fbc7e2..ef8569d29 100644
--- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/get_shell_on_user_service.go
+++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/get_shell_on_user_service.go
@@ -8,7 +8,7 @@ import (
 	"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/enclave"
 	"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service"
 	"github.com/kurtosis-tech/stacktrace"
-	"golang.org/x/crypto/ssh/terminal"
+	terminal "golang.org/x/term"
 	"io"
 	"os"
 )
@@ -44,11 +44,16 @@ func GetShellOnUserService(ctx context.Context, enclaveId enclave.EnclaveUUID, s
 	// I just followed the solution here: https://stackoverflow.com/questions/58732588/accept-user-input-os-stdin-to-container-using-golang-docker-sdk-interactive-co
 	// This channel is being used to know the user exited the ContainerExec
 	finishChan := make(chan bool)
+	// TODO(victor.colombo): Decide what to do with errors that happen inside these go routines
 	go func() {
+		//nolint:errcheck
 		io.Copy(os.Stdout, newReader)
 		finishChan <- true
 	}()
+
+	//nolint:errcheck
 	go io.Copy(os.Stderr, newReader)
+	//nolint:errcheck
 	go io.Copy(newConnection, os.Stdin)
 
 	stdinFd := int(os.Stdin.Fd())
@@ -59,6 +64,7 @@ func GetShellOnUserService(ctx context.Context, enclaveId enclave.EnclaveUUID, s
 			// print error
 			return stacktrace.Propagate(err, "An error occurred making STDIN stream raw")
 		}
+		//nolint:errcheck
 		defer terminal.Restore(stdinFd, oldState)
 	}
 
diff --git a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/shared_helpers/shared_helpers.go b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/shared_helpers/shared_helpers.go
index 4fd458b48..f4d40ef94 100644
--- a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/shared_helpers/shared_helpers.go
+++ b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/shared_helpers/shared_helpers.go
@@ -117,20 +117,8 @@ func (apiContainerModeArgs *ApiContainerModeArgs) GetOwnNamespaceName() string {
 	return apiContainerModeArgs.ownNamespaceName
 }
 
-type EngineServerModeArgs struct {
-	/*
-		StorageClass name to be used for volumes in the cluster
-		StorageClasses must be defined by a cluster administrator.
-		passes this in when starting Kurtosis with Kubernetes.
-	*/
-	storageClassName string
-
-	/*
-		Enclave availability must be set and defined by a cluster administrator.
-		The user passes this in when starting Kurtosis with Kubernetes.
-	*/
-	enclaveDataVolumeSizeInMegabytes uint
-}
+// EngineServerModeArgs TODO(victor.colombo): Can we remove this?
+type EngineServerModeArgs struct{}
 
 type UserServiceObjectsAndKubernetesResources struct {
 	// Should never be nil because 1 Kubernetes service = 1 Kurtosis service registration
diff --git a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/user_services_functions/start_user_services.go b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/user_services_functions/start_user_services.go
index 3182cef66..fbd605513 100644
--- a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/user_services_functions/start_user_services.go
+++ b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/user_services_functions/start_user_services.go
@@ -133,7 +133,7 @@ func StartRegisteredUserServices(
 	//TODO this is a huge hack to temporarily enable static ports for NEAR until we have a more productized solution
 	for _, config := range services {
 		publicPorts := config.GetPublicPorts()
-		if publicPorts != nil && len(publicPorts) > 0 {
+		if len(publicPorts) > 0 {
 			logrus.Warn("The Kubernetes Kurtosis backend doesn't support defining static ports for services; the public ports will be ignored.")
 		}
 	}
diff --git a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_manager/kubernetes_manager.go b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_manager/kubernetes_manager.go
index cc7683970..82c1b4fee 100644
--- a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_manager/kubernetes_manager.go
+++ b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_manager/kubernetes_manager.go
@@ -12,7 +12,7 @@ import (
 	"fmt"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
-	"golang.org/x/crypto/ssh/terminal"
+	terminal "golang.org/x/term"
 	"io"
 	apiv1 "k8s.io/api/core/v1"
 	rbacv1 "k8s.io/api/rbac/v1"
@@ -1383,7 +1383,7 @@ func (manager *KubernetesManager) RunExecCommand(
 		)
 	}
 
-	if err = exec.Stream(remotecommand.StreamOptions{
+	if err = exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{
 		Stdin:             nil,
 		Stdout:            stdOutOutput,
 		Stderr:            stdErrOutput,
diff --git a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_resource_collectors/kubernetes_resource_collectors.go b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_resource_collectors/kubernetes_resource_collectors.go
index fecd8174c..a0a86e9bb 100644
--- a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_resource_collectors/kubernetes_resource_collectors.go
+++ b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_resource_collectors/kubernetes_resource_collectors.go
@@ -179,7 +179,7 @@ func postFilterKubernetesResources[T kubernetesResource](
 			)
 		}
 
-		if postFilterLabelValues != nil && len(postFilterLabelValues) > 0 {
+		if len(postFilterLabelValues) > 0 {
 			if _, found := postFilterLabelValues[labelValue]; !found {
 				continue
 			}
diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go
index 00abdf6c4..17f596fdc 100644
--- a/core/server/api_container/server/api_container_service.go
+++ b/core/server/api_container/server/api_container_service.go
@@ -30,7 +30,6 @@ import (
 	"google.golang.org/grpc"
 	"google.golang.org/protobuf/types/known/emptypb"
 	"io"
-	"io/ioutil"
 	"math"
 	"net/http"
 	"os"
@@ -548,7 +547,7 @@ func (apicService ApiContainerService) waitForEndpointAvailability(
 		body := resp.Body
 		defer body.Close()
 
-		bodyBytes, err := ioutil.ReadAll(body)
+		bodyBytes, err := io.ReadAll(body)
 
 		if err != nil {
 			return stacktrace.Propagate(err,
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go
index 792021bb7..7528fe1f6 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go
@@ -11,6 +11,7 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator"
 	"github.com/kurtosis-tech/stacktrace"
@@ -24,8 +25,7 @@ import (
 const (
 	AddServicesBuiltinName = "add_services"
 
-	ConfigsArgName   = "configs"
-	ParallelismParam = "PARALLELISM"
+	ConfigsArgName = "configs"
 )
 
 func NewAddServices(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtosis_plan_instruction.KurtosisPlanInstruction {
@@ -112,7 +112,7 @@ func (builtin *AddServicesCapabilities) Validate(_ *builtin_argument.ArgumentVal
 
 func (builtin *AddServicesCapabilities) Execute(ctx context.Context, _ *builtin_argument.ArgumentValuesSet) (string, error) {
 	renderedServiceConfigs := make(map[service.ServiceName]*service.ServiceConfig, len(builtin.serviceConfigs))
-	parallelism, ok := ctx.Value(ParallelismParam).(int)
+	parallelism, ok := ctx.Value(startosis_constants.ParallelismParam).(int)
 	if !ok {
 		return "", stacktrace.NewError("An error occurred when getting parallelism level from execution context")
 	}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go
index a2c1e946d..5d23d8c86 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go
@@ -15,8 +15,8 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator"
 	"github.com/kurtosis-tech/stacktrace"
+	starlarkjson "go.starlark.net/lib/json"
 	"go.starlark.net/starlark"
-	"go.starlark.net/starlarkjson"
 	"go.starlark.net/starlarkstruct"
 	"reflect"
 )
diff --git a/core/server/api_container/server/startosis_engine/package_io/package_io.go b/core/server/api_container/server/startosis_engine/package_io/package_io.go
index aeda7a69b..621adcabe 100644
--- a/core/server/api_container/server/startosis_engine/package_io/package_io.go
+++ b/core/server/api_container/server/startosis_engine/package_io/package_io.go
@@ -3,8 +3,8 @@ package package_io
 import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/sirupsen/logrus"
+	starlarkjson "go.starlark.net/lib/json"
 	"go.starlark.net/starlark"
-	"go.starlark.net/starlarkjson"
 	"go.starlark.net/starlarkstruct"
 	"reflect"
 )
diff --git a/core/server/api_container/server/startosis_engine/startosis_constants/startosis_constants.go b/core/server/api_container/server/startosis_engine/startosis_constants/startosis_constants.go
index c6b41c2c9..90c30a7b8 100644
--- a/core/server/api_container/server/startosis_engine/startosis_constants/startosis_constants.go
+++ b/core/server/api_container/server/startosis_engine/startosis_constants/startosis_constants.go
@@ -1,5 +1,7 @@
 package startosis_constants
 
+type StarlarkContextParam string
+
 const (
 	MainFileName       = "main.star"
 	KurtosisYamlName   = "kurtosis.yml"
@@ -8,6 +10,7 @@ const (
 
 	NoOutputObject = ""
 
-	PackageIdPlaceholderForStandaloneScript     = "DEFAULT_PACKAGE_ID_FOR_SCRIPT"
-	PlaceHolderMainFileForPlaceStandAloneScript = ""
+	PackageIdPlaceholderForStandaloneScript                          = "DEFAULT_PACKAGE_ID_FOR_SCRIPT"
+	PlaceHolderMainFileForPlaceStandAloneScript                      = ""
+	ParallelismParam                            StarlarkContextParam = "PARALLELISM"
 )
diff --git a/core/server/api_container/server/startosis_engine/startosis_executor.go b/core/server/api_container/server/startosis_engine/startosis_executor.go
index 0b04b729d..132acbc76 100644
--- a/core/server/api_container/server/startosis_engine/startosis_executor.go
+++ b/core/server/api_container/server/startosis_engine/startosis_executor.go
@@ -8,18 +8,18 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers/magic_string_helper"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store"
+	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants"
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/sirupsen/logrus"
 	"sync"
 )
 
 const (
-	progressMsg      = "Execution in progress"
-	ParallelismParam = "PARALLELISM"
 	// we limit the output to 64k characters
 	// TODO(tedi) get rid of this in favor of streaming
 	outputSizeLimit          = 64 * 1024
 	outputLimitReachedSuffix = "..."
+	progressMsg              = "Execution in progress"
 )
 
 var (
@@ -54,7 +54,7 @@ func NewStartosisExecutor(runtimeValueStore *runtime_value_store.RuntimeValueSto
 func (executor *StartosisExecutor) Execute(ctx context.Context, dryRun bool, parallelism int, instructionsSequence []*instructions_plan.ScheduledInstruction, serializedScriptOutput string) <-chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine {
 	executor.mutex.Lock()
 	starlarkRunResponseLineStream := make(chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)
-	ctxWithParallelism := context.WithValue(ctx, ParallelismParam, parallelism)
+	ctxWithParallelism := context.WithValue(ctx, startosis_constants.ParallelismParam, parallelism)
 	go func() {
 		defer func() {
 			executor.mutex.Unlock()
diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter.go b/core/server/api_container/server/startosis_engine/startosis_interpreter.go
index 28b132116..b8e9a546f 100644
--- a/core/server/api_container/server/startosis_engine/startosis_interpreter.go
+++ b/core/server/api_container/server/startosis_engine/startosis_interpreter.go
@@ -17,10 +17,10 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages"
 	"github.com/sirupsen/logrus"
+	starlarkjson "go.starlark.net/lib/json"
 	"go.starlark.net/lib/time"
 	"go.starlark.net/resolve"
 	"go.starlark.net/starlark"
-	"go.starlark.net/starlarkjson"
 	"go.starlark.net/starlarkstruct"
 	"go.starlark.net/syntax"
 	"path"
diff --git a/core/server/commons/yaml_parser/kurtosis_yaml.go b/core/server/commons/yaml_parser/kurtosis_yaml.go
index 138f206e8..adf48213e 100644
--- a/core/server/commons/yaml_parser/kurtosis_yaml.go
+++ b/core/server/commons/yaml_parser/kurtosis_yaml.go
@@ -3,7 +3,7 @@ package yaml_parser
 import (
 	"github.com/go-yaml/yaml"
 	"github.com/kurtosis-tech/stacktrace"
-	"io/ioutil"
+	"os"
 )
 
 var noPackageNameFound = ""
@@ -35,5 +35,5 @@ func parseKurtosisYamlInternal(absPathToKurtosisYaml string, read func(filename
 }
 
 func ParseKurtosisYaml(absPathToKurtosisYaml string) (*KurtosisYaml, error) {
-	return parseKurtosisYamlInternal(absPathToKurtosisYaml, ioutil.ReadFile)
+	return parseKurtosisYamlInternal(absPathToKurtosisYaml, os.ReadFile)
 }


Test patch:
diff --git a/cli/cli/commands/root_test.go b/cli/cli/commands/root_test.go
index cea52707e..bff403f5f 100644
--- a/cli/cli/commands/root_test.go
+++ b/cli/cli/commands/root_test.go
@@ -8,7 +8,6 @@ import (
 	"github.com/sirupsen/logrus"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
-	"io/ioutil"
 	"os"
 	"testing"
 )
@@ -88,7 +87,7 @@ func TestParseVersionStrToSemVer_CanParseValidVersions(t *testing.T) {
 
 func createNewTempFileAndGetFilepath() (string, func() error, error) {
 
-	tempFile, err := ioutil.TempFile("", temporaryTestFileFilename)
+	tempFile, err := os.CreateTemp("", temporaryTestFileFilename)
 	if err != nil {
 		return "", nil, stacktrace.Propagate(err, "An error occurred creating temporary file for test purpose with name '%v'", temporaryTestFileFilename)
 	}
diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/starlark_framework_engine_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/starlark_framework_engine_test.go
index 6c5ba16c1..619c39765 100644
--- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/starlark_framework_engine_test.go
+++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/starlark_framework_engine_test.go
@@ -12,9 +12,9 @@ import (
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction"
 	"github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants"
 	"github.com/stretchr/testify/require"
+	starlarkjson "go.starlark.net/lib/json"
 	"go.starlark.net/lib/time"
 	"go.starlark.net/starlark"
-	"go.starlark.net/starlarkjson"
 	"go.starlark.net/starlarkstruct"
 	"reflect"
 	"testing"
@@ -98,7 +98,7 @@ func testKurtosisPlanInstruction(t *testing.T, builtin KurtosisPlanInstructionBa
 	instructionToExecute := instructionsSequence[0].GetInstruction()
 
 	// execute the instruction and run custom builtin assertions
-	executionResult, err := instructionToExecute.Execute(context.WithValue(context.Background(), "PARALLELISM", 1))
+	executionResult, err := instructionToExecute.Execute(context.WithValue(context.Background(), startosis_constants.ParallelismParam, 1))
 	require.Nil(t, err, "Builtin execution threw an error: \n%v", err)
 	builtin.Assert(interpretationResult, executionResult)
 
diff --git a/core/server/commons/enclave_data_directory/directory_existence_ensurer_test.go b/core/server/commons/enclave_data_directory/directory_existence_ensurer_test.go
index 679ec622f..5d9d825a9 100644
--- a/core/server/commons/enclave_data_directory/directory_existence_ensurer_test.go
+++ b/core/server/commons/enclave_data_directory/directory_existence_ensurer_test.go
@@ -7,14 +7,13 @@ package enclave_data_directory
 
 import (
 	"github.com/stretchr/testify/assert"
-	"io/ioutil"
 	"os"
 	"path"
 	"testing"
 )
 
 func TestEnsureDirectoryExists(t *testing.T) {
-	tempDir, err := ioutil.TempDir("", "")
+	tempDir, err := os.MkdirTemp("", "")
 	assert.Nil(t, err)
 
 	dirToCreate := path.Join(tempDir, "to-create")
diff --git a/core/server/commons/enclave_data_directory/enclave_data_directory_test.go b/core/server/commons/enclave_data_directory/enclave_data_directory_test.go
index bbfba906a..89dcff4e8 100644
--- a/core/server/commons/enclave_data_directory/enclave_data_directory_test.go
+++ b/core/server/commons/enclave_data_directory/enclave_data_directory_test.go
@@ -7,14 +7,13 @@ package enclave_data_directory
 
 import (
 	"github.com/stretchr/testify/assert"
-	"io/ioutil"
 	"os"
 	"path"
 	"testing"
 )
 
 func TestGetFilesArtifactStore(t *testing.T) {
-	enclaveDirpath, err := ioutil.TempDir("", "")
+	enclaveDirpath, err := os.MkdirTemp("", "")
 	assert.Nil(t, err)
 
 	enclaveDir := NewEnclaveDataDirectory(enclaveDirpath)
diff --git a/core/server/commons/enclave_data_directory/file_cache_test.go b/core/server/commons/enclave_data_directory/file_cache_test.go
index def3e0530..11f801e02 100644
--- a/core/server/commons/enclave_data_directory/file_cache_test.go
+++ b/core/server/commons/enclave_data_directory/file_cache_test.go
@@ -8,7 +8,7 @@ package enclave_data_directory
 import (
 	"github.com/kurtosis-tech/stacktrace"
 	"github.com/stretchr/testify/assert"
-	"io/ioutil"
+	"io"
 	"os"
 	"path"
 	"strings"
@@ -34,7 +34,7 @@ func TestFileCache_AddAndGetAndRemoveArtifact(t *testing.T) {
 	// Check that the contents are what we expect
 	fp, err := os.Open(addedFileObj.GetAbsoluteFilepath())
 	assert.Nil(t, err)
-	testFileBytes, err := ioutil.ReadAll(fp)
+	testFileBytes, err := io.ReadAll(fp)
 	assert.Nil(t, err)
 	assert.Equal(t, testContents, string(testFileBytes))
 
@@ -82,7 +82,7 @@ func TestFileCache_FileDeletedOnReaderError(t *testing.T) {
 	assert.NotNil(t, err)
 
 	// Make sure the file cache directory is still empty
-	files, err := ioutil.ReadDir(fileCache.absoluteDirpath)
+	files, err := os.ReadDir(fileCache.absoluteDirpath)
 	assert.Nil(t, err)
 	assert.Equal(t, 0, len(files))
 }
@@ -96,7 +96,7 @@ func TestFileCache_RemoveFileFailsForNonExistingKeys(t *testing.T) {
 }
 
 func getTestFileCache(t *testing.T) *FileCache {
-	absDirpath, err := ioutil.TempDir("", "")
+	absDirpath, err := os.MkdirTemp("", "")
 	assert.Nil(t, err)
 	return newFileCache(absDirpath, "")
 }
diff --git a/core/server/commons/enclave_data_directory/files_artifact_store_test.go b/core/server/commons/enclave_data_directory/files_artifact_store_test.go
index 30b8d2d39..be5653781 100644
--- a/core/server/commons/enclave_data_directory/files_artifact_store_test.go
+++ b/core/server/commons/enclave_data_directory/files_artifact_store_test.go
@@ -7,7 +7,6 @@ package enclave_data_directory
 
 import (
 	"github.com/stretchr/testify/require"
-	"io/ioutil"
 	"os"
 	"path/filepath"
 	"strings"
@@ -33,7 +32,7 @@ func TestFileStore_StoreFileSimpleCase(t *testing.T) {
 	expectedFilepath := filepath.Join(fileStore.fileCache.absoluteDirpath, expectedFilename)
 	_, dirErr := os.Stat(expectedFilepath)
 	require.Nil(t, dirErr)
-	file, readErr := ioutil.ReadFile(expectedFilepath)
+	file, readErr := os.ReadFile(expectedFilepath)
 	require.Nil(t, readErr)
 	require.Equal(t, []byte(testContent), file)
 }
@@ -66,7 +65,7 @@ func TestFileStore_GetFilepathByUUIDProperFilepath(t *testing.T) {
 
 	_, dirErr := os.Stat(enclaveDataFile.absoluteFilepath)
 	require.Nil(t, dirErr)
-	file, readErr := ioutil.ReadFile(enclaveDataFile.absoluteFilepath)
+	file, readErr := os.ReadFile(enclaveDataFile.absoluteFilepath)
 	require.Nil(t, readErr)
 	require.Equal(t, []byte(testContent), file)
 }
@@ -96,9 +95,9 @@ func TestFileStore_StoreFilesUniquely(t *testing.T) {
 	require.NotEqual(t, enclaveDataFile, anotherFilepath)
 
 	//Read and evaluate their content is different.
-	file, readErr := ioutil.ReadFile(enclaveDataFile.absoluteFilepath)
+	file, readErr := os.ReadFile(enclaveDataFile.absoluteFilepath)
 	require.Nil(t, readErr)
-	anotherFile, readErr := ioutil.ReadFile(anotherFilepath.absoluteFilepath)
+	anotherFile, readErr := os.ReadFile(anotherFilepath.absoluteFilepath)
 	require.Nil(t, readErr)
 	require.NotEqual(t, file, anotherFile)
 }
@@ -159,7 +158,7 @@ func TestFilesArtifactStore_GetFileNamesAndUuids(t *testing.T) {
 }
 
 func getTestFileStore(t *testing.T) *FilesArtifactStore {
-	absDirpath, err := ioutil.TempDir("", "")
+	absDirpath, err := os.MkdirTemp("", "")
 	require.Nil(t, err)
 	fileStore := newFilesArtifactStore(absDirpath, "")
 	require.Nil(t, err)