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: update v1 schema#643

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
coadler merged 3 commits intomainfromcolin/uuid-schema
Apr 1, 2022
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
1 change: 1 addition & 0 deletions.golangci.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -187,6 +187,7 @@ linters-settings:
- t
- id
- wg
- Me
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>" for
# variables, or "const <name>" for constants.
Expand Down
1 change: 1 addition & 0 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ build: site/out bin
# Runs migrations to output a dump of the database.
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
go run coderd/database/dump/main.go
.PHONY: coderd/database/dump.sql

# Generates Go code for querying the database.
coderd/database/generate: fmt/sql coderd/database/dump.sql coderd/database/query.sql
Expand Down
2 changes: 1 addition & 1 deletioncli/configssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ func configSSH() *cobra.Command {
sshConfigContent = sshConfigContent[:startIndex-1] + sshConfigContent[endIndex+len(sshEndToken):]
}

workspaces, err := client.WorkspacesByUser(cmd.Context(),"")
workspaces, err := client.WorkspacesByUser(cmd.Context(),codersdk.Me)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletioncli/configssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/pty/ptytest"
)

Expand All@@ -21,7 +22,7 @@ func TestConfigSSH(t *testing.T) {
version := coderdtest.CreateProjectVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
tempFile, err := os.CreateTemp(t.TempDir(), "")
require.NoError(t, err)
Expand Down
12 changes: 6 additions & 6 deletionscli/login.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,10 +119,10 @@ func login() *cobra.Command {
}

_, err = client.CreateFirstUser(cmd.Context(), codersdk.CreateFirstUserRequest{
Email: email,
Username: username,
Organization: username,
Password: password,
Email:email,
Username:username,
OrganizationName: username,
Password:password,
})
if err != nil {
return xerrors.Errorf("create initial user: %w", err)
Expand DownExpand Up@@ -167,7 +167,7 @@ func login() *cobra.Command {
Secret: true,
Validate: func(token string) error {
client.SessionToken = token
_, err := client.User(cmd.Context(),"me")
_, err := client.User(cmd.Context(),codersdk.Me)
if err != nil {
return xerrors.New("That's not a valid token!")
}
Expand All@@ -180,7 +180,7 @@ func login() *cobra.Command {

// Login to get user data - verify it is OK before persisting
client.SessionToken = sessionToken
resp, err := client.User(cmd.Context(),"me")
resp, err := client.User(cmd.Context(),codersdk.Me)
if err != nil {
return xerrors.Errorf("get user: %w", err)
}
Expand Down
28 changes: 16 additions & 12 deletionscli/parameters.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ package cli
import (
"context"

"github.com/google/uuid"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

Expand All@@ -20,42 +21,45 @@ func parameters() *cobra.Command {
return cmd
}

func parseScopeAndID(ctx context.Context, client *codersdk.Client, organization codersdk.Organization, rawScope string, name string) (codersdk.ParameterScope,string, error) {
func parseScopeAndID(ctx context.Context, client *codersdk.Client, organization codersdk.Organization, rawScope string, name string) (codersdk.ParameterScope,uuid.UUID, error) {
scope, err := parseParameterScope(rawScope)
if err != nil {
return scope,"", err
return scope,uuid.Nil, err
}
var scopeID string

var scopeID uuid.UUID
switch scope {
case codersdk.ParameterOrganization:
if name == "" {
scopeID = organization.ID
} else {
org, err := client.OrganizationByName(ctx,"", name)
org, err := client.OrganizationByName(ctx,codersdk.Me, name)
if err != nil {
return scope,"", err
return scope,uuid.Nil, err
}
scopeID = org.ID
}
case codersdk.ParameterProject:
project, err := client.ProjectByName(ctx, organization.ID, name)
if err != nil {
return scope,"", err
return scope,uuid.Nil, err
}
scopeID = project.ID.String()
scopeID = project.ID
case codersdk.ParameterUser:
user, err := client.User(ctx, name)
uid, _ := uuid.Parse(name)
user, err := client.User(ctx, uid)
if err != nil {
return scope,"", err
return scope,uuid.Nil, err
}
scopeID = user.ID
case codersdk.ParameterWorkspace:
workspace, err := client.WorkspaceByName(ctx,"", name)
workspace, err := client.WorkspaceByName(ctx,codersdk.Me, name)
if err != nil {
return scope,"", err
return scope,uuid.Nil, err
}
scopeID = workspace.ID.String()
scopeID = workspace.ID
}

return scope, scopeID, nil
}

Expand Down
2 changes: 1 addition & 1 deletioncli/root.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ func createClient(cmd *cobra.Command) (*codersdk.Client, error) {

// currentOrganization returns the currently active organization for the authenticated user.
func currentOrganization(cmd *cobra.Command, client *codersdk.Client) (codersdk.Organization, error) {
orgs, err := client.OrganizationsByUser(cmd.Context(),"me")
orgs, err := client.OrganizationsByUser(cmd.Context(),codersdk.Me)
if err != nil {
return codersdk.Organization{}, nil
}
Expand Down
14 changes: 13 additions & 1 deletioncli/ssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,33 +32,40 @@ func ssh() *cobra.Command {
if err != nil {
return err
}
workspace, err := client.WorkspaceByName(cmd.Context(), "", args[0])

workspace, err := client.WorkspaceByName(cmd.Context(), codersdk.Me, args[0])
if err != nil {
return err
}

if workspace.LatestBuild.Transition != database.WorkspaceTransitionStart {
return xerrors.New("workspace must be in start transition to ssh")
}

if workspace.LatestBuild.Job.CompletedAt == nil {
err = cliui.WorkspaceBuild(cmd.Context(), cmd.ErrOrStderr(), client, workspace.LatestBuild.ID, workspace.CreatedAt)
if err != nil {
return err
}
}

if workspace.LatestBuild.Transition == database.WorkspaceTransitionDelete {
return xerrors.New("workspace is deleting...")
}

resources, err := client.WorkspaceResourcesByBuild(cmd.Context(), workspace.LatestBuild.ID)
if err != nil {
return err
}

resourceByAddress := make(map[string]codersdk.WorkspaceResource)
for _, resource := range resources {
if resource.Agent == nil {
continue
}
resourceByAddress[resource.Address] = resource
}

var resourceAddress string
if len(args) >= 2 {
resourceAddress = args[1]
Expand All@@ -73,6 +80,7 @@ func ssh() *cobra.Command {
break
}
}

resource, exists := resourceByAddress[resourceAddress]
if !exists {
resourceKeys := make([]string, 0)
Expand DownExpand Up@@ -100,6 +108,7 @@ func ssh() *cobra.Command {
return err
}
defer conn.Close()

if stdio {
rawSSH, err := conn.SSH()
if err != nil {
Expand DownExpand Up@@ -135,13 +144,16 @@ func ssh() *cobra.Command {
if err != nil {
return err
}

sshSession.Stdin = cmd.InOrStdin()
sshSession.Stdout = cmd.OutOrStdout()
sshSession.Stderr = cmd.OutOrStdout()

err = sshSession.Shell()
if err != nil {
return err
}

err = sshSession.Wait()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletionscli/ssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,7 +53,7 @@ func TestSSH(t *testing.T) {
})
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
go func() {
// Run this async so the SSH command has to wait for
// the build and agent to connect!
Expand DownExpand Up@@ -111,7 +111,7 @@ func TestSSH(t *testing.T) {
})
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
go func() {
// Run this async so the SSH command has to wait for
// the build and agent to connect!
Expand Down
10 changes: 5 additions & 5 deletionscli/start.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -255,7 +255,7 @@ func start() *cobra.Command {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "\n\n"+cliui.Styles.Bold.Render("Interrupt caught. Gracefully exiting..."))

if dev {
workspaces, err := client.WorkspacesByUser(cmd.Context(),"")
workspaces, err := client.WorkspacesByUser(cmd.Context(),codersdk.Me)
if err != nil {
return xerrors.Errorf("get workspaces: %w", err)
}
Expand DownExpand Up@@ -343,10 +343,10 @@ func start() *cobra.Command {

func createFirstUser(cmd *cobra.Command, client *codersdk.Client, cfg config.Root) error {
_, err := client.CreateFirstUser(cmd.Context(), codersdk.CreateFirstUserRequest{
Email: "admin@coder.com",
Username: "developer",
Password: "password",
Organization: "acme-corp",
Email:"admin@coder.com",
Username:"developer",
Password:"password",
OrganizationName: "acme-corp",
})
if err != nil {
return xerrors.Errorf("create first user: %w", err)
Expand Down
14 changes: 7 additions & 7 deletionscli/start_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,10 +59,10 @@ func TestStart(t *testing.T) {
return true
}, 15*time.Second, 25*time.Millisecond)
_, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{
Email: "some@one.com",
Username: "example",
Password: "password",
Organization: "example",
Email:"some@one.com",
Username:"example",
Password:"password",
OrganizationName: "example",
})
require.NoError(t, err)
cancelFunc()
Expand DownExpand Up@@ -90,7 +90,7 @@ func TestStart(t *testing.T) {
require.NoError(t, err)
client := codersdk.New(parsed)
client.SessionToken = token
_, err = client.User(ctx,"")
_, err = client.User(ctx,codersdk.Me)
require.NoError(t, err)
})
t.Run("TLSBadVersion", func(t *testing.T) {
Expand DownExpand Up@@ -182,15 +182,15 @@ func TestStart(t *testing.T) {
require.NoError(t, err)
client := codersdk.New(parsed)
client.SessionToken = token
orgs, err := client.OrganizationsByUser(ctx,"")
orgs, err := client.OrganizationsByUser(ctx,codersdk.Me)
require.NoError(t, err)
coderdtest.NewProvisionerDaemon(t, client)

// Create a workspace so the cleanup occurs!
version := coderdtest.CreateProjectVersion(t, client, orgs[0].ID, nil)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
project := coderdtest.CreateProject(t, client, orgs[0].ID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)

require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletionscli/workspaceagent_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
)
Expand DownExpand Up@@ -43,7 +44,7 @@ func TestWorkspaceAgent(t *testing.T) {
})
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"me", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)

cmd, _ := clitest.New(t, "workspaces", "agent", "--auth", "aws-instance-identity", "--url", client.URL.String())
Expand DownExpand Up@@ -97,7 +98,7 @@ func TestWorkspaceAgent(t *testing.T) {
})
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client,"me", project.ID)
workspace := coderdtest.CreateWorkspace(t, client,codersdk.Me, project.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)

cmd, _ := clitest.New(t, "workspaces", "agent", "--auth", "google-instance-identity", "--url", client.URL.String())
Expand Down
4 changes: 2 additions & 2 deletionscli/workspacecreate.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,7 +74,7 @@ func workspaceCreate() *cobra.Command {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"Creating with the "+cliui.Styles.Field.Render(project.Name)+" project...")

workspaceName := args[0]
_, err = client.WorkspaceByName(cmd.Context(),"", workspaceName)
_, err = client.WorkspaceByName(cmd.Context(),codersdk.Me, workspaceName)
if err == nil {
return xerrors.Errorf("A workspace already exists named %q!", workspaceName)
}
Expand DownExpand Up@@ -137,7 +137,7 @@ func workspaceCreate() *cobra.Command {
}

before := time.Now()
workspace, err := client.CreateWorkspace(cmd.Context(),"", codersdk.CreateWorkspaceRequest{
workspace, err := client.CreateWorkspace(cmd.Context(),codersdk.Me, codersdk.CreateWorkspaceRequest{
ProjectID: project.ID,
Name: workspaceName,
ParameterValues: parameters,
Expand Down
2 changes: 1 addition & 1 deletioncli/workspacedelete.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ func workspaceDelete() *cobra.Command {
if err != nil {
return err
}
workspace, err := client.WorkspaceByName(cmd.Context(),"", args[0])
workspace, err := client.WorkspaceByName(cmd.Context(),codersdk.Me, args[0])
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletioncli/workspacelist.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"

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

func workspaceList() *cobra.Command {
Expand All@@ -21,7 +22,7 @@ func workspaceList() *cobra.Command {
return err
}
start := time.Now()
workspaces, err := client.WorkspacesByUser(cmd.Context(),"")
workspaces, err := client.WorkspacesByUser(cmd.Context(),codersdk.Me)
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletioncli/workspaces.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,8 @@ import (
"strings"

"github.com/spf13/cobra"

"github.com/coder/coder/codersdk"
)

func workspaces() *cobra.Command {
Expand All@@ -29,7 +31,7 @@ func validArgsWorkspaceName(cmd *cobra.Command, _ []string, toComplete string) (
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
workspaces, err := client.WorkspacesByUser(cmd.Context(),"")
workspaces, err := client.WorkspacesByUser(cmd.Context(),codersdk.Me)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp