Repository: dexidp/dex
Pull request #3564 (2024-06-03 19:20:07)

Fix trivy scanning job

<!--
Thank you for sending a pull request! Here are some tips for contributors:

1. Fill the description template below.
2. Sign a DCO (if you haven't already signed it).
3. Include appropriate tests (if necessary). Make sure that all CI checks passed.
4. If the Pull Request is a work in progress, make use of GitHub's "Draft PR" feature and mark it as such.
-->

#### Overview

container-image -> container-images

#### What this PR does / why we need it

<!--
- Please state in detail why we need this PR and what it solves.
- If your PR closes some of the existing issues, please add links to them here.
  Mentioned issues will be automatically closed.
  Usage: "Closes #<issue number>", or "Closes (paste link of issue)"
-->

#### Special notes for your reviewer



Patch:
diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml
index eda163a3..3f241db7 100644
--- a/.github/workflows/artifacts.yaml
+++ b/.github/workflows/artifacts.yaml
@@ -16,13 +16,13 @@ on:
     outputs:
       container-image-name:
         description: Container image name
-        value: ${{ jobs.container-image.outputs.name }}
+        value: ${{ jobs.container-images.outputs.name }}
       container-image-digest:
         description: Container image digest
-        value: ${{ jobs.container-image.outputs.digest }}
+        value: ${{ jobs.container-images.outputs.digest }}
       container-image-ref:
         description: Container image ref
-        value: ${{ jobs.container-image.outputs.ref }}
+        value: ${{ jobs.container-images.outputs.ref }}
 
 permissions:
   contents: read
diff --git a/cmd/dex/serve.go b/cmd/dex/serve.go
index b39354ec..456e07f6 100644
--- a/cmd/dex/serve.go
+++ b/cmd/dex/serve.go
@@ -520,11 +520,11 @@ func newLogger(level slog.Level, format string) (*slog.Logger, error) {
 	var handler slog.Handler
 	switch strings.ToLower(format) {
 	case "", "text":
-		slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
+		handler = slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
 			Level: level,
 		})
 	case "json":
-		slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
+		handler = slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
 			Level: level,
 		})
 	default:


Test patch:
diff --git a/cmd/dex/serve_test.go b/cmd/dex/serve_test.go
new file mode 100644
index 00000000..9e214480
--- /dev/null
+++ b/cmd/dex/serve_test.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+	"log/slog"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestNewLogger(t *testing.T) {
+	t.Run("JSON", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelInfo, "json")
+		require.NoError(t, err)
+		require.NotEqual(t, (*slog.Logger)(nil), logger)
+	})
+
+	t.Run("Text", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelError, "text")
+		require.NoError(t, err)
+		require.NotEqual(t, (*slog.Logger)(nil), logger)
+	})
+
+	t.Run("Unknown", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelError, "gofmt")
+		require.Error(t, err)
+		require.Equal(t, "log format is not one of the supported values (json, text): gofmt", err.Error())
+		require.Equal(t, (*slog.Logger)(nil), logger)
+	})
+}