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

chore: edit CLI/UI copy#2247

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
khorne3 merged 24 commits intomainfromcli-ui-copyedits
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
24 commits
Select commitHold shift + click to select a range
110ea81
chore: update CLI copy
Jun 10, 2022
ac10e6c
chore: update UI copy
Jun 10, 2022
0c21651
chore: escape apostrophe
Jun 10, 2022
953c542
chore: lint
Jun 10, 2022
2f0be80
Add template tooltips/kira pilot (#2308)
Kira-PilotJun 14, 2022
d602078
Merge branch 'main' into cli-ui-copyedits
Jun 14, 2022
dd94aca
chore: fix issues w/ merge conflict resolution
Jun 14, 2022
d2dcdd8
resolving in flight conflicts
Kira-PilotJun 14, 2022
4a2900f
formating server.go
Kira-PilotJun 14, 2022
d7d1a04
Merge remote-tracking branch 'origin/main' into cli-ui-copyedits
Kira-PilotJun 14, 2022
78b8f9b
Merge remote-tracking branch 'origin/main' into cli-ui-copyedits
Kira-PilotJun 14, 2022
f5e73a2
Apply suggestions from review
Jun 15, 2022
0f1e8c0
Merge branch 'main' into cli-ui-copyedits
Jun 15, 2022
4684bd1
chore: fix typos
Jun 15, 2022
6d4afa2
chore: update template definition
Jun 15, 2022
e4a6c04
chore: fix wording; lint
Jun 15, 2022
21d87a9
chore: expand defintion of provisioner-daemons
Jun 15, 2022
3cb014c
chore: update wording
Jun 15, 2022
a7927dc
Merge remote-tracking branch 'origin/main' into cli-ui-copyedits
Kira-PilotJun 15, 2022
43642ed
fix test
Kira-PilotJun 15, 2022
d8bc927
Merge remote-tracking branch 'origin/main' into cli-ui-copyedits
Kira-PilotJun 15, 2022
4e5067d
chore: remove provisioner daemons line
Jun 15, 2022
9400b2f
Merge branch 'main' into cli-ui-copyedits
Jun 15, 2022
555c636
Merge branch 'main' into cli-ui-copyedits
Jun 16, 2022
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
PrevPrevious commit
NextNext commit
Add template tooltips/kira pilot (#2308)
* feat: update build url to @username/workspace/builds/buildnumber (#2234)* update build url to @username/workspace/builds/buildnumber* update errors thrown from the API* add unit tests for the new API* add t.parallel* get username and workspace name from params* fix: update icon (#2216)* feat: Show template description in `coder template init` (#2238)* fix: workspace schedule time displays (#2249)Summary:Various time displays weren't quite right.Details:- Display date (not just time) of upcoming workspace stop in workspacepage- Fix ttlShutdownAt for various cases + tests  - manual to non-manual  - unchanged/unmodified  - isBefore --> isSameOrBefore  - use the delta (off by _ error)- pluralize units in dayjs.add* fix: Remove easter egg mentioning competitor (#2250)This is more confusing than helpful!* feat: Warn on coderd startup if access URL is localhost (#2248)* feat: use custom wireguard reverse proxy for dev tunnel (#1975)* fix: use correct link in create from template button (#2253)* feat: store and display template creator (#2228)* design commit* add owner_id to templates table* add owner information in apis and ui* update minWidth for statItem* rename owner to created_by* missing refactor to created_by* handle errors in fetching created_by names* feat: update language on workspace page (#2220)* fix: ensure config dir exists before reading tunnel config (#2259)* fix(devtunnel): close `http.Server` before wireguard interface (#2263)* fix: ensure `agentResource` is non-nil (#2261)* chore: add hero image to OSS docs homepage (#2241)* fix: Do not write 2 errors to api on template fetch error (#2285)* feat: add tooltips to templates pageresolves#2242Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>Co-authored-by: Joe Previte <jjprevite@gmail.com>Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>Co-authored-by: G r e y <grey@coder.com>Co-authored-by: Kyle Carberry <kyle@coder.com>Co-authored-by: David Wahler <david@coder.com>Co-authored-by: Colin Adler <colin1adler@gmail.com>Co-authored-by: Garrett Delfosse <garrett@coder.com>Co-authored-by: Katie Horne <katie@coder.com>Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
  • Loading branch information
@Kira-Pilot@AbhineetJain
@jsjoeio@mafredri@greyscaled@kylecarbs@dwahler@coadler@f0ssel@Emyrk
11 people authoredJun 14, 2022
commit2f0be801c5c94e025db34c3bc2464e9d201db289
76 changes: 71 additions & 5 deletionscli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,7 @@ import (
"golang.org/x/mod/semver"
"golang.org/x/oauth2"
xgithub "golang.org/x/oauth2/github"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"google.golang.org/api/idtoken"
"google.golang.org/api/option"
Expand DownExpand Up@@ -169,8 +170,9 @@ func server() *cobra.Command {
}

var (
tunnelErrChan <-chan error
ctxTunnel, closeTunnel = context.WithCancel(cmd.Context())
devTunnel = (*devtunnel.Tunnel)(nil)
devTunnelErrChan = make(<-chan error, 1)
)
defer closeTunnel()

Expand All@@ -197,14 +199,37 @@ func server() *cobra.Command {
}
}
if err == nil {
accessURL, tunnelErrChan, err = devtunnel.New(ctxTunnel,localURL)
devTunnel, devTunnelErrChan, err = devtunnel.New(ctxTunnel,logger.Named("devtunnel"))
if err != nil {
return xerrors.Errorf("create tunnel: %w", err)
}
accessURL = devTunnel.URL
}
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
}

// Warn the user if the access URL appears to be a loopback address.
isLocal, err := isLocalURL(cmd.Context(), accessURL)
if isLocal || err != nil {
var reason string
if isLocal {
reason = "appears to be a loopback address"
} else {
reason = "could not be resolved"
}
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), cliui.Styles.Wrap.Render(
cliui.Styles.Warn.Render("Warning:")+" The current access URL:")+"\n\n")
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), " "+cliui.Styles.Field.Render(accessURL)+"\n\n")
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), cliui.Styles.Wrap.Render(
reason+". Provisioned workspaces are unlikely to be able to "+
"connect to Coder. Please consider changing your "+
"access URL using the --access-url option, or directly "+
"specifying access URLs on templates.",
)+"\n\n")
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "For more information, see "+
"https://github.com/coder/coder/issues/1528\n\n")
}

validator, err := idtoken.NewValidator(cmd.Context(), option.WithoutAuthentication())
if err != nil {
return err
Expand DownExpand Up@@ -329,7 +354,27 @@ func server() *cobra.Command {
return shutdownConnsCtx
},
}
errCh <- server.Serve(listener)

wg := errgroup.Group{}
wg.Go(func() error {
// Make sure to close the tunnel listener if we exit so the
// errgroup doesn't wait forever!
if dev && tunnel {
defer devTunnel.Listener.Close()
}

return server.Serve(listener)
})

if dev && tunnel {
wg.Go(func() error {
defer listener.Close()

return server.Serve(devTunnel.Listener)
})
}

errCh <- wg.Wait()
}()

config := createConfig(cmd)
Expand DownExpand Up@@ -395,7 +440,7 @@ func server() *cobra.Command {
case <-cmd.Context().Done():
coderAPI.Close()
return cmd.Context().Err()
case err := <-tunnelErrChan:
case err := <-devTunnelErrChan:
if err != nil {
return err
}
Expand DownExpand Up@@ -458,7 +503,7 @@ func server() *cobra.Command {
if dev && tunnel {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"Waiting for dev tunnel to close...\n")
closeTunnel()
<-tunnelErrChan
<-devTunnelErrChan
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"Waiting for WebSocket connections to close...\n")
Expand DownExpand Up@@ -805,3 +850,24 @@ func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler,

return func() { _ = srv.Close() }
}

// isLocalURL returns true if the hostname of the provided URL appears to
// resolve to a loopback address.
func isLocalURL(ctx context.Context, urlString string) (bool, error) {
parsedURL, err := url.Parse(urlString)
if err != nil {
return false, err
}
resolver := &net.Resolver{}
ips, err := resolver.LookupIPAddr(ctx, parsedURL.Hostname())
if err != nil {
return false, err
}

for _, ip := range ips {
if ip.IP.IsLoopback() {
return true, nil
}
}
return false, nil
}
29 changes: 29 additions & 0 deletionscli/server_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,6 +118,9 @@ func TestServer(t *testing.T) {
} else {
t.Error("expected password line output; got no match")
}

// Verify that we warned the user about the default access URL possibly not being what they want.
assert.Contains(t, buf.String(), "coder/coder/issues/1528")
})

// Duplicated test from "Development" above to test setting email/password via env.
Expand DownExpand Up@@ -163,6 +166,32 @@ func TestServer(t *testing.T) {
assert.Contains(t, buf.String(), fmt.Sprintf("password: %s", wantPassword), "expected output %q; got no match", wantPassword)
})

t.Run("NoWarningWithRemoteAccessURL", func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()

root, cfg := clitest.New(t, "server", "--dev", "--tunnel=false", "--address", ":0", "--access-url", "http://1.2.3.4:3000/")
var buf strings.Builder
errC := make(chan error)
root.SetOutput(&buf)
go func() {
errC <- root.ExecuteContext(ctx)
}()

// Just wait for startup
require.Eventually(t, func() bool {
var err error
_, err = cfg.URL().Read()
return err == nil
}, 15*time.Second, 25*time.Millisecond)

cancelFunc()
require.ErrorIs(t, <-errC, context.Canceled)

assert.NotContains(t, buf.String(), "coder/coder/issues/1528")
})

t.Run("TLSBadVersion", func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
Expand Down
9 changes: 7 additions & 2 deletionscli/templateinit.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,8 +24,13 @@ func templateInit() *cobra.Command {
exampleNames := []string{}
exampleByName := map[string]examples.Example{}
for _, example := range exampleList {
exampleNames = append(exampleNames, example.Name)
exampleByName[example.Name] = example
name := fmt.Sprintf(
"%s\n%s\n",
cliui.Styles.Bold.Render(example.Name),
cliui.Styles.Wrap.Copy().PaddingLeft(6).Render(example.Description),
)
exampleNames = append(exampleNames, name)
exampleByName[name] = example
}

_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Wrap.Render(
Expand Down
24 changes: 0 additions & 24 deletionscmd/coder/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,17 +4,13 @@ import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
_ "time/tzdata"

"github.com/coder/coder/cli"
"github.com/coder/coder/cli/cliui"
)

func main() {
dadjoke()
cmd, err := cli.Root().ExecuteC()
if err != nil {
if errors.Is(err, cliui.Canceled) {
Expand All@@ -25,23 +21,3 @@ func main() {
os.Exit(1)
}
}

//nolint
func dadjoke() {
if os.Getenv("EEOFF") != "" || filepath.Base(os.Args[0]) != "gitpod" {
return
}

args := strings.Fields(`run -it --rm git --image=index.docker.io/bitnami/git --command --restart=Never -- git`)
args = append(args, os.Args[1:]...)
cmd := exec.Command("kubectl", args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
_ = cmd.Start()
err := cmd.Wait()
if exitErr, ok := err.(*exec.ExitError); ok {
os.Exit(exitErr.ExitCode())
}
os.Exit(0)
}
2 changes: 2 additions & 0 deletionscoderd/audit/diff_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,6 +88,7 @@ func TestDiff(t *testing.T) {
ActiveVersionID: uuid.UUID{3},
MaxTtl: int64(time.Hour),
MinAutostartInterval: int64(time.Minute),
CreatedBy: uuid.NullUUID{UUID: uuid.UUID{4}, Valid: true},
},
exp: audit.Map{
"id": uuid.UUID{1}.String(),
Expand All@@ -97,6 +98,7 @@ func TestDiff(t *testing.T) {
"active_version_id": uuid.UUID{3}.String(),
"max_ttl": int64(3600000000000),
"min_autostart_interval": int64(60000000000),
"created_by": uuid.UUID{4}.String(),
},
},
})
Expand Down
1 change: 1 addition & 0 deletionscoderd/audit/table.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ var AuditableResources = auditMap(map[any]map[string]Action{
"description": ActionTrack,
"max_ttl": ActionTrack,
"min_autostart_interval": ActionTrack,
"created_by": ActionTrack,
},
&database.TemplateVersion{}: {
"id": ActionTrack,
Expand Down
5 changes: 4 additions & 1 deletioncoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -270,7 +270,10 @@ func New(options *Options) *API {
r.Get("/", api.organizationsByUser)
r.Get("/{organizationname}", api.organizationByUserAndName)
})
r.Get("/workspace/{workspacename}", api.workspaceByOwnerAndName)
r.Route("/workspace/{workspacename}", func(r chi.Router) {
r.Get("/", api.workspaceByOwnerAndName)
r.Get("/builds/{buildnumber}", api.workspaceBuildByBuildNumber)
})
r.Get("/gitsshkey", api.gitSSHKey)
r.Put("/gitsshkey", api.regenerateGitSSHKey)
})
Expand Down
6 changes: 6 additions & 0 deletionscoderd/coderd_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import (
"context"
"io"
"net/http"
"strconv"
"strings"
"testing"
"time"
Expand DownExpand Up@@ -163,6 +164,10 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
AssertObject: rbac.ResourceWorkspace,
AssertAction: rbac.ActionRead,
},
"GET:/api/v2/users/me/workspace/{workspacename}/builds/{buildnumber}": {
AssertObject: rbac.ResourceWorkspace,
AssertAction: rbac.ActionRead,
},
"GET:/api/v2/workspaces/{workspace}/builds/{workspacebuildname}": {
AssertAction: rbac.ActionRead,
AssertObject: workspaceRBACObj,
Expand DownExpand Up@@ -388,6 +393,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
route = strings.ReplaceAll(route, "{workspacename}", workspace.Name)
route = strings.ReplaceAll(route, "{workspacebuildname}", workspace.LatestBuild.Name)
route = strings.ReplaceAll(route, "{workspaceagent}", workspaceResources[0].Agents[0].ID.String())
route = strings.ReplaceAll(route, "{buildnumber}", strconv.FormatInt(int64(workspace.LatestBuild.BuildNumber), 10))
route = strings.ReplaceAll(route, "{template}", template.ID.String())
route = strings.ReplaceAll(route, "{hash}", file.Hash)
route = strings.ReplaceAll(route, "{workspaceresource}", workspaceResources[0].ID.String())
Expand Down
17 changes: 17 additions & 0 deletionscoderd/database/databasefake/databasefake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -625,6 +625,22 @@ func (q *fakeQuerier) GetWorkspaceBuildByWorkspaceIDAndName(_ context.Context, a
return database.WorkspaceBuild{}, sql.ErrNoRows
}

func (q *fakeQuerier) GetWorkspaceBuildByWorkspaceIDAndBuildNumber(_ context.Context, arg database.GetWorkspaceBuildByWorkspaceIDAndBuildNumberParams) (database.WorkspaceBuild, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()

for _, workspaceBuild := range q.workspaceBuilds {
if workspaceBuild.WorkspaceID.String() != arg.WorkspaceID.String() {
continue
}
if workspaceBuild.BuildNumber != arg.BuildNumber {
continue
}
return workspaceBuild, nil
}
return database.WorkspaceBuild{}, sql.ErrNoRows
}

func (q *fakeQuerier) GetWorkspacesByOrganizationIDs(_ context.Context, req database.GetWorkspacesByOrganizationIDsParams) ([]database.Workspace, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()
Expand DownExpand Up@@ -1325,6 +1341,7 @@ func (q *fakeQuerier) InsertTemplate(_ context.Context, arg database.InsertTempl
Description: arg.Description,
MaxTtl: arg.MaxTtl,
MinAutostartInterval: arg.MinAutostartInterval,
CreatedBy: arg.CreatedBy,
}
q.templates = append(q.templates, template)
return template, nil
Expand Down
6 changes: 5 additions & 1 deletioncoderd/database/dump.sql
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
ALTER TABLE ONLY templates DROP COLUMN IF EXISTS created_by;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
ALTER TABLE ONLY templates ADD COLUMN IF NOT EXISTS created_by uuid REFERENCES users (id) ON DELETE RESTRICT;
1 change: 1 addition & 0 deletionscoderd/database/models.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionscoderd/database/querier.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp