Skip to content

Commit

Permalink
Remove the params.Life type and use life.Value from core/life package.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Nov 8, 2019
1 parent 34ac7aa commit 52602ea
Show file tree
Hide file tree
Showing 157 changed files with 764 additions and 622 deletions.
3 changes: 2 additions & 1 deletion api/agent/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
apiagent "github.com/juju/juju/api/agent"
apiserveragent "github.com/juju/juju/apiserver/facades/agent/agent"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
"github.com/juju/juju/juju/testing"
"github.com/juju/juju/mongo"
Expand Down Expand Up @@ -135,7 +136,7 @@ func (s *machineSuite) TestMachineEntity(c *gc.C) {
m, err = apiSt.Entity(s.machine.Tag())
c.Assert(err, jc.ErrorIsNil)
c.Assert(m.Tag(), gc.Equals, s.machine.Tag().String())
c.Assert(m.Life(), gc.Equals, params.Alive)
c.Assert(m.Life(), gc.Equals, life.Alive)
c.Assert(m.Jobs(), gc.DeepEquals, []model.MachineJob{model.JobHostUnits})

err = s.machine.EnsureDead()
Expand Down
3 changes: 2 additions & 1 deletion api/agent/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/juju/juju/api/common/cloudspec"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/instance"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
)

Expand Down Expand Up @@ -101,7 +102,7 @@ func (m *Entity) Tag() string {
}

// Life returns the current life cycle state of the entity.
func (m *Entity) Life() params.Life {
func (m *Entity) Life() life.Value {
return m.doc.Life
}

Expand Down
3 changes: 2 additions & 1 deletion api/agent/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/juju/juju/api"
apiagent "github.com/juju/juju/api/agent"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/juju/testing"
"github.com/juju/juju/state"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ func (s *unitSuite) TestUnitEntity(c *gc.C) {
m, err = apiSt.Entity(s.unit.Tag())
c.Assert(err, jc.ErrorIsNil)
c.Assert(m.Tag(), gc.Equals, s.unit.Tag().String())
c.Assert(m.Life(), gc.Equals, params.Alive)
c.Assert(m.Life(), gc.Equals, life.Alive)
c.Assert(m.Jobs(), gc.HasLen, 0)

err = s.unit.EnsureDead()
Expand Down
7 changes: 4 additions & 3 deletions api/base/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/juju/version"

"github.com/juju/juju/core/instance"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
"github.com/juju/juju/core/status"
)
Expand All @@ -27,7 +28,7 @@ type UserModel struct {
// ModelStatus holds information about the status of a juju model.
type ModelStatus struct {
UUID string
Life string
Life life.Value
ModelType model.ModelType
Owner string
TotalMachineCount int
Expand Down Expand Up @@ -66,7 +67,7 @@ type ModelInfo struct {
CloudRegion string
CloudCredential string
Owner string
Life string
Life life.Value
Status Status
Users []UserInfo
Machines []Machine
Expand Down Expand Up @@ -120,7 +121,7 @@ type UserModelSummary struct {
CloudRegion string
CloudCredential string
Owner string
Life string
Life life.Value
Status Status
ModelUserAccess string
UserLastConnection *time.Time
Expand Down
2 changes: 1 addition & 1 deletion api/caasfirewaller/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *FirewallerSuite) TestLife(c *gc.C) {
c.Assert(result, gc.FitsTypeOf, &params.LifeResults{})
*(result.(*params.LifeResults)) = params.LifeResults{
Results: []params.LifeResult{{
Life: params.Alive,
Life: life.Alive,
}},
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperator/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (s *operatorSuite) testLife(c *gc.C, tag names.Tag) {
c.Assert(result, gc.FitsTypeOf, &params.LifeResults{})
*(result.(*params.LifeResults)) = params.LifeResults{
Results: []params.LifeResult{{
Life: params.Alive,
Life: life.Alive,
}},
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperatorprovisioner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *provisionerSuite) TestLife(c *gc.C) {
c.Assert(result, gc.FitsTypeOf, &params.LifeResults{})
*(result.(*params.LifeResults)) = params.LifeResults{
Results: []params.LifeResult{{
Life: params.Alive,
Life: life.Alive,
}},
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion api/caasunitprovisioner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (s *unitprovisionerSuite) testLife(c *gc.C, tag names.Tag) {
c.Assert(result, gc.FitsTypeOf, &params.LifeResults{})
*(result.(*params.LifeResults)) = params.LifeResults{
Results: []params.LifeResult{{
Life: params.Alive,
Life: life.Alive,
}},
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion api/common/life.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
)

// Life requests the life cycle of the given entities from the given
Expand All @@ -31,7 +32,7 @@ func Life(caller base.FacadeCaller, tags []names.Tag) ([]params.LifeResult, erro

// OneLife requests the life cycle of the given entity from the given
// server-side API facade via the given caller.
func OneLife(caller base.FacadeCaller, tag names.Tag) (params.Life, error) {
func OneLife(caller base.FacadeCaller, tag names.Tag) (life.Value, error) {
result, err := Life(caller, []names.Tag{tag})
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion api/common/modelstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func constructModelStatus(m names.ModelTag, owner names.UserTag, r params.ModelS

result := base.ModelStatus{
UUID: m.Id(),
Life: string(r.Life),
Life: r.Life,
Owner: owner.Id(),
ModelType: model.ModelType(r.Type),
HostedMachineCount: r.HostedMachineCount,
Expand Down
3 changes: 2 additions & 1 deletion api/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/juju/juju/api/controller"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/environs"
coretesting "github.com/juju/juju/testing"
)
Expand Down Expand Up @@ -336,7 +337,7 @@ func (s *Suite) TestModelStatus(c *gc.C) {
HostedMachineCount: 2,
ApplicationCount: 3,
Owner: "glenda",
Life: string(params.Alive),
Life: life.Alive,
Machines: []base.Machine{{Id: "0", InstanceId: "inst-ance", Status: "pending"}},
})
c.Assert(results[1].Error, gc.ErrorMatches, "model error")
Expand Down
3 changes: 2 additions & 1 deletion api/controller/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/juju/juju/api/controller"
commontesting "github.com/juju/juju/apiserver/common/testing"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
"github.com/juju/juju/environs/config"
jujutesting "github.com/juju/juju/juju/testing"
Expand Down Expand Up @@ -191,7 +192,7 @@ func (s *legacySuite) TestWatchAllModels(c *gc.C) {
modelInfo.Status.Since = nil
c.Assert(modelInfo.ModelUUID, gc.Equals, model.UUID())
c.Assert(modelInfo.Name, gc.Equals, model.Name())
c.Assert(modelInfo.Life, gc.Equals, params.Life("alive"))
c.Assert(modelInfo.Life, gc.Equals, life.Alive)
c.Assert(modelInfo.Owner, gc.Equals, model.Owner().Id())
c.Assert(modelInfo.ControllerUUID, gc.Equals, model.ControllerUUID())
c.Assert(modelInfo.Config, jc.DeepEquals, cfg.AllAttrs())
Expand Down
3 changes: 2 additions & 1 deletion api/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
)

const deployerFacade = "Deployer"
Expand All @@ -27,7 +28,7 @@ func NewState(caller base.APICaller) *State {
}

// unitLife returns the lifecycle state of the given unit.
func (st *State) unitLife(tag names.UnitTag) (params.Life, error) {
func (st *State) unitLife(tag names.UnitTag) (life.Value, error) {
return common.OneLife(st.facade, tag)
}

Expand Down
7 changes: 4 additions & 3 deletions api/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/juju/juju/api"
"github.com/juju/juju/api/deployer"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/network"
"github.com/juju/juju/core/status"
"github.com/juju/juju/core/watcher/watchertest"
Expand Down Expand Up @@ -156,18 +157,18 @@ func (s *deployerSuite) TestUnitLifeRefresh(c *gc.C) {
unit, err := s.st.Unit(s.subordinate.Tag().(names.UnitTag))
c.Assert(err, jc.ErrorIsNil)

c.Assert(unit.Life(), gc.Equals, params.Alive)
c.Assert(unit.Life(), gc.Equals, life.Alive)

// Now make it dead and check again, then refresh and check.
err = s.subordinate.EnsureDead()
c.Assert(err, jc.ErrorIsNil)
err = s.subordinate.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.subordinate.Life(), gc.Equals, state.Dead)
c.Assert(unit.Life(), gc.Equals, params.Alive)
c.Assert(unit.Life(), gc.Equals, life.Alive)
err = unit.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(unit.Life(), gc.Equals, params.Dead)
c.Assert(unit.Life(), gc.Equals, life.Dead)
}

func (s *deployerSuite) TestUnitRemove(c *gc.C) {
Expand Down
5 changes: 3 additions & 2 deletions api/deployer/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (

"github.com/juju/juju/api/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/status"
)

// Unit represents a juju unit as seen by the deployer worker.
type Unit struct {
tag names.UnitTag
life params.Life
life life.Value
st *State
}

Expand All @@ -29,7 +30,7 @@ func (u *Unit) Name() string {
}

// Life returns the unit's lifecycle value.
func (u *Unit) Life() params.Life {
func (u *Unit) Life() life.Value {
return u.life
}

Expand Down
3 changes: 2 additions & 1 deletion api/firewaller/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (

"github.com/juju/juju/api/common"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/watcher"
)

// Application represents the state of an application.
type Application struct {
st *Client
tag names.ApplicationTag
life params.Life
life life.Value
}

// Name returns the application name.
Expand Down
3 changes: 2 additions & 1 deletion api/firewaller/firewaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/juju/juju/api/common/cloudspec"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/relation"
"github.com/juju/juju/core/watcher"
"gopkg.in/macaroon.v2-unstable"
Expand Down Expand Up @@ -53,7 +54,7 @@ func (c *Client) ModelTag() (names.ModelTag, bool) {
}

// life requests the life cycle of the given entity from the server.
func (c *Client) life(tag names.Tag) (params.Life, error) {
func (c *Client) life(tag names.Tag) (life.Value, error) {
return common.OneLife(c.facade, tag)
}

Expand Down
5 changes: 3 additions & 2 deletions api/firewaller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/instance"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/network"
"github.com/juju/juju/core/watcher"
)
Expand All @@ -19,7 +20,7 @@ import (
type Machine struct {
st *Client
tag names.MachineTag
life params.Life
life life.Value
}

// Tag returns the machine tag.
Expand Down Expand Up @@ -71,7 +72,7 @@ func (m *Machine) InstanceId() (instance.Id, error) {
}

// Life returns the machine's life cycle value.
func (m *Machine) Life() params.Life {
func (m *Machine) Life() life.Value {
return m.life
}

Expand Down
6 changes: 3 additions & 3 deletions api/firewaller/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ package firewaller
import (
"gopkg.in/juju/names.v3"

"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
)

// Relation represents a juju relation as seen by the firewaller worker.
type Relation struct {
tag names.RelationTag
life params.Life
life life.Value
}

// Tag returns the relation tag.
Expand All @@ -21,6 +21,6 @@ func (r *Relation) Tag() names.RelationTag {
}

// Life returns the relation's life cycle value.
func (r *Relation) Life() params.Life {
func (r *Relation) Life() life.Value {
return r.life
}
3 changes: 2 additions & 1 deletion api/firewaller/relation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/juju/juju/api/firewaller"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
)

type relationSuite struct {
Expand Down Expand Up @@ -47,5 +48,5 @@ func (s *relationSuite) TestTag(c *gc.C) {
}

func (s *relationSuite) TestLife(c *gc.C) {
c.Assert(s.apiRelation.Life(), gc.Equals, params.Alive)
c.Assert(s.apiRelation.Life(), gc.Equals, life.Alive)
}
5 changes: 3 additions & 2 deletions api/firewaller/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"gopkg.in/juju/names.v3"

"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
)

// Unit represents a juju unit as seen by a firewaller worker.
type Unit struct {
st *Client
tag names.UnitTag
life params.Life
life life.Value
}

// Name returns the name of the unit.
Expand All @@ -28,7 +29,7 @@ func (u *Unit) Tag() names.UnitTag {
}

// Life returns the unit's life cycle value.
func (u *Unit) Life() params.Life {
func (u *Unit) Life() life.Value {
return u.life
}

Expand Down
Loading

0 comments on commit 52602ea

Please sign in to comment.