Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Improve version warning log#206

Merged
cmoog merged 3 commits intomasterfromimprove-warning-error
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioncoder-sdk/version.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import (
// APIVersion parses the coder-version http header from an authenticated request.
func (c Client) APIVersion(ctx context.Context) (string, error) {
const coderVersionHeaderKey = "coder-version"
resp, err := c.request(ctx, http.MethodGet, "/api/private/users/"+Me, nil)
resp, err := c.request(ctx, http.MethodGet, "/api", nil)
if err != nil {
return "", err
}
Expand Down
21 changes: 12 additions & 9 deletionsinternal/cmd/auth.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,6 +53,9 @@ func newClient(ctx context.Context) (*coder.Client, error) {
}

apiVersion, err := c.APIVersion(ctx)
if apiVersion != "" && !version.VersionsMatch(apiVersion) {
logVersionMismatchError(apiVersion)
}
if err != nil {
var he *coder.HTTPError
if xerrors.As(err, &he) {
Expand All@@ -63,14 +66,14 @@ func newClient(ctx context.Context) (*coder.Client, error) {
return nil, err
}

if !version.VersionsMatch(apiVersion) {
clog.LogWarn(
"version mismatch detected",
fmt.Sprintf("coder-cli version: %s", version.Version),
fmt.Sprintf("Coder API version: %s", apiVersion), clog.BlankLine,
clog.Tipf("download the appropriate version here: https://github.com/cdr/coder-cli/releases"),
)
}

return c, nil
}

func logVersionMismatchError(apiVersion string) {
clog.LogWarn(
"version mismatch detected",
fmt.Sprintf("Coder CLI version: %s", version.Version),
fmt.Sprintf("Coder API version: %s", apiVersion), clog.BlankLine,
clog.Tipf("download the appropriate version here: https://github.com/cdr/coder-cli/releases"),
)
}
9 changes: 8 additions & 1 deletioninternal/cmd/login.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ import (
"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/config"
"cdr.dev/coder-cli/internal/loginsrv"
"cdr.dev/coder-cli/internal/version"
"cdr.dev/coder-cli/pkg/clog"
"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand DownExpand Up@@ -64,7 +65,13 @@ func newLocalListener() (net.Listener, error) {
// Not using the SDK as we want to verify the url/token pair before storing the config files.
func pingAPI(ctx context.Context, envURL *url.URL, token string) error {
client := &coder.Client{BaseURL: envURL, Token: token}
if _, err := client.Me(ctx); err != nil {
if apiVersion, err := client.APIVersion(ctx); err == nil {
if apiVersion != "" && !version.VersionsMatch(apiVersion) {
logVersionMismatchError(apiVersion)
}
}
_, err := client.Me(ctx)
if err != nil {
return xerrors.Errorf("call api: %w", err)
}
return nil
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp