Skip to content

Commit

Permalink
chore: adjustments for dev environment (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
shini4i authored Dec 2, 2024
1 parent fa1b4d0 commit fa9bc35
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 158 deletions.
8 changes: 7 additions & 1 deletion cmd/argo-watcher/argocd/argo_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ func (updater *ArgoStatusUpdater) waitRollout(task models.Task) (*models.Applica

if task.Timeout > 0 {
log.Debug().Str("id", task.Id).Msgf("Overriding task timeout to %ds", task.Timeout)
retryOptions = append(retryOptions, retry.Attempts(uint((task.Timeout/15)+1)))
calculatedAttempts := task.Timeout/15 + 1

if calculatedAttempts < 0 {
log.Error().Msg("Calculated attempts resulted in a negative number, defaulting to 15 attempts.")
calculatedAttempts = 15
}
retryOptions = append(retryOptions, retry.Attempts(uint(calculatedAttempts))) // #nosec G115
}

log.Debug().Str("id", task.Id).Msg("Waiting for rollout")
Expand Down
1 change: 1 addition & 0 deletions cmd/argo-watcher/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type ServerConfig struct {
Keycloak KeycloakConfig `json:"keycloak,omitempty"`
LockdownSchedule string `env:"LOCKDOWN_SCHEDULE" json:"lockdown_schedule,omitempty"`
Webhook WebhookConfig `json:"webhook,omitempty"`
DevEnvironment bool `env:"DEV_ENVIRONMENT" envDefault:"false" json:"devEnvironment"` // Whether a set of dev specific setting should be turned on, do not touch unless you know what you are doing
}

// NewServerConfig parses the server configuration from environment variables using the envconfig package.
Expand Down
6 changes: 5 additions & 1 deletion cmd/argo-watcher/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ func (env *Env) validateToken(c *gin.Context, allowedAuthStrategy string) (bool,
// acceptance fails, an error is logged. The goroutine serves to monitor
// the connection's activity and removes it from the slice if it's inactive.
func (env *Env) handleWebSocketConnection(c *gin.Context) {
conn, err := websocket.Accept(c.Writer, c.Request, nil)
options := &websocket.AcceptOptions{
InsecureSkipVerify: env.config.DevEnvironment, // It will disable websocket host validation if set to true
}

conn, err := websocket.Accept(c.Writer, c.Request, options)
if err != nil {
log.Error().Msgf("couldn't accept websocket connection, got the following error: %s", err)
}
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
postgres:
condition: service_healthy
backend:
image: golang:1.22-alpine3.19
image: golang:1.23-alpine3.20
volumes:
- .:/app
working_dir: /app
Expand All @@ -41,6 +41,7 @@ services:
DB_PASSWORD: watcher
DB_MIGRATIONS_PATH: /app/db/migrations
LOG_LEVEL: debug
DEV_ENVIRONMENT: true
depends_on:
migrations:
condition: service_completed_successfully
Expand All @@ -57,7 +58,7 @@ services:
ports:
- "3000:3000"
mock:
image: golang:1.22-alpine3.19
image: golang:1.23-alpine3.20
volumes:
- .:/app
working_dir: /app
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -76,6 +78,7 @@ require (
github.com/microsoft/go-mssqldb v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
Loading

0 comments on commit fa9bc35

Please sign in to comment.