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

Restructure go util packages#166

Merged
cmoog merged 5 commits intomasterfromrestructure
Nov 2, 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
6 changes: 3 additions & 3 deletions.golangci.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,6 @@ linters-settings:
settings:
printf:
funcs: # Run `go tool vet help printf` to see available settings for `printf` analyzer.
- (cdr.dev/coder-cli/internal/clog).Tipf
- (cdr.dev/coder-cli/internal/clog).Hintf
- (cdr.dev/coder-cli/internal/clog).Causef
- (cdr.dev/coder-cli/pkg/clog).Tipf
- (cdr.dev/coder-cli/pkg/clog).Hintf
- (cdr.dev/coder-cli/pkg/clog).Causef
2 changes: 1 addition & 1 deletionci/integration/devurls_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import (
"context"
"testing"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/pkg/tcli"
)

func TestDevURLCLI(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletionci/integration/envs_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,8 @@ import (
"testing"
"time"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/pkg/tcli"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"cdr.dev/slog/sloggers/slogtest/assert"
Expand Down
2 changes: 1 addition & 1 deletionci/integration/integration_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import (
"testing"
"time"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/pkg/tcli"
"cdr.dev/slog/sloggers/slogtest/assert"
)

Expand Down
2 changes: 1 addition & 1 deletionci/integration/secrets_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import (
"regexp"
"testing"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/pkg/tcli"
)

func TestSecrets(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletionci/integration/setup_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ import (
"strings"
"testing"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/pkg/tcli"
"golang.org/x/xerrors"
)

Expand Down
2 changes: 1 addition & 1 deletionci/integration/ssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@ import (
"context"
"testing"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/pkg/tcli"
)

func TestSSH(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletionci/integration/users_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@ import (
"context"
"testing"

"cdr.dev/coder-cli/ci/tcli"
"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/pkg/tcli"
"cdr.dev/slog/sloggers/slogtest/assert"
)

Expand Down
2 changes: 1 addition & 1 deletioncmd/coder/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,10 @@ import (
"os"
"runtime"

"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/cmd"
"cdr.dev/coder-cli/internal/version"
"cdr.dev/coder-cli/internal/x/xterminal"
"cdr.dev/coder-cli/pkg/clog"
)

func main() {
Expand Down
10 changes: 5 additions & 5 deletionscoder-sdk/devurl.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,11 +8,11 @@ import (

// DevURL is the parsed json response record for a devURL from cemanager.
type DevURL struct {
ID string `json:"id"tab:"ID"`
URL string `json:"url"tab:"URL"`
Port int `json:"port"tab:"Port"`
Access string `json:"access"tab:"Access"`
Name string `json:"name"tab:"Name"`
ID string `json:"id"table:"ID"`
URL string `json:"url"table:"URL"`
Port int `json:"port"table:"Port"`
Access string `json:"access"table:"Access"`
Name string `json:"name"table:"Name"`
}

type delDevURLRequest struct {
Expand Down
40 changes: 20 additions & 20 deletionscoder-sdk/env.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,32 +13,32 @@ import (

// Environment describes a Coder environment
type Environment struct {
ID string `json:"id"tab:"-"`
Name string `json:"name"tab:"Name"`
ImageID string `json:"image_id"tab:"-"`
ImageTag string `json:"image_tag"tab:"ImageTag"`
OrganizationID string `json:"organization_id"tab:"-"`
UserID string `json:"user_id"tab:"-"`
LastBuiltAt time.Time `json:"last_built_at"tab:"-"`
CPUCores float32 `json:"cpu_cores"tab:"CPUCores"`
MemoryGB float32 `json:"memory_gb"tab:"MemoryGB"`
DiskGB int `json:"disk_gb"tab:"DiskGB"`
GPUs int `json:"gpus"tab:"GPUs"`
Updating bool `json:"updating"tab:"Updating"`
LatestStat EnvironmentStat `json:"latest_stat"tab:"Status"`
RebuildMessages []RebuildMessage `json:"rebuild_messages"tab:"-"`
CreatedAt time.Time `json:"created_at"tab:"-"`
UpdatedAt time.Time `json:"updated_at"tab:"-"`
LastOpenedAt time.Time `json:"last_opened_at"tab:"-"`
LastConnectionAt time.Time `json:"last_connection_at"tab:"-"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold"tab:"-"`
ID string `json:"id"table:"-"`
Name string `json:"name"table:"Name"`
ImageID string `json:"image_id"table:"-"`
ImageTag string `json:"image_tag"table:"ImageTag"`
OrganizationID string `json:"organization_id"table:"-"`
UserID string `json:"user_id"table:"-"`
LastBuiltAt time.Time `json:"last_built_at"table:"-"`
CPUCores float32 `json:"cpu_cores"table:"CPUCores"`
MemoryGB float32 `json:"memory_gb"table:"MemoryGB"`
DiskGB int `json:"disk_gb"table:"DiskGB"`
GPUs int `json:"gpus"table:"GPUs"`
Updating bool `json:"updating"table:"Updating"`
LatestStat EnvironmentStat `json:"latest_stat"table:"Status"`
RebuildMessages []RebuildMessage `json:"rebuild_messages"table:"-"`
CreatedAt time.Time `json:"created_at"table:"-"`
UpdatedAt time.Time `json:"updated_at"table:"-"`
LastOpenedAt time.Time `json:"last_opened_at"table:"-"`
LastConnectionAt time.Time `json:"last_connection_at"table:"-"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold"table:"-"`
}

// RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
type RebuildMessage struct {
Text string `json:"text"`
Required bool `json:"required"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold"tab:"-"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold"table:"-"`
}

// EnvironmentStat represents the state of an environment
Expand Down
12 changes: 6 additions & 6 deletionscoder-sdk/secrets.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,12 +8,12 @@ import (

// Secret describes a Coder secret
type Secret struct {
ID string `json:"id"tab:"-"`
Name string `json:"name"tab:"Name"`
Value string `json:"value,omitempty"tab:"Value"`
Description string `json:"description"tab:"Description"`
CreatedAt time.Time `json:"created_at"tab:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at"tab:"-"`
ID string `json:"id"table:"-"`
Name string `json:"name"table:"Name"`
Value string `json:"value,omitempty"table:"Value"`
Description string `json:"description"table:"Description"`
CreatedAt time.Time `json:"created_at"table:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at"table:"-"`
}

// Secrets gets all secrets for the given user
Expand Down
12 changes: 6 additions & 6 deletionscoder-sdk/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,12 +8,12 @@ import (

// User describes a Coder user account.
type User struct {
ID string `json:"id"tab:"-"`
Email string `json:"email"tab:"Email"`
Username string `json:"username"tab:"Username"`
Name string `json:"name"tab:"Name"`
CreatedAt time.Time `json:"created_at"tab:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at"tab:"-"`
ID string `json:"id"table:"-"`
Email string `json:"email"table:"Email"`
Username string `json:"username"table:"Username"`
Name string `json:"name"table:"Name"`
CreatedAt time.Time `json:"created_at"table:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at"table:"-"`
}

// Me gets the details of the authenticated user.
Expand Down
2 changes: 1 addition & 1 deletioninternal/activity/pusher.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import (
"golang.org/x/time/rate"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/pkg/clog"
)

const pushInterval = time.Minute
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/auth.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ import (
"golang.org/x/xerrors"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/config"
"cdr.dev/coder-cli/internal/version"
"cdr.dev/coder-cli/pkg/clog"
)

var errNeedLogin = clog.Fatal(
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/ceapi.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import (
"strings"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/pkg/clog"
"golang.org/x/xerrors"
)

Expand Down
6 changes: 3 additions & 3 deletionsinternal/cmd/envs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@ import (
"os"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/x/xtabwriter"
"cdr.dev/coder-cli/pkg/clog"
"cdr.dev/coder-cli/pkg/tablewriter"

"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
Expand DownExpand Up@@ -62,7 +62,7 @@ func lsEnvsCommand(user *string) *cobra.Command {

switch outputFmt {
case "human":
err :=xtabwriter.WriteTable(len(envs), func(i int) interface{} {
err :=tablewriter.WriteTable(len(envs), func(i int) interface{} {
return envs[i]
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/login.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ import (
"strings"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/config"
"cdr.dev/coder-cli/internal/loginsrv"
"cdr.dev/coder-cli/pkg/clog"
"github.com/pkg/browser"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/logout.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,8 @@ package cmd
import (
"os"

"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/config"
"cdr.dev/coder-cli/pkg/clog"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
)
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/rebuild.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import (
"time"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/pkg/clog"
"github.com/briandowns/spinner"
"github.com/fatih/color"
"github.com/manifoldco/promptui"
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/resourcemanager.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import (
"text/tabwriter"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/pkg/clog"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
)
Expand Down
6 changes: 3 additions & 3 deletionsinternal/cmd/secrets.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,8 @@ import (
"golang.org/x/xerrors"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/x/xtabwriter"
"cdr.dev/coder-cli/pkg/clog"
"cdr.dev/coder-cli/pkg/tablewriter"
)

func secretsCmd() *cobra.Command {
Expand DownExpand Up@@ -159,7 +159,7 @@ func listSecretsCmd(userEmail *string) func(cmd *cobra.Command, _ []string) erro
return nil
}

err =xtabwriter.WriteTable(len(secrets), func(i int) interface{} {
err =tablewriter.WriteTable(len(secrets), func(i int) interface{} {
s := secrets[i]
s.Value = "******" // value is omitted from bulk responses
return s
Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/shell.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,8 @@ import (

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/activity"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/x/xterminal"
"cdr.dev/coder-cli/pkg/clog"
"cdr.dev/wsep"
)

Expand Down
2 changes: 1 addition & 1 deletioninternal/cmd/sync.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,8 @@ import (
"strings"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/sync"
"cdr.dev/coder-cli/pkg/clog"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
)
Expand Down
16 changes: 8 additions & 8 deletionsinternal/cmd/urls.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,8 +14,8 @@ import (
"golang.org/x/xerrors"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/internal/x/xtabwriter"
"cdr.dev/coder-cli/pkg/clog"
"cdr.dev/coder-cli/pkg/tablewriter"
)

func urlCmd() *cobra.Command {
Expand DownExpand Up@@ -51,11 +51,11 @@ func urlCmd() *cobra.Command {

// DevURL is the parsed json response record for a devURL from cemanager
type DevURL struct {
ID string `json:"id"tab:"-"`
URL string `json:"url"tab:"URL"`
Port int `json:"port"tab:"Port"`
Name string `json:"name"tab:"-"`
Access string `json:"access"tab:"Access"`
ID string `json:"id"table:"-"`
URL string `json:"url"table:"URL"`
Port int `json:"port"table:"Port"`
Name string `json:"name"table:"-"`
Access string `json:"access"table:"Access"`
}

var urlAccessLevel = map[string]string{
Expand DownExpand Up@@ -104,7 +104,7 @@ func listDevURLsCmd(outputFmt *string) func(cmd *cobra.Command, args []string) e
clog.LogInfo(fmt.Sprintf("no devURLs found for environment %q", envName))
return nil
}
err :=xtabwriter.WriteTable(len(devURLs), func(i int) interface{} {
err :=tablewriter.WriteTable(len(devURLs), func(i int) interface{} {
return devURLs[i]
})
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletionsinternal/cmd/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,9 @@ import (
"encoding/json"
"os"

"cdr.dev/coder-cli/pkg/tablewriter"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"cdr.dev/coder-cli/internal/x/xtabwriter"
)

func usersCmd() *cobra.Command {
Expand DownExpand Up@@ -47,7 +46,7 @@ func listUsers(outputFmt *string) func(cmd *cobra.Command, args []string) error
case "human":
// For each element, return the user.
each := func(i int) interface{} { return users[i] }
if err :=xtabwriter.WriteTable(len(users), each); err != nil {
if err :=tablewriter.WriteTable(len(users), each); err != nil {
return xerrors.Errorf("write table: %w", err)
}
case "json":
Expand Down
2 changes: 1 addition & 1 deletioninternal/sync/sync.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ import (

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/activity"
"cdr.dev/coder-cli/internal/clog"
"cdr.dev/coder-cli/pkg/clog"
"cdr.dev/wsep"
)

Expand Down
2 changes: 1 addition & 1 deletioninternal/clog/doc.go → pkg/clog/doc.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
//package clog provides rich error types and logging helpers for coder-cli.
//Package clog provides rich error types and logging helpers for coder-cli.
//
// clog encourages returning error types rather than
// logging them and failing with os.Exit as they happen.
Expand Down
File renamed without changes.
File renamed without changes.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp