Skip to content

Commit

Permalink
chore: modernize code
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Dec 21, 2024
1 parent d0255aa commit c25efdd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/daemon/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ func Execute(args []string, logWriter io.Writer, version, commit, date string) i

openvpnClient := openvpn.New(ctx, logger, conf)

oauth2Client, err := oauth2.New(ctx, logger, conf, httpClient, tokenStorage, provider, openvpnClient)
oAuth2Client, err := oauth2.New(ctx, logger, conf, httpClient, tokenStorage, provider, openvpnClient)
if err != nil {
logger.Error(err.Error())

return 1
}

openvpnClient.SetOAuth2Client(oauth2Client)
openvpnClient.SetOAuth2Client(oAuth2Client)

httpHandler, err := httphandler.New(conf, oauth2Client)
httpHandler, err := httphandler.New(conf, oAuth2Client)
if err != nil {
logger.Error(err.Error())

Expand Down
6 changes: 3 additions & 3 deletions internal/httphandler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/jkroepke/openvpn-auth-oauth2/internal/ui"
)

func New(conf config.Config, oauth2 *oauth2.Client) (*http.ServeMux, error) {
func New(conf config.Config, oAuth2Client *oauth2.Client) (*http.ServeMux, error) {
staticFs, err := fs.Sub(ui.Static, "assets")
if err != nil {
return nil, fmt.Errorf("failed to create static file system: %w", err)
Expand All @@ -26,8 +26,8 @@ func New(conf config.Config, oauth2 *oauth2.Client) (*http.ServeMux, error) {
_, _ = w.Write([]byte("OK"))
}))
mux.Handle(fmt.Sprintf("GET %s/assets/", basePath), http.StripPrefix(basePath+"/assets/", http.FileServerFS(staticFs)))
mux.Handle(fmt.Sprintf("GET %s/oauth2/start", basePath), noCacheHeaders(oauth2.OAuth2Start()))
mux.Handle(fmt.Sprintf("GET %s/oauth2/callback", basePath), noCacheHeaders(oauth2.OAuth2Callback()))
mux.Handle(fmt.Sprintf("GET %s/oauth2/start", basePath), noCacheHeaders(oAuth2Client.OAuth2Start()))
mux.Handle(fmt.Sprintf("GET %s/oauth2/callback", basePath), noCacheHeaders(oAuth2Client.OAuth2Callback()))

return mux, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/openvpn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(ctx context.Context, logger *slog.Logger, conf config.Config) *Client {
return client
}

func (c *Client) SetOAuth2Client(client oauth2Client) {
func (c *Client) SetOAuth2Client(client oAuth2Client) {

Check failure on line 46 in internal/openvpn/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: oAuth2Client (typecheck)

Check failure on line 46 in internal/openvpn/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: oAuth2Client) (typecheck)

Check failure on line 46 in internal/openvpn/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: oAuth2Client) (typecheck)

Check failure on line 46 in internal/openvpn/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: oAuth2Client) (typecheck)

Check failure on line 46 in internal/openvpn/main.go

View workflow job for this annotation

GitHub Actions / Build & Test

undefined: oAuth2Client
c.oauth2 = client
}

Expand Down
6 changes: 3 additions & 3 deletions internal/utils/testutils/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ func SetupOpenVPNOAuth2Clients(
require.NoError(tb, err)

openVPNClient := openvpn.New(ctx, logger, conf)
oauth2Client, err := oauth2.New(ctx, logger, conf, httpClient, tokenStorage, provider, openVPNClient)
oAuth2Client, err := oauth2.New(ctx, logger, conf, httpClient, tokenStorage, provider, openVPNClient)
require.NoError(tb, err)

openVPNClient.SetOAuth2Client(oauth2Client)
openVPNClient.SetOAuth2Client(oAuth2Client)

tb.Cleanup(openVPNClient.Shutdown)

return oauth2Client, openVPNClient
return oAuth2Client, openVPNClient
}

0 comments on commit c25efdd

Please sign in to comment.