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

Add template tooltips/kira pilot#2308

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
Kira-Pilot merged 17 commits intocli-ui-copyeditsfromadd-template-tooltips/kira-pilot
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
b2833c6
feat: update build url to @username/workspace/builds/buildnumber (#2234)
AbhineetJainJun 10, 2022
fcc5284
fix: update icon (#2216)
jsjoeioJun 10, 2022
1a9e572
feat: Show template description in `coder template init` (#2238)
mafredriJun 10, 2022
928958c
fix: workspace schedule time displays (#2249)
greyscaledJun 10, 2022
f79ab7f
fix: Remove easter egg mentioning competitor (#2250)
kylecarbsJun 10, 2022
71fd196
feat: Warn on coderd startup if access URL is localhost (#2248)
dwahlerJun 10, 2022
f562b74
feat: use custom wireguard reverse proxy for dev tunnel (#1975)
coadlerJun 10, 2022
46da59a
fix: use correct link in create from template button (#2253)
f0sselJun 10, 2022
02d2aea
feat: store and display template creator (#2228)
AbhineetJainJun 10, 2022
ec0bb7b
feat: update language on workspace page (#2220)
Kira-PilotJun 10, 2022
de6f86b
fix: ensure config dir exists before reading tunnel config (#2259)
coadlerJun 10, 2022
8415022
fix(devtunnel): close `http.Server` before wireguard interface (#2263)
coadlerJun 10, 2022
e3a1cd3
fix: ensure `agentResource` is non-nil (#2261)
coadlerJun 11, 2022
cbde8e8
chore: add hero image to OSS docs homepage (#2241)
Jun 13, 2022
49f8578
fix: Do not write 2 errors to api on template fetch error (#2285)
EmyrkJun 13, 2022
e207286
Merge remote-tracking branch 'origin/main' into add-template-tooltips…
Kira-PilotJun 13, 2022
fe20e25
feat: add tooltips to templates page
Kira-PilotJun 13, 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
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<-chanerror
ctxTunnel,closeTunnel=context.WithCancel(cmd.Context())
devTunnel= (*devtunnel.Tunnel)(nil)
devTunnelErrChan=make(<-chanerror,1)
)
defercloseTunnel()

Expand All@@ -197,14 +199,37 @@ func server() *cobra.Command {
}
}
iferr==nil {
accessURL,tunnelErrChan,err=devtunnel.New(ctxTunnel,localURL)
devTunnel,devTunnelErrChan,err=devtunnel.New(ctxTunnel,logger.Named("devtunnel"))
iferr!=nil {
returnxerrors.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)
ifisLocal||err!=nil {
varreasonstring
ifisLocal {
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())
iferr!=nil {
returnerr
Expand DownExpand Up@@ -329,7 +354,27 @@ func server() *cobra.Command {
returnshutdownConnsCtx
},
}
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!
ifdev&&tunnel {
deferdevTunnel.Listener.Close()
}

returnserver.Serve(listener)
})

ifdev&&tunnel {
wg.Go(func()error {
deferlistener.Close()

returnserver.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()
returncmd.Context().Err()
caseerr:=<-tunnelErrChan:
caseerr:=<-devTunnelErrChan:
iferr!=nil {
returnerr
}
Expand DownExpand Up@@ -458,7 +503,7 @@ func server() *cobra.Command {
ifdev&&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,

returnfunc() {_=srv.Close() }
}

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

for_,ip:=rangeips {
ifip.IP.IsLoopback() {
returntrue,nil
}
}
returnfalse,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())
defercancelFunc()

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

// Just wait for startup
require.Eventually(t,func()bool {
varerrerror
_,err=cfg.URL().Read()
returnerr==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:=rangeexampleList {
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"
)

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

//nolint
funcdadjoke() {
ifos.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()
ifexitErr,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()
deferq.mutex.RUnlock()

for_,workspaceBuild:=rangeq.workspaceBuilds {
ifworkspaceBuild.WorkspaceID.String()!=arg.WorkspaceID.String() {
continue
}
ifworkspaceBuild.BuildNumber!=arg.BuildNumber {
continue
}
returnworkspaceBuild,nil
}
return database.WorkspaceBuild{},sql.ErrNoRows
}

func (q*fakeQuerier)GetWorkspacesByOrganizationIDs(_ context.Context,req database.GetWorkspacesByOrganizationIDsParams) ([]database.Workspace,error) {
q.mutex.RLock()
deferq.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)
returntemplate,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 @@
ALTERTABLE ONLY templates DROP COLUMN IF EXISTS created_by;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
ALTERTABLE ONLY templates ADD COLUMN IF NOT EXISTS created_by uuidREFERENCES 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