Skip to content

Commit

Permalink
fix linter errors in other modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean committed Dec 6, 2023
1 parent d30c9b6 commit 3f0bf59
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func ContainerStatusStringifier(containerStatus kurtosis_core_rpc_api_bindings.C
return colorizeStopped(containerStatusStr)
case kurtosis_core_rpc_api_bindings.Container_RUNNING:
return colorizeRunning(containerStatusStr)
case kurtosis_core_rpc_api_bindings.Container_UNKNOWN:
return containerStatusStr
default:
return containerStatusStr
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package output_printers
import (
"errors"
"fmt"
"strings"
"sync"
"time"

"github.com/bazelbuild/buildtools/build"
"github.com/briandowns/spinner"
"github.com/fatih/color"
Expand All @@ -12,9 +16,6 @@ import (
"github.com/kurtosis-tech/kurtosis/cli/cli/out"
"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
"strings"
"sync"
"time"
)

const (
Expand Down Expand Up @@ -184,6 +185,7 @@ func formatInfo(infoMessage string) string {
return colorizeInfo(infoMessage)
}

// nolint:exhaustive
func formatInstruction(instruction *kurtosis_core_rpc_api_bindings.StarlarkInstruction, verbosity run.Verbosity) string {
var serializedInstruction string
switch verbosity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func ServiceStatusStringifier(serviceStatus kurtosis_core_rpc_api_bindings.Servi
return colorizeStopped(serviceStatusStr)
case kurtosis_core_rpc_api_bindings.ServiceStatus_RUNNING:
return colorizeRunning(serviceStatusStr)
case kurtosis_core_rpc_api_bindings.ServiceStatus_UNKNOWN:
return serviceStatusStr
default:
return serviceStatusStr
}
Expand Down
16 changes: 10 additions & 6 deletions connect-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package connect_server
import (
"context"
"fmt"
"github.com/kurtosis-tech/stacktrace"
"github.com/rs/cors"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/kurtosis-tech/stacktrace"
"github.com/rs/cors"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)

const (
Expand Down Expand Up @@ -63,6 +64,7 @@ func (server *ConnectServer) RunServerUntilStopped(

mux.Handle(server.path, server.handler)

// nolint:exhaustruct
httpServer := http.Server{
Addr: fmt.Sprintf(":%v", server.listenPort),
Handler: cors.Handler(h2c.NewHandler(mux, &http2.Server{})),
Expand All @@ -78,7 +80,9 @@ func (server *ConnectServer) RunServerUntilStopped(
<-stopper
serverStoppedChan := make(chan interface{})
go func() {
httpServer.Shutdown(context.Background())
if err := httpServer.Shutdown(context.Background()); err != nil {
logrus.WithError(err).Error("Failed to shutdown the HTTP server")
}
serverStoppedChan <- nil
}()
select {
Expand Down
23 changes: 16 additions & 7 deletions enclave-manager/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
)

const (
listenPort = 8081
grpcServerStopGracePeriod = 5 * time.Second
engineHostUrl = "http://localhost:9710"
kurtosisCloudApiHost = "https://cloud.kurtosis.com"
kurtosisCloudApiPort = 8080
listenPort = 8081
grpcServerStopGracePeriod = 5 * time.Second
engineHostUrl = "http://localhost:9710"
kurtosisCloudApiHost = "https://cloud.kurtosis.com"
kurtosisCloudApiPort = 8080
numberOfElementsAuthHeader = 2
numberOfElementsHostString = 2
)

type Authentication struct {
Expand Down Expand Up @@ -60,6 +62,7 @@ func NewWebserver(enforceAuth bool) (*WebServer, error) {
apiKeyMutex: &sync.RWMutex{},
apiKeyMap: map[string]*string{},
instanceConfigMap: map[string]*kurtosis_backend_server_rpc_api_bindings.GetCloudInstanceConfigResponse{},
instanceConfig: nil,
}, nil
}

Expand All @@ -83,7 +86,7 @@ func (c *WebServer) ValidateRequestAuthorization(

reqToken := header.Get("Authorization")
splitToken := strings.Split(reqToken, "Bearer")
if len(splitToken) != 2 {
if len(splitToken) != numberOfElementsAuthHeader {
return false, stacktrace.NewError("Authorization token malformed. Bearer token format required")
}
reqToken = strings.TrimSpace(splitToken[1])
Expand All @@ -101,7 +104,7 @@ func (c *WebServer) ValidateRequestAuthorization(
}
reqHost := header.Get("Host")
splitHost := strings.Split(reqHost, ":")
if len(splitHost) != 2 {
if len(splitHost) != numberOfElementsHostString {
return false, stacktrace.NewError("Host header malformed. host:port format required")
}
reqHost = splitHost[0]
Expand Down Expand Up @@ -227,6 +230,9 @@ func (c *WebServer) RunStarlarkPackage(ctx context.Context, req *connect.Request
}

starlarkLogsStream, err := (*apiContainerServiceClient).RunStarlarkPackage(ctx, runStarlarkRequest)
if err != nil {
return stacktrace.Propagate(err, "Failed to run package: %s", req.Msg.RunStarlarkPackageArgs.PackageId)
}

for starlarkLogsStream.Receive() {
resp := starlarkLogsStream.Msg()
Expand Down Expand Up @@ -333,6 +339,9 @@ func (c *WebServer) DownloadFilesArtifact(
}

filesArtifactStream, err := (*apiContainerServiceClient).DownloadFilesArtifact(ctx, downloadFilesArtifactRequest)
if err != nil {
return stacktrace.Propagate(err, "Failed to create download stream for file artifact: %s", filesArtifactIdentifier)
}
for filesArtifactStream.Receive() {
resp := filesArtifactStream.Msg()
err = str.Send(resp)
Expand Down

0 comments on commit 3f0bf59

Please sign in to comment.