-
Notifications
You must be signed in to change notification settings - Fork 905
feat: add version to footer #882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2b100e6
Add endpoint for getting build info
code-asher 6fef81f
Add build info XService
code-asher c79bdd2
Add version to page footer
code-asher 201c264
Sort buildinfo route alphabetically
code-asher 63dfcf1
Unnest buildinfo route test
code-asher 7fc1570
Move buildinfo route into coderd.go
code-asher 0eac736
Ensure 200 on buildinfo route
code-asher 0479d34
Add frontend mock for buildinfo route
code-asher 123d523
Sort BuildInfoResponse alphabetically
code-asher cfc4bb8
Inline buildinfo route handler
code-asher fc65c10
Skip version line when there is no build info
code-asher aa96e28
Add language object to footer
code-asher 409ff77
Lift buildinfo
code-asher 57f6787
Add external url to build info response
code-asher 987b89d
Link footer build info to external url
code-asher 4c31058
Add TODO for adding retry to frontend API calls
code-asher 86d4a01
Add missing return type
code-asher d540e09
Merge remote-tracking branch 'origin/main' into asher/footer
code-asher 228ab5e
Run make fmt
code-asher 78d3e2e
Merge remote-tracking branch 'origin/main' into asher/footer
code-asher 49adf16
Remove todo in favor of GitHub issue
code-asher 55833fb
Clear build info on error
code-asher 20c7be3
Add success and failure states to buildInfo machine
code-asher adfea9e
Merge remote-tracking branch 'origin/main' into asher/footer
code-asher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
package coderd_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"go.uber.org/goleak" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/coder/coder/buildinfo" | ||
"github.com/coder/coder/coderd/coderdtest" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
goleak.VerifyTestMain(m) | ||
} | ||
|
||
func TestBuildInfo(t *testing.T) { | ||
t.Parallel() | ||
client := coderdtest.New(t, nil) | ||
buildInfo, err := client.BuildInfo(context.Background()) | ||
require.NoError(t, err) | ||
require.Equal(t, buildinfo.ExternalURL(), buildInfo.ExternalURL, "external URL") | ||
require.Equal(t, buildinfo.Version(), buildInfo.Version, "version") | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package codersdk | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"net/http" | ||
) | ||
|
||
// BuildInfoResponse contains build information for this instance of Coder. | ||
type BuildInfoResponse struct { | ||
// ExternalURL is a URL referencing the current Coder version. For production | ||
// builds, this will link directly to a release. For development builds, this | ||
// will link to a commit. | ||
ExternalURL string `json:"external_url"` | ||
// Version returns the semantic version of the build. | ||
Version string `json:"version"` | ||
} | ||
|
||
// BuildInfo returns build information for this instance of Coder. | ||
func (c *Client) BuildInfo(ctx context.Context) (BuildInfoResponse, error) { | ||
res, err := c.request(ctx, http.MethodGet, "/api/v2/buildinfo", nil) | ||
if err != nil { | ||
return BuildInfoResponse{}, err | ||
} | ||
defer res.Body.Close() | ||
|
||
if res.StatusCode != http.StatusOK { | ||
return BuildInfoResponse{}, readBodyAsError(res) | ||
} | ||
|
||
var buildInfo BuildInfoResponse | ||
return buildInfo, json.NewDecoder(res.Body).Decode(&buildInfo) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { assign, createMachine } from "xstate" | ||
import * as API from "../../api" | ||
import * as Types from "../../api/types" | ||
|
||
export interface BuildInfoContext { | ||
getBuildInfoError?: Error | unknown | ||
buildInfo?: Types.BuildInfoResponse | ||
} | ||
|
||
export const buildInfoMachine = createMachine( | ||
{ | ||
tsTypes: {} as import("./buildInfoXService.typegen").Typegen0, | ||
schema: { | ||
context: {} as BuildInfoContext, | ||
services: {} as { | ||
getBuildInfo: { | ||
data: Types.BuildInfoResponse | ||
} | ||
}, | ||
}, | ||
context: { | ||
buildInfo: undefined, | ||
}, | ||
id: "buildInfoState", | ||
initial: "gettingBuildInfo", | ||
states: { | ||
code-asher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
gettingBuildInfo: { | ||
code-asher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
invoke: { | ||
src: "getBuildInfo", | ||
id: "getBuildInfo", | ||
onDone: [ | ||
{ | ||
actions: ["assignBuildInfo", "clearGetBuildInfoError"], | ||
target: "#buildInfoState.success", | ||
}, | ||
], | ||
onError: [ | ||
{ | ||
actions: ["assignGetBuildInfoError", "clearBuildInfo"], | ||
target: "#buildInfoState.failure", | ||
}, | ||
], | ||
}, | ||
}, | ||
success: { | ||
type: "final", | ||
}, | ||
failure: { | ||
type: "final", | ||
}, | ||
}, | ||
}, | ||
{ | ||
services: { | ||
getBuildInfo: API.getBuildInfo, | ||
}, | ||
actions: { | ||
assignBuildInfo: assign({ | ||
buildInfo: (_, event) => event.data, | ||
}), | ||
clearBuildInfo: assign((context: BuildInfoContext) => ({ | ||
...context, | ||
buildInfo: undefined, | ||
})), | ||
assignGetBuildInfoError: assign({ | ||
getBuildInfoError: (_, event) => event.data, | ||
}), | ||
clearGetBuildInfoError: assign((context: BuildInfoContext) => ({ | ||
...context, | ||
getBuildInfoError: undefined, | ||
})), | ||
}, | ||
}, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.