Skip to content

Commit

Permalink
environs: drop Environ.BootstrapMessage method
Browse files Browse the repository at this point in the history
The Environ.BootstrapMessage method was added
as a means of logging a message at bootstrap
time in the LXD provider. The added method is
redundant, as we already pass context to the
Bootstrap method, which the provider can use
to show messages to the user.

We drop the BootstrapMessage method, and update
the LXD provider to use the bootstrap context
to display its message.
  • Loading branch information
axw committed Feb 20, 2017
1 parent 19d4074 commit afd56a6
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 85 deletions.
4 changes: 0 additions & 4 deletions environs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ type Environ interface {
// architecture.
Bootstrap(ctx BootstrapContext, params BootstrapParams) (*BootstrapResult, error)

// BootstrapMessage optionally provides a message to be displayed to
// the user at bootstrap time.
BootstrapMessage() string

// Create creates the environment for a new hosted model.
//
// This will be called before any workers begin operating on the
Expand Down
5 changes: 0 additions & 5 deletions provider/azure/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ func (env *azureEnviron) Bootstrap(
return result, nil
}

// BootstrapMessage is part of the Environ interface.
func (env *azureEnviron) BootstrapMessage() string {
return ""
}

// initResourceGroup creates a resource group for this environment.
func (env *azureEnviron) initResourceGroup(controllerUUID string, controller bool) error {
resourceGroupsClient := resources.GroupsClient{env.resources}
Expand Down
5 changes: 0 additions & 5 deletions provider/cloudsigma/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ func (env *environ) Bootstrap(ctx environs.BootstrapContext, params environs.Boo
return common.Bootstrap(ctx, env, params)
}

// BootstrapMessage is part of the Environ interface.
func (env *environ) BootstrapMessage() string {
return ""
}

// ControllerInstances is part of the Environ interface.
func (e *environ) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
return e.client.getControllerIds()
Expand Down
5 changes: 0 additions & 5 deletions provider/common/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ func BootstrapInstance(ctx environs.BootstrapContext, env environs.Environ, args
}
maybeSetBridge(instanceConfig)

bootstrapMsg := env.BootstrapMessage()
if bootstrapMsg != "" {
ctx.Infof(bootstrapMsg)
}

cloudRegion := args.CloudName
if args.CloudRegion != "" {
cloudRegion += "/" + args.CloudRegion
Expand Down
6 changes: 0 additions & 6 deletions provider/common/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
package common_test

import (
"bytes"
"fmt"
"os"
"strings"
"time"

"github.com/juju/errors"
Expand Down Expand Up @@ -235,10 +233,6 @@ func (s *BootstrapSuite) TestSuccess(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Arch, gc.Equals, "ppc64el") // based on hardware characteristics
c.Assert(result.Series, gc.Equals, config.PreferredSeries(mocksConfig))
output := inner.Stderr.(*bytes.Buffer)
lines := strings.Split(output.String(), "\n")
c.Assert(len(lines), jc.GreaterThan, 1)
c.Assert(lines[0], gc.Equals, "Some message")
}

type neverRefreshes struct {
Expand Down
4 changes: 0 additions & 4 deletions provider/common/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (env *mockEnviron) AllInstances() ([]instance.Instance, error) {
return env.allInstances()
}

func (env *mockEnviron) BootstrapMessage() string {
return "Some message"
}

func (env *mockEnviron) StartInstance(args environs.StartInstanceParams) (*environs.StartInstanceResult, error) {
inst, hw, networkInfo, err := env.startInstance(
args.Placement,
Expand Down
5 changes: 0 additions & 5 deletions provider/dummy/environs.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,6 @@ func (e *environ) Bootstrap(ctx environs.BootstrapContext, args environs.Bootstr
return bsResult, nil
}

// BootstrapMessage is part of the Environ interface.
func (e *environ) BootstrapMessage() string {
return ""
}

func (e *environ) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
estate, err := e.state()
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions provider/ec2/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ func (e *environ) Bootstrap(ctx environs.BootstrapContext, args environs.Bootstr
return common.Bootstrap(ctx, e, args)
}

// BootstrapMessage is part of the Environ interface.
func (e *environ) BootstrapMessage() string {
return ""
}

// SupportsSpaces is specified on environs.Networking.
func (e *environ) SupportsSpaces() (bool, error) {
return true, nil
Expand Down
5 changes: 0 additions & 5 deletions provider/gce/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ func (env *environ) Bootstrap(ctx environs.BootstrapContext, params environs.Boo
return bootstrap(ctx, env, params)
}

// BootstrapMessage is part of the Environ interface.
func (env *environ) BootstrapMessage() string {
return ""
}

// Destroy shuts down all known machines and destroys the rest of the
// known environment.
func (env *environ) Destroy() error {
Expand Down
5 changes: 0 additions & 5 deletions provider/joyent/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ func (env *joyentEnviron) Bootstrap(ctx environs.BootstrapContext, args environs
return common.Bootstrap(ctx, env, args)
}

// BootstrapMessage is part of the Environ interface.
func (env *joyentEnviron) BootstrapMessage() string {
return ""
}

func (env *joyentEnviron) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
instanceIds := []instance.Id{}

Expand Down
6 changes: 1 addition & 5 deletions provider/lxd/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,10 @@ func (env *environ) Create(environs.CreateParams) error {

// Bootstrap implements environs.Environ.
func (env *environ) Bootstrap(ctx environs.BootstrapContext, params environs.BootstrapParams) (*environs.BootstrapResult, error) {
ctx.Infof("%s", bootstrapMessage)
return env.base.BootstrapEnv(ctx, params)
}

// BootstrapMessage is part of the Environ interface.
func (env *environ) BootstrapMessage() string {
return bootstrapMessage
}

// Destroy shuts down all known machines and destroys the rest of the
// known environment.
func (env *environ) Destroy() error {
Expand Down
8 changes: 6 additions & 2 deletions provider/lxd/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
gc "gopkg.in/check.v1"

"github.com/juju/juju/cloudconfig/instancecfg"
"github.com/juju/juju/cmd/modelcmd"
"github.com/juju/juju/environs"
envtesting "github.com/juju/juju/environs/testing"
"github.com/juju/juju/provider/common"
Expand Down Expand Up @@ -65,17 +66,20 @@ func (s *environSuite) TestBootstrapOkay(c *gc.C) {
},
}

ctx := envtesting.BootstrapContext(c)
ctx := coretesting.Context(c)
params := environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
}
result, err := s.Env.Bootstrap(ctx, params)
result, err := s.Env.Bootstrap(modelcmd.BootstrapContext(ctx), params)
c.Assert(err, jc.ErrorIsNil)

c.Check(result.Arch, gc.Equals, "amd64")
c.Check(result.Series, gc.Equals, "trusty")
// We don't check bsFinalizer because functions cannot be compared.
c.Check(result.Finalize, gc.NotNil)

out := coretesting.Stderr(ctx)
c.Assert(out, gc.Equals, "To configure your system to better support LXD containers, please see: https://github.com/lxc/lxd/blob/master/doc/production-setup.md\n")
}

func (s *environSuite) TestBootstrapAPI(c *gc.C) {
Expand Down
5 changes: 0 additions & 5 deletions provider/maas/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ func (env *maasEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.B
return bsResult, nil
}

// BootstrapMessage is part of the Environ interface.
func (env *maasEnviron) BootstrapMessage() string {
return ""
}

// ControllerInstances is specified in the Environ interface.
func (env *maasEnviron) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
if !env.usingMAAS2() {
Expand Down
5 changes: 0 additions & 5 deletions provider/manual/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ func (e *manualEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.B
return result, nil
}

// BootstrapMessage is part of the Environ interface.
func (e *manualEnviron) BootstrapMessage() string {
return ""
}

// ControllerInstances is specified in the Environ interface.
func (e *manualEnviron) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
if !isRunningController() {
Expand Down
5 changes: 0 additions & 5 deletions provider/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,6 @@ func (e *Environ) supportsNeutron() bool {
return ok
}

// BootstrapMessage is part of the Environ interface.
func (e *Environ) BootstrapMessage() string {
return ""
}

func (e *Environ) ControllerInstances(controllerUUID string) ([]instance.Id, error) {
// Find all instances tagged with tags.JujuIsController.
instances, err := e.allControllerManagedInstances(controllerUUID, e.ecfg().useFloatingIP())
Expand Down
5 changes: 0 additions & 5 deletions provider/rackspace/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ func (e environ) Bootstrap(ctx environs.BootstrapContext, params environs.Bootst
return bootstrap(ctx, e, params)
}

// BootstrapMessage is part of the Environ interface.
func (e environ) BootstrapMessage() string {
return ""
}

var waitSSH = common.WaitSSH

// StartInstance implements environs.Environ.
Expand Down
4 changes: 0 additions & 4 deletions provider/rackspace/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ func (e *fakeEnviron) Bootstrap(ctx environs.BootstrapContext, params environs.B
return nil, nil
}

func (e *fakeEnviron) BootstrapMessage() string {
return ""
}

func (e *fakeEnviron) StartInstance(args environs.StartInstanceParams) (*environs.StartInstanceResult, error) {
e.Push("StartInstance", args)
return &environs.StartInstanceResult{
Expand Down
5 changes: 0 additions & 5 deletions provider/vsphere/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ func (env *environ) Bootstrap(ctx environs.BootstrapContext, params environs.Boo
return Bootstrap(ctx, env, params)
}

// BootstrapMessage is part of the Environ interface.
func (env *environ) BootstrapMessage() string {
return ""
}

//this variable is exported, because it has to be rewritten in external unit tests
var DestroyEnv = common.Destroy

Expand Down

0 comments on commit afd56a6

Please sign in to comment.