Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: galvanize-instancer/go.mod
cache-dependency-path: galvanize-instancer/go.sum
Expand All @@ -28,13 +28,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version-file: galvanize-instancer/go.mod
cache-dependency-path: galvanize-instancer/go.sum

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest
working-directory: galvanize-instancer
11 changes: 0 additions & 11 deletions galvanize-instancer/internal/ansible/published_ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ var knownDockerProtocols = map[string]struct{}{
"sctp": {},
}

// normalizePublishedPorts supports optional protocol hints in published_ports,
// e.g. "22/ssh" or "8080:80/http".
//
// It returns:
// - a shallow-copied deploy params map where published_ports entries are made Docker-compatible,
// - a target-port to connection-scheme map used when building connection info.
func normalizePublishedPorts(params map[string]interface{}) (map[string]interface{}, map[int]string) {
normalized, hints, _ := normalizePublishedPortsWithState(params, false, nil, false)
return normalized, hints
}

func randomizableContainerPorts(params map[string]interface{}) []string {
rawPorts, ok := params["published_ports"]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion galvanize-instancer/internal/docker/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SanitizeProjectName(name string) string {

func BuildComposeProject(unique bool, challengeName, teamID string) string {
var composeProject string
if unique == true {
if unique {
composeProject = "global-" + challengeName
composeProject = SanitizeProjectName(composeProject)
} else {
Expand Down
18 changes: 9 additions & 9 deletions galvanize-instancer/internal/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,23 @@ func (s *stats) report(out io.Writer, phase string, elapsed time.Duration) {
minLatency = 0
}

fmt.Fprintf(out, "\nPhase %s\n", phase)
fmt.Fprintf(out, " Duration: %s\n", elapsed)
fmt.Fprintf(out, " Total: %d Success: %d Errors: %d\n", total, success, errors)
fmt.Fprintf(out, " Latency: min %s avg %s max %s\n", minLatency, avgLatency, maxLatency)
_, _ = fmt.Fprintf(out, "\nPhase %s\n", phase)
_, _ = fmt.Fprintf(out, " Duration: %s\n", elapsed)
_, _ = fmt.Fprintf(out, " Total: %d Success: %d Errors: %d\n", total, success, errors)
_, _ = fmt.Fprintf(out, " Latency: min %s avg %s max %s\n", minLatency, avgLatency, maxLatency)

s.mu.Lock()
if len(s.statuses) > 0 {
fmt.Fprintf(out, " Status counts:")
_, _ = fmt.Fprintf(out, " Status counts:")
for code, count := range s.statuses {
fmt.Fprintf(out, " %d=%d", code, count)
_, _ = fmt.Fprintf(out, " %d=%d", code, count)
}
fmt.Fprintln(out, "")
_, _ = fmt.Fprintln(out, "")
}
if len(s.errSamples) > 0 {
fmt.Fprintln(out, " Error samples:")
_, _ = fmt.Fprintln(out, " Error samples:")
for _, sample := range s.errSamples {
fmt.Fprintf(out, " - %s\n", sample)
_, _ = fmt.Fprintf(out, " - %s\n", sample)
}
}
s.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion galvanize-instancer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
} else {
logger.Init(false)
}
defer zap.L().Sync()
defer func() { _ = zap.L().Sync() }()
cmd.SetVersion(Version)
cmd.Execute()
}
4 changes: 2 additions & 2 deletions galvanize-instancer/pkg/restserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s *Server) DeployInstance(ctx echo.Context) error {
zap.S().Errorf("Failed to get challenge infos: %v", err)
return ctx.JSON(400, api.Error{Message: utils.HTTP500Debug(fmt.Sprintf("Failed to get challenge info: %v", err))}) //TODO notify admin
}
if chall.Unique == true {
if chall.Unique {
zap.S().Errorf("Attempt to deploy unique challenge %s for team %s", req.ChallengeName, claims.TeamID)
return ctx.JSON(403, api.Error{Message: utils.Ptr("Unauthorized")})
}
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *Server) GetInstanceStatus(ctx echo.Context) error {
return ctx.JSON(400, api.Error{Message: utils.Ptr("Invalid challenge")})
}
var deployment *models.Deployment
if chall.Unique == true {
if chall.Unique {
zap.S().Debugf("Status request received for challenge %s", chall.Name)
deployment, err = models.GetUniqueDeployment(s.db, chall.Category, chall.Name, false)
} else {
Expand Down
2 changes: 1 addition & 1 deletion galvanize-instancer/pkg/restserver_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *Server) DeployAdminInstance(ctx echo.Context) error {
zap.S().Errorf("Failed to get challenge infos: %v", err)
return ctx.JSON(400, api.Error{Message: utils.Ptr(fmt.Sprintf("Failed to get challenge info: %v", err))})
}
if chall.Unique != true {
if !chall.Unique {
zap.S().Errorf("Attempt to admin-deploy non-unique challenge %s", req.ChallengeName)
return ctx.JSON(400, api.Error{Message: utils.Ptr("Challenge is not unique")})
}
Expand Down
2 changes: 1 addition & 1 deletion galvanize-instancer/pkg/utils/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func RegisterSSHHosts(cfg *config.Config) error {
if err != nil {
return err
}
defer f.Close()
defer func() { _ = f.Close() }()

// Register all hosts that need it
for _, host := range hostsToRegister {
Expand Down
1 change: 0 additions & 1 deletion galvanize-instancer/pkg/worker/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (p *Pool) runWorker(ctx context.Context, workerID string) {
}

p.processJob(ctx, workerID, job)
job = nil // Help GC

// Aggressively free memory after each job since Ansible processes are memory-heavy
runtime.GC()
Expand Down
Loading