From 89dd05be0cd2bc3665f08ea2fa7e9de0417e51c0 Mon Sep 17 00:00:00 2001 From: Brody Date: Sat, 2 Mar 2024 11:51:25 -0500 Subject: [PATCH] small updates --- Dockerfile | 4 ++-- go.mod | 19 +++++++++---------- go.sum | 40 ++++++++++++++++++---------------------- main.go | 18 ++++++++++++------ railway.json | 11 ----------- 5 files changed, 41 insertions(+), 51 deletions(-) delete mode 100644 railway.json diff --git a/Dockerfile b/Dockerfile index 73d2379..62d8d6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.3-alpine3.18 as builder +FROM golang:1.22.0-alpine as builder WORKDIR /app @@ -8,7 +8,7 @@ RUN go mod download COPY . ./ -RUN go build -ldflags "-w -s -extldflags '-static'" -trimpath -a -o main +RUN go build -ldflags "-w -s" -o main FROM gcr.io/distroless/static diff --git a/go.mod b/go.mod index 6956bee..ad3ac65 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,24 @@ module main -go 1.21.3 +go 1.22.0 require ( github.com/brody192/genqlient v0.0.1 - github.com/brody192/logger v0.0.3 - github.com/go-co-op/gocron v1.35.2 - github.com/google/uuid v1.4.0 - github.com/gorilla/schema v1.2.0 + github.com/brody192/logger v0.0.5 + github.com/go-co-op/gocron v1.37.0 + github.com/google/uuid v1.6.0 + github.com/gorilla/schema v1.2.1 github.com/robfig/cron/v3 v3.0.1 - golang.org/x/exp v0.0.0-20231006140011-7918f672742d + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 ) require ( github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alexflint/go-arg v1.4.3 // indirect github.com/alexflint/go-scalar v1.2.0 // indirect - github.com/vektah/gqlparser/v2 v2.5.10 // indirect + github.com/vektah/gqlparser/v2 v2.5.11 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/mod v0.13.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/tools v0.14.0 // indirect + golang.org/x/mod v0.15.0 // indirect + golang.org/x/tools v0.18.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index c6ae25a..f4ba92c 100644 --- a/go.sum +++ b/go.sum @@ -13,23 +13,21 @@ github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oM github.com/bradleyjkemp/cupaloy/v2 v2.8.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0= github.com/brody192/genqlient v0.0.1 h1:uAX6azSukJI+Z/CQ+c1n0zWhqfo4Z2U+bI9JYS0BeJg= github.com/brody192/genqlient v0.0.1/go.mod h1:LTRv7kq7++Mb81acucp6h7p7ZPImQyrrYdAQwrybHo4= -github.com/brody192/logger v0.0.2 h1:6oar2SjCSbvuI/6rd4YxLrKq3rK8ESzoM4INDKLCwBM= -github.com/brody192/logger v0.0.2/go.mod h1:U5FG46DkOU21OlsjjoMIwXOnh2+8/erIMTNUGag3pwU= -github.com/brody192/logger v0.0.3 h1:5tgw4Bs/NDP9iMdmOS7knR3/cbvu5OzO0q3tf28EEqc= -github.com/brody192/logger v0.0.3/go.mod h1:U5FG46DkOU21OlsjjoMIwXOnh2+8/erIMTNUGag3pwU= +github.com/brody192/logger v0.0.5 h1:1xfbVnWijvpB0gPwUVyjlGIp45n1e650bYovdTREyag= +github.com/brody192/logger v0.0.5/go.mod h1:U5FG46DkOU21OlsjjoMIwXOnh2+8/erIMTNUGag3pwU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= -github.com/go-co-op/gocron v1.35.2 h1:lG3rdA9TqBBC/PtT2ukQqgLm6jEepnAzz3+OQetvPTE= -github.com/go-co-op/gocron v1.35.2/go.mod h1:NLi+bkm4rRSy1F8U7iacZOz0xPseMoIOnvabGoSe/no= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0= +github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= -github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= +github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -59,21 +57,19 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= -github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= +github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/main.go b/main.go index b4346e2..6ab8019 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,12 @@ func main() { os.Exit(1) } + if len(schedules) == 0 { + logger.Stderr.Error("no schedules found") + logger.Stdout.Info("set at least one or more schedules with 'SCHEDULE_1', 'SCHEDULE_2', etc. variables") + os.Exit(1) + } + logger.Stdout.Info("parsed schedules from environment successfully", slog.Int("found_schedules", len(schedules)), ) @@ -35,18 +41,18 @@ func main() { railwayClient := railway.NewAuthedClient(railwayToken) // print schedules for viewing purposes - for _, schedule := range schedules { - project, err := railway.Project(railwayClient, schedule.ProjectID) + for i := range schedules { + project, err := railway.Project(railwayClient, schedules[i].ProjectID) if err != nil { - logger.Stderr.Error("failed retrieving project information", logger.ErrAttr(err), slog.String("project_id", schedule.ProjectID)) + logger.Stderr.Error("failed retrieving project information", logger.ErrAttr(err), slog.String("project_id", schedules[i].ProjectID)) os.Exit(1) } logger.Stdout.Info("found schedule", - slog.String("service_id", schedule.ServiceID), + slog.String("service_id", schedules[i].ServiceID), slog.String("project_name", project.Project.Name), - slog.String("action", string(schedule.Action)), - slog.String("expression", schedule.Expression), + slog.String("action", string(schedules[i].Action)), + slog.String("expression", schedules[i].Expression), ) } diff --git a/railway.json b/railway.json deleted file mode 100644 index 59790e8..0000000 --- a/railway.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://schema.up.railway.app/railway.schema.json", - "build": { - "builder": "DOCKERFILE", - "dockerfilePath": "Dockerfile" - }, - "deploy": { - "numReplicas": 1, - "restartPolicyType": "NEVER" - } -} \ No newline at end of file