Skip to content

Commit

Permalink
Remove a bunch of snapd references (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Sep 7, 2021
1 parent a31f640 commit 4c5d8c1
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 281 deletions.
8 changes: 4 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ type doer interface {
Do(*http.Request) (*http.Response, error)
}

// Config allows to customize client behavior.
// Config allows the user to customize client behavior.
type Config struct {
// BaseURL contains the base URL where snappy daemon is expected to be.
// BaseURL contains the base URL where the pebble daemon is expected to be.
// It can be empty for a default behavior of talking over a unix socket.
BaseURL string

Expand All @@ -65,11 +65,11 @@ type Config struct {
// alive for later reuse
DisableKeepAlive bool

// User-Agent to sent to the snapd daemon
// User-Agent to sent to the pebble daemon
UserAgent string
}

// A Client knows how to talk to the snappy daemon.
// A Client knows how to talk to the pebble daemon.
type Client struct {
baseURL url.URL
doer doer
Expand Down
4 changes: 2 additions & 2 deletions client/warnings.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type jsonWarning struct {
RepeatAfter string `json:"repeat-after,omitempty"`
}

// WarningsOptions contains options for querying snapd for warnings
// WarningsOptions contains options for querying pebble for warnings
// supported options:
// - All: return all warnings, instead of only the un-okayed ones.
type WarningsOptions struct {
Expand Down Expand Up @@ -71,7 +71,7 @@ type warningsAction struct {
Timestamp time.Time `json:"timestamp"`
}

// Okay asks snapd to chill about the warnings that would have been returned by
// Okay asks pebble to chill about the warnings that would have been returned by
// Warnings at the given time.
func (client *Client) Okay(t time.Time) error {
var body bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion cmd/pebble/cmd_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var fakeChangesJSON = `{"type": "sync", "result": [
},
{
"id": "one",
"kind": "remove-snap",
"kind": "remove",
"summary": "...",
"status": "Do",
"ready": false,
Expand Down
4 changes: 1 addition & 3 deletions cmd/pebble/cmd_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (s *PebbleSuite) TestVersionCommand(c *C) {
fmt.Fprintln(w, `{"type":"sync","status-code":200,"status":"OK","result":{"version":"7.89"}}`)
})

restore := fakeArgs("snap", "version")
defer restore()
restore = fakeVersion("4.56")
restore := fakeVersion("4.56")
defer restore()

_, err := pebble.Parser(pebble.Client()).ParseArgs([]string{"version"})
Expand Down
242 changes: 0 additions & 242 deletions cmd/pebble/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
package main

import (
//"os/user"
//"time"

//"github.com/jessevdk/go-flags"

"github.com/canonical/pebble/client"
)

Expand All @@ -31,173 +26,19 @@ func Client() *client.Client {
return client.New(ClientConfig)
}

const WriteLogBufSize = writeLogBufSize

var (
//FirstNonOptionIsRun = firstNonOptionIsRun

//CreateUserDataDirs = createUserDataDirs
//ResolveApp = resolveApp
//SnapdHelperPath = snapdHelperPath
//SortByPath = sortByPath
//AdviseCommand = adviseCommand
//Antialias = antialias
//FormatChannel = fmtChannel
//PrintDescr = printDescr
//WrapFlow = wrapFlow
//TrueishJSON = trueishJSON

CanUnicode = canUnicode
ColorTable = colorTable
MonoColorTable = mono
ColorColorTable = color
NoEscColorTable = noesc
//ColorMixinGetEscapes = (colorMixin).getEscapes
//FillerPublisher = fillerPublisher
//LongPublisher = longPublisher
//ShortPublisher = shortPublisher

//ReadRpc = readRpc

WriteWarningTimestamp = writeWarningTimestamp
MaybePresentWarnings = maybePresentWarnings

//LongSnapDescription = longSnapDescription
//SnapUsage = snapUsage
//SnapHelpCategoriesIntro = snapHelpCategoriesIntro
//SnapHelpAllFooter = snapHelpAllFooter
//SnapHelpFooter = snapHelpFooter
//HelpCategories = helpCategories

//LintArg = lintArg
//LintDesc = lintDesc

//FixupArg = fixupArg

//InterfacesDeprecationNotice = interfacesDeprecationNotice

GetEnvPaths = getEnvPaths
)

//func NewInfoWriter(w writeflusher) *infoWriter {
// return &infoWriter{
// writeflusher: w,
// termWidth: 20,
// esc: &escapes{dash: "--", tick: "*"},
// fmtTime: func(t time.Time) string { return t.Format(time.Kitchen) },
// }
//}
//
//func SetVerbose(iw *infoWriter, verbose bool) {
// iw.verbose = verbose
//}
//
//var (
// ClientSnapFromPath = clientSnapFromPath
// SetupDiskSnap = (*infoWriter).setupDiskSnap
// SetupSnap = (*infoWriter).setupSnap
// MaybePrintServices = (*infoWriter).maybePrintServices
// MaybePrintCommands = (*infoWriter).maybePrintCommands
// MaybePrintType = (*infoWriter).maybePrintType
// PrintSummary = (*infoWriter).printSummary
// MaybePrintPublisher = (*infoWriter).maybePrintPublisher
// MaybePrintNotes = (*infoWriter).maybePrintNotes
// MaybePrintStandaloneVersion = (*infoWriter).maybePrintStandaloneVersion
// MaybePrintBuildDate = (*infoWriter).maybePrintBuildDate
// MaybePrintContact = (*infoWriter).maybePrintContact
// MaybePrintBase = (*infoWriter).maybePrintBase
// MaybePrintPath = (*infoWriter).maybePrintPath
// MaybePrintSum = (*infoWriter).maybePrintSum
// MaybePrintCohortKey = (*infoWriter).maybePrintCohortKey
// MaybePrintHealth = (*infoWriter).maybePrintHealth
//)
//
//func MockPollTime(d time.Duration) (restore func()) {
// d0 := pollTime
// pollTime = d
// return func() {
// pollTime = d0
// }
//}
//
//func MockMaxGoneTime(d time.Duration) (restore func()) {
// d0 := maxGoneTime
// maxGoneTime = d
// return func() {
// maxGoneTime = d0
// }
//}
//
//func MockSyscallExec(f func(string, []string, []string) error) (restore func()) {
// syscallExecOrig := syscallExec
// syscallExec = f
// return func() {
// syscallExec = syscallExecOrig
// }
//}
//
//func MockUserCurrent(f func() (*user.User, error)) (restore func()) {
// userCurrentOrig := userCurrent
// userCurrent = f
// return func() {
// userCurrent = userCurrentOrig
// }
//}
//
//func MockStoreNew(f func(*store.Config, store.DeviceAndAuthContext) *store.Store) (restore func()) {
// storeNewOrig := storeNew
// storeNew = f
// return func() {
// storeNew = storeNewOrig
// }
//}
//
//func MockGetEnv(f func(name string) string) (restore func()) {
// osGetenvOrig := osGetenv
// osGetenv = f
// return func() {
// osGetenv = osGetenvOrig
// }
//}
//
//func MockMountInfoPath(newMountInfoPath string) (restore func()) {
// mountInfoPathOrig := mountInfoPath
// mountInfoPath = newMountInfoPath
// return func() {
// mountInfoPath = mountInfoPathOrig
// }
//}
//
//func MockOsReadlink(f func(string) (string, error)) (restore func()) {
// osReadlinkOrig := osReadlink
// osReadlink = f
// return func() {
// osReadlink = osReadlinkOrig
// }
//}
//
//var AutoImportCandidates = autoImportCandidates
//
//func AliasInfoLess(snapName1, alias1, cmd1, snapName2, alias2, cmd2 string) bool {
// x := aliasInfos{
// &aliasInfo{
// Snap: snapName1,
// Alias: alias1,
// Command: cmd1,
// },
// &aliasInfo{
// Snap: snapName2,
// Alias: alias2,
// Command: cmd2,
// },
// }
// return x.Less(0, 1)
//}
//
//func AssertTypeNameCompletion(match string) []flags.Completion {
// return assertTypeName("").Complete(match)
//}

func FakeIsStdoutTTY(t bool) (restore func()) {
oldIsStdoutTTY := isStdoutTTY
isStdoutTTY = t
Expand All @@ -213,86 +54,3 @@ func FakeIsStdinTTY(t bool) (restore func()) {
isStdinTTY = oldIsStdinTTY
}
}

//func MockTimeNow(newTimeNow func() time.Time) (restore func()) {
// oldTimeNow := timeNow
// timeNow = newTimeNow
// return func() {
// timeNow = oldTimeNow
// }
//}
//
//func MockTimeutilHuman(h func(time.Time) string) (restore func()) {
// oldH := timeutilHuman
// timeutilHuman = h
// return func() {
// timeutilHuman = oldH
// }
//}
//
//func MockWaitConfTimeout(d time.Duration) (restore func()) {
// oldWaitConfTimeout := d
// waitConfTimeout = d
// return func() {
// waitConfTimeout = oldWaitConfTimeout
// }
//}
//
//func Wait(cli *client.Client, id string) (*client.Change, error) {
// wmx := waitMixin{}
// wmx.client = cli
// return wmx.wait(id)
//}
//
//func ColorMixin(cmode, umode string) colorMixin {
// return colorMixin{
// Color: cmode,
// unicodeMixin: unicodeMixin{Unicode: umode},
// }
//}
//
//func CmdAdviseSnap() *cmdAdviseSnap {
// return &cmdAdviseSnap{}
//}
//
//func MockSELinuxIsEnabled(isEnabled func() (bool, error)) (restore func()) {
// old := selinuxIsEnabled
// selinuxIsEnabled = isEnabled
// return func() {
// selinuxIsEnabled = old
// }
//}
//
//func MockSELinuxVerifyPathContext(verifypathcon func(string) (bool, error)) (restore func()) {
// old := selinuxVerifyPathContext
// selinuxVerifyPathContext = verifypathcon
// return func() {
// selinuxVerifyPathContext = old
// }
//}
//
//func MockSELinuxRestoreContext(restorecon func(string, selinux.RestoreMode) error) (restore func()) {
// old := selinuxRestoreContext
// selinuxRestoreContext = restorecon
// return func() {
// selinuxRestoreContext = old
// }
//}
//
//func MockTermSize(newTermSize func() (int, int)) (restore func()) {
// old := termSize
// termSize = newTermSize
// return func() {
// termSize = old
// }
//}
//
//func MockImagePrepare(newImagePrepare func(*image.Options) error) (restore func()) {
// old := imagePrepare
// imagePrepare = newImagePrepare
// return func() {
// imagePrepare = old
// }
//}
//
//type ServiceName = serviceName
12 changes: 6 additions & 6 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func (d *Daemon) Stop(sigCh chan<- os.Signal) error {
// those open requests resulted in something that
// prevents us from going into socket activation mode.
//
// If this is the case we do a "normal" snapd restart
// If this is the case we do a "normal" pebble restart
// to process the new changes.
if !d.standbyOpinions.CanStandby() {
d.restartSocket = false
Expand All @@ -555,7 +555,7 @@ func (d *Daemon) Stop(sigCh chan<- os.Signal) error {
if err != nil {
// do not stop the shutdown even if the tomb errors
// because we already scheduled a slow shutdown and
// exiting here will just restart snapd (via systemd)
// exiting here will just restart pebble (via systemd)
// which will lead to confusing results.
if restartSystem {
logger.Noticef("WARNING: cannot stop daemon: %v", err)
Expand Down Expand Up @@ -589,7 +589,7 @@ func (d *Daemon) rebootDelay() (time.Duration, error) {
if err == nil {
rebootDelay = rebootAt.Sub(now)
} else {
ovr := os.Getenv("SNAPD_REBOOT_DELAY") // for tests
ovr := os.Getenv("PEBBLE_REBOOT_DELAY") // for tests
if ovr != "" {
d, err := time.ParseDuration(ovr)
if err == nil {
Expand All @@ -608,7 +608,7 @@ func (d *Daemon) doReboot(sigCh chan<- os.Signal, waitTimeout time.Duration) err
return err
}
// ask for shutdown and wait for it to happen.
// if we exit snapd will be restared by systemd
// if we exit, pebble will be restarted by systemd
if err := reboot(rebootDelay); err != nil {
return err
}
Expand Down Expand Up @@ -674,12 +674,12 @@ func (d *Daemon) RebootIsMissing(st *state.State) error {
// might get rolled back!!
st.ClearReboot()
clearReboot(st)
logger.Noticef("snapd was restarted while a system restart was expected, snapd retried to schedule and waited again for a system restart %d times and is giving up", rebootMaxTentatives)
logger.Noticef("pebble was restarted while a system restart was expected, pebble retried to schedule and waited again for a system restart %d times and is giving up", rebootMaxTentatives)
return nil
}
st.Set("daemon-system-restart-tentative", nTentative)
d.state = st
logger.Noticef("snapd was restarted while a system restart was expected, snapd will try to schedule and wait for a system restart again (tenative %d/%d)", nTentative, rebootMaxTentatives)
logger.Noticef("pebble was restarted while a system restart was expected, pebble will try to schedule and wait for a system restart again (tenative %d/%d)", nTentative, rebootMaxTentatives)
return state.ErrExpectedReboot
}

Expand Down

0 comments on commit 4c5d8c1

Please sign in to comment.