Skip to content

Commit 7fc1570

Browse files
committed
Move buildinfo route into coderd.go
1 parent 63dfcf1 commit 7fc1570

File tree

4 files changed

+23
-35
lines changed

4 files changed

+23
-35
lines changed

coderd/buildinfo.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

coderd/buildinfo_test.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

coderd/coderd.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ import (
77
"time"
88

99
"github.com/go-chi/chi/v5"
10+
"github.com/go-chi/render"
1011
"google.golang.org/api/idtoken"
1112

1213
chitrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/go-chi/chi.v5"
1314

1415
"cdr.dev/slog"
16+
"github.com/coder/coder/cli/buildinfo"
1517
"github.com/coder/coder/coderd/awsidentity"
1618
"github.com/coder/coder/coderd/database"
1719
"github.com/coder/coder/coderd/httpapi"
1820
"github.com/coder/coder/coderd/httpmw"
21+
"github.com/coder/coder/codersdk"
1922
"github.com/coder/coder/site"
2023
)
2124

@@ -211,3 +214,9 @@ type api struct {
211214
websocketWaitMutex sync.Mutex
212215
websocketWaitGroup sync.WaitGroup
213216
}
217+
218+
func (*api) buildInfo(rw http.ResponseWriter, r *http.Request) {
219+
render.JSON(rw, r, codersdk.BuildInfoResponse{
220+
Version: buildinfo.Version(),
221+
})
222+
}

coderd/coderd_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package coderd_test
22

33
import (
4+
"context"
45
"testing"
56

67
"go.uber.org/goleak"
8+
9+
"github.com/stretchr/testify/require"
10+
11+
"github.com/coder/coder/cli/buildinfo"
12+
"github.com/coder/coder/coderd/coderdtest"
713
)
814

915
func TestMain(m *testing.M) {
1016
goleak.VerifyTestMain(m)
1117
}
18+
19+
func TestBuildInfo(t *testing.T) {
20+
t.Parallel()
21+
client := coderdtest.New(t, nil)
22+
buildInfo, err := client.BuildInfo(context.Background())
23+
require.NoError(t, err)
24+
require.Equal(t, buildinfo.Version(), buildInfo.Version, "version")
25+
}

0 commit comments

Comments
 (0)