diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 30ec28db..d459563d 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -45,12 +45,12 @@ jobs:
- name: Test
run: |
- go test -c ./internal/daemon
+ go test -c ./internals/daemon
PEBBLE_TEST_USER=runner PEBBLE_TEST_GROUP=runner sudo -E ./daemon.test -check.v -check.f ^execSuite\.TestUserGroup$
PEBBLE_TEST_USER=runner PEBBLE_TEST_GROUP=runner sudo -E ./daemon.test -check.v -check.f ^execSuite\.TestUserIDGroupID$
PEBBLE_TEST_USER=runner PEBBLE_TEST_GROUP=runner sudo -E ./daemon.test -check.v -check.f ^filesSuite\.TestWriteUserGroupReal$
PEBBLE_TEST_USER=runner PEBBLE_TEST_GROUP=runner sudo -E ./daemon.test -check.v -check.f ^filesSuite\.TestMakeDirsUserGroupReal$
- go test -c ./internal/overlord/servstate/
+ go test -c ./internals/overlord/servstate/
PEBBLE_TEST_USER=runner PEBBLE_TEST_GROUP=runner sudo -E ./servstate.test -check.v -check.f ^S.TestUserGroup$
format:
diff --git a/client/client.go b/client/client.go
index a9fde3ad..0e9cce91 100644
--- a/client/client.go
+++ b/client/client.go
@@ -31,7 +31,7 @@ import (
"github.com/gorilla/websocket"
- "github.com/canonical/pebble/internal/wsutil"
+ "github.com/canonical/pebble/internals/wsutil"
)
// SocketNotFoundError is the error type returned when the client fails
diff --git a/client/exec.go b/client/exec.go
index 98c02d63..4b74242d 100644
--- a/client/exec.go
+++ b/client/exec.go
@@ -23,7 +23,7 @@ import (
"io/ioutil"
"time"
- "github.com/canonical/pebble/internal/wsutil"
+ "github.com/canonical/pebble/internals/wsutil"
)
type ExecOptions struct {
diff --git a/cmd/pebble/main.go b/cmd/pebble/main.go
index c83224cd..2d874728 100644
--- a/cmd/pebble/main.go
+++ b/cmd/pebble/main.go
@@ -15,424 +15,15 @@
package main
import (
- "errors"
"fmt"
- "io"
"os"
- "os/user"
- "path/filepath"
- "strings"
- "unicode"
- "unicode/utf8"
- "github.com/canonical/go-flags"
-
- "golang.org/x/crypto/ssh/terminal"
-
- "github.com/canonical/pebble/client"
- "github.com/canonical/pebble/internal/logger"
-)
-
-var (
- // Standard streams, redirected for testing.
- Stdin io.Reader = os.Stdin
- Stdout io.Writer = os.Stdout
- Stderr io.Writer = os.Stderr
- // overridden for testing
- ReadPassword = terminal.ReadPassword
- // set to logger.Panicf in testing
- noticef = logger.Noticef
+ "github.com/canonical/pebble/internals/cli"
)
-// defaultPebbleDir is the Pebble directory used if $PEBBLE is not set. It is
-// created by the daemon ("pebble run") if it doesn't exist, and also used by
-// the pebble client.
-const defaultPebbleDir = "/var/lib/pebble/default"
-
-type options struct {
- Version func() `long:"version"`
-}
-
-type argDesc struct {
- name string
- desc string
-}
-
-var optionsData options
-
-// ErrExtraArgs is returned if extra arguments to a command are found
-var ErrExtraArgs = fmt.Errorf("too many arguments for command")
-
-// cmdInfo holds information needed to call parser.AddCommand(...).
-type cmdInfo struct {
- name, shortHelp, longHelp string
- builder func() flags.Commander
- hidden bool
- optDescs map[string]string
- argDescs []argDesc
- alias string
- extra func(*flags.Command)
-}
-
-// commands holds information about all non-debug commands.
-var commands []*cmdInfo
-
-// debugCommands holds information about all debug commands.
-var debugCommands []*cmdInfo
-
-// addCommand replaces parser.addCommand() in a way that is compatible with
-// re-constructing a pristine parser.
-func addCommand(name, shortHelp, longHelp string, builder func() flags.Commander, optDescs map[string]string, argDescs []argDesc) *cmdInfo {
- info := &cmdInfo{
- name: name,
- shortHelp: shortHelp,
- longHelp: longHelp,
- builder: builder,
- optDescs: optDescs,
- argDescs: argDescs,
- }
- commands = append(commands, info)
- return info
-}
-
-// addDebugCommand replaces parser.addCommand() in a way that is
-// compatible with re-constructing a pristine parser. It is meant for
-// adding debug commands.
-func addDebugCommand(name, shortHelp, longHelp string, builder func() flags.Commander, optDescs map[string]string, argDescs []argDesc) *cmdInfo {
- info := &cmdInfo{
- name: name,
- shortHelp: shortHelp,
- longHelp: longHelp,
- builder: builder,
- optDescs: optDescs,
- argDescs: argDescs,
- }
- debugCommands = append(debugCommands, info)
- return info
-}
-
-type parserSetter interface {
- setParser(*flags.Parser)
-}
-
-func lintDesc(cmdName, optName, desc, origDesc string) {
- if len(optName) == 0 {
- logger.Panicf("option on %q has no name", cmdName)
- }
- if len(origDesc) != 0 {
- logger.Panicf("description of %s's %q of %q set from tag", cmdName, optName, origDesc)
- }
- if len(desc) > 0 {
- // decode the first rune instead of converting all of desc into []rune
- r, _ := utf8.DecodeRuneInString(desc)
- // note IsLower != !IsUpper for runes with no upper/lower.
- if unicode.IsLower(r) && !strings.HasPrefix(desc, "login.ubuntu.com") && !strings.HasPrefix(desc, cmdName) {
- noticef("description of %s's %q is lowercase: %q", cmdName, optName, desc)
- }
- }
-}
-
-func lintArg(cmdName, optName, desc, origDesc string) {
- lintDesc(cmdName, optName, desc, origDesc)
- if len(optName) > 0 && optName[0] == '<' && optName[len(optName)-1] == '>' {
- return
- }
- if len(optName) > 0 && optName[0] == '<' && strings.HasSuffix(optName, ">s") {
- // see comment in fixupArg about the >s case
- return
- }
- noticef("argument %q's %q should begin with < and end with >", cmdName, optName)
-}
-
-func fixupArg(optName string) string {
- // Due to misunderstanding some localized versions of option name are
- // literally "