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

Docs#93

Merged
cmoog merged 4 commits intomasterfromdocs
Aug 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
14 changes: 14 additions & 0 deletions.github/workflows/test.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,17 @@ jobs:
uses: ./ci/image
with:
args: go test ./internal/... ./cmd/...
gendocs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: generate-docs
uses: ./ci/image
with:
args: ./ci/steps/gendocs.sh
8 changes: 6 additions & 2 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,14 @@

`coder` is a command line utility for Coder Enterprise.

To view usage documentation, head over to [https://enterprise.coder.com](https://enterprise.coder.com/docs/getting-started).

To report bugs and request features, please [open an issue](https://github.com/cdr/coder-cli/issues/new).

## Usage

View the `coder-cli` documentation [here](./docs/coder.md).

You can find additional Coder Enterprise usage documentation on [https://enterprise.coder.com](https://enterprise.coder.com/docs/getting-started).

## Install Release

Download the latest [release](https://github.com/cdr/coder-cli/releases):
Expand Down
33 changes: 10 additions & 23 deletionsci/integration/devurls_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,36 +3,23 @@ package integration
import (
"context"
"testing"
"time"

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

func TestDevURLCLI(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
defer cancel()

c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{
Image: "codercom/enterprise-dev",
Name: "coder-cli-devurl-tests",
BindMounts: map[string]string{
binpath: "/bin/coder",
},
run(t, "coder-cli-devurl-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
c.Run(ctx, "which coder").Assert(t,
tcli.Success(),
tcli.StdoutMatches("/usr/sbin/coder"),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder urls ls").Assert(t,
tcli.Error(),
)
})
assert.Success(t, "new run container", err)
defer c.Close()

c.Run(ctx, "which coder").Assert(t,
tcli.Success(),
tcli.StdoutMatches("/usr/sbin/coder"),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder urls ls").Assert(t,
tcli.Error(),
)

// The following cannot be enabled nor verified until either the
// integration testing dogfood target has environments created, or
Expand Down
127 changes: 69 additions & 58 deletionsci/integration/integration_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,67 +10,78 @@ import (
"cdr.dev/slog/sloggers/slogtest/assert"
)

func run(t *testing.T, container string, execute func(t *testing.T, ctx context.Context, runner *tcli.ContainerRunner)) {
t.Run(container, func(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
defer cancel()

c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{
Image: "codercom/enterprise-dev",
Name: container,
BindMounts: map[string]string{
binpath: "/bin/coder",
},
})
assert.Success(t, "new run container", err)
defer c.Close()

execute(t, ctx, c)
})
}

func TestCoderCLI(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
defer cancel()

c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{
Image: "codercom/enterprise-dev",
Name: "coder-cli-tests",
BindMounts: map[string]string{
binpath: "/bin/coder",
},
run(t, "test-coder-cli", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
c.Run(ctx, "which coder").Assert(t,
tcli.Success(),
tcli.StdoutMatches("/usr/sbin/coder"),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder --version").Assert(t,
tcli.StderrEmpty(),
tcli.Success(),
tcli.StdoutMatches("linux"),
)

c.Run(ctx, "coder --help").Assert(t,
tcli.Success(),
tcli.StdoutMatches("Available Commands"),
)

headlessLogin(ctx, t, c)

c.Run(ctx, "coder envs").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder envs ls").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder urls").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder sync").Assert(t,
tcli.Error(),
)

c.Run(ctx, "coder sh").Assert(t,
tcli.Error(),
)

c.Run(ctx, "coder logout").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder envs ls").Assert(t,
tcli.Error(),
)
})
assert.Success(t, "new run container", err)
defer c.Close()

c.Run(ctx, "which coder").Assert(t,
tcli.Success(),
tcli.StdoutMatches("/usr/sbin/coder"),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder --version").Assert(t,
tcli.StderrEmpty(),
tcli.Success(),
tcli.StdoutMatches("linux"),
)

c.Run(ctx, "coder --help").Assert(t,
tcli.Success(),
tcli.StdoutMatches("Available Commands"),
)

headlessLogin(ctx, t, c)

c.Run(ctx, "coder envs").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder envs ls").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder urls").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder sync").Assert(t,
tcli.Error(),
)

c.Run(ctx, "coder sh").Assert(t,
tcli.Error(),
)

c.Run(ctx, "coder logout").Assert(t,
tcli.Success(),
)

c.Run(ctx, "coder envs ls").Assert(t,
tcli.Error(),
)

}

var seededRand = rand.New(rand.NewSource(time.Now().UnixNano()))
Expand Down
146 changes: 66 additions & 80 deletionsci/integration/secrets_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,91 +5,77 @@ import (
"fmt"
"regexp"
"testing"
"time"

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

func TestSecrets(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
defer cancel()

c, err := tcli.NewContainerRunner(ctx, &tcli.ContainerConfig{
Image: "codercom/enterprise-dev",
Name: "secrets-cli-tests",
BindMounts: map[string]string{
binpath: "/bin/coder",
},
run(t, "secrets-cli-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
headlessLogin(ctx, t, c)

c.Run(ctx, "coder secrets ls").Assert(t,
tcli.Success(),
)

name, value := randString(8), randString(8)

c.Run(ctx, "coder secrets create").Assert(t,
tcli.Error(),
)

// this tests the "Value:" prompt fallback
c.Run(ctx, fmt.Sprintf("echo %s | coder secrets create %s --from-prompt", value, name)).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder secrets ls").Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
tcli.StdoutMatches("Value"),
tcli.StdoutMatches(regexp.QuoteMeta(name)),
)

c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)

c.Run(ctx, "coder secrets rm").Assert(t,
tcli.Error(),
)
c.Run(ctx, "coder secrets rm "+name).Assert(t,
tcli.Success(),
)
c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Error(),
tcli.StdoutEmpty(),
)

name, value = randString(8), randString(8)

c.Run(ctx, fmt.Sprintf("coder secrets create %s --from-literal %s", name, value)).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)

name, value = randString(8), randString(8)
c.Run(ctx, fmt.Sprintf("echo %s > ~/secret.json", value)).Assert(t,
tcli.Success(),
)
c.Run(ctx, fmt.Sprintf("coder secrets create %s --from-file ~/secret.json", name)).Assert(t,
tcli.Success(),
)
c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)
})
assert.Success(t, "new run container", err)
defer c.Close()

headlessLogin(ctx, t, c)

c.Run(ctx, "coder secrets ls").Assert(t,
tcli.Success(),
)

name, value := randString(8), randString(8)

c.Run(ctx, "coder secrets create").Assert(t,
tcli.Error(),
)

// this tests the "Value:" prompt fallback
c.Run(ctx, fmt.Sprintf("echo %s | coder secrets create %s --from-prompt", value, name)).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder secrets ls").Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
tcli.StdoutMatches("Value"),
tcli.StdoutMatches(regexp.QuoteMeta(name)),
)

c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)

c.Run(ctx, "coder secrets rm").Assert(t,
tcli.Error(),
)
c.Run(ctx, "coder secrets rm "+name).Assert(t,
tcli.Success(),
)
c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Error(),
tcli.StdoutEmpty(),
)

name, value = randString(8), randString(8)

c.Run(ctx, fmt.Sprintf("coder secrets create %s --from-literal %s", name, value)).Assert(t,
tcli.Success(),
tcli.StderrEmpty(),
)

c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)

name, value = randString(8), randString(8)
c.Run(ctx, fmt.Sprintf("echo %s > ~/secret.json", value)).Assert(t,
tcli.Success(),
)
c.Run(ctx, fmt.Sprintf("coder secrets create %s --from-file ~/secret.json", name)).Assert(t,
tcli.Success(),
)
//
c.Run(ctx, "coder secrets view "+name).Assert(t,
tcli.Success(),
tcli.StdoutMatches(regexp.QuoteMeta(value)),
)
}
18 changes: 18 additions & 0 deletionsci/integration/ssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
package integration

import (
"context"
"testing"

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

func TestSSH(t *testing.T) {
t.Parallel()
run(t, "ssh-coder-cli-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
headlessLogin(ctx, t, c)
c.Run(ctx, "coder config-ssh").Assert(t,
tcli.Success(),
)
})
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp