@@ -14,7 +14,6 @@ import (
14
14
"time"
15
15
16
16
"github.com/jippi/scm-engine/pkg/config"
17
- "github.com/jippi/scm-engine/pkg/scm/gitlab"
18
17
"github.com/jippi/scm-engine/pkg/state"
19
18
"github.com/urfave/cli/v2"
20
19
slogctx "github.com/veqryn/slog-context"
@@ -55,15 +54,22 @@ func errHandler(ctx context.Context, w http.ResponseWriter, code int, err error)
55
54
return
56
55
}
57
56
58
- func Server (cCtx * cli.Context ) error { //nolint:unparam
59
- slogctx .Info (cCtx .Context , "Starting HTTP server" , slog .String ("listen" , cCtx .String (FlagServerListen )))
57
+ func Server (cCtx * cli.Context ) error {
58
+ // Initialize context
59
+ ctx := state .WithDryRun (cCtx .Context , cCtx .Bool (FlagDryRun ))
60
+ ctx = state .WithBaseURL (ctx , cCtx .String (FlagSCMBaseURL ))
61
+ ctx = state .WithToken (ctx , cCtx .String (FlagAPIToken ))
62
+ ctx = state .WithProvider (ctx , cCtx .String (FlagProvider ))
63
+ ctx = state .WithUpdatePipeline (ctx , cCtx .Bool (FlagUpdatePipeline ))
64
+
65
+ slogctx .Info (ctx , "Starting HTTP server" , slog .String ("listen" , cCtx .String (FlagServerListen )))
60
66
61
67
mux := http .NewServeMux ()
62
68
63
69
ourSecret := cCtx .String (FlagWebhookSecret )
64
70
65
- // Initialize GitLab client
66
- client , err := gitlab . NewClient (cCtx .String ( FlagAPIToken ), cCtx . String ( FlagSCMBaseURL ) )
71
+ // Initialize client
72
+ client , err := getClient (cCtx .Context )
67
73
if err != nil {
68
74
return err
69
75
}
@@ -179,9 +185,6 @@ func Server(cCtx *cli.Context) error { //nolint:unparam
179
185
ReadTimeout : 5 * time .Second ,
180
186
WriteTimeout : 5 * time .Second ,
181
187
BaseContext : func (l net.Listener ) context.Context {
182
- ctx := state .WithDryRun (cCtx .Context , cCtx .Bool (FlagDryRun ))
183
- ctx = state .WithUpdatePipeline (ctx , cCtx .Bool (FlagUpdatePipeline ))
184
-
185
188
return ctx
186
189
},
187
190
}
0 commit comments