Skip to content

Commit

Permalink
Compiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Dec 12, 2018
1 parent f58acb9 commit d89f8de
Show file tree
Hide file tree
Showing 212 changed files with 1,032 additions and 1,031 deletions.
4 changes: 2 additions & 2 deletions api/firewaller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (m *Machine) WatchUnits() (watcher.StringsWatcher, error) {

// InstanceId returns the provider specific instance id for this
// machine, or a CodeNotProvisioned error, if not set.
func (m *Machine) InstanceId() (instance.ID, error) {
func (m *Machine) InstanceId() (instance.Id, error) {
var results params.StringResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag.String()}},
Expand All @@ -67,7 +67,7 @@ func (m *Machine) InstanceId() (instance.ID, error) {
if result.Error != nil {
return "", result.Error
}
return instance.ID(result.Result), nil
return instance.Id(result.Result), nil
}

// Life returns the machine's life cycle value.
Expand Down
2 changes: 1 addition & 1 deletion api/firewaller/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *machineSuite) TestInstanceId(c *gc.C) {

instanceId, err := s.apiMachine.InstanceId()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instanceId, gc.Equals, instance.ID("i-manager"))
c.Assert(instanceId, gc.Equals, instance.Id("i-manager"))
}

func (s *machineSuite) TestWatchUnits(c *gc.C) {
Expand Down
4 changes: 2 additions & 2 deletions api/instancepoller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (m *Machine) IsManual() (bool, error) {
}

// InstanceId returns the machine's instance id.
func (m *Machine) InstanceId() (instance.ID, error) {
func (m *Machine) InstanceId() (instance.Id, error) {
var results params.StringResults
args := params.Entities{Entities: []params.Entity{
{Tag: m.tag.String()},
Expand All @@ -114,7 +114,7 @@ func (m *Machine) InstanceId() (instance.ID, error) {
if result.Error != nil {
return "", result.Error
}
return instance.ID(result.Result), nil
return instance.Id(result.Result), nil
}

// InstanceStatus returns the machine's instance status.
Expand Down
2 changes: 1 addition & 1 deletion api/instancepoller/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (s *MachineSuite) TestInstanceIdSuccess(c *gc.C) {
machine := instancepoller.NewMachine(apiCaller, s.tag, params.Alive)
instId, err := machine.InstanceId()
c.Check(err, jc.ErrorIsNil)
c.Check(instId, gc.Equals, instance.ID("i-foo"))
c.Check(instId, gc.Equals, instance.Id("i-foo"))
c.Check(apiCaller.CallCount, gc.Equals, 1)
}

Expand Down
14 changes: 7 additions & 7 deletions api/provisioner/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ type MachineProvisioner interface {
// that belong to the same distribution group as this
// Machine. The provisioner may use this information
// to distribute instances for high availability.
DistributionGroup() ([]instance.ID, error)
DistributionGroup() ([]instance.Id, error)

// SetInstanceInfo sets the provider specific instance id, nonce, metadata,
// network config for this machine. Once set, the instance id cannot be changed.
SetInstanceInfo(
id instance.ID, nonce string, characteristics *instance.HardwareCharacteristics,
id instance.Id, nonce string, characteristics *instance.HardwareCharacteristics,
networkConfig []params.NetworkConfig, volumes []params.Volume,
volumeAttachments map[string]params.VolumeAttachmentInfo, charmProfiles []string,
) error

// InstanceId returns the provider specific instance id for the
// machine or an CodeNotProvisioned error, if not set.
InstanceId() (instance.ID, error)
InstanceId() (instance.Id, error)

// KeepInstance returns the value of the keep-instance
// for the machine.
Expand Down Expand Up @@ -339,7 +339,7 @@ func (m *Machine) AvailabilityZone() (string, error) {
}

// DistributionGroup implements MachineProvisioner.DistributionGroup.
func (m *Machine) DistributionGroup() ([]instance.ID, error) {
func (m *Machine) DistributionGroup() ([]instance.Id, error) {
var results params.DistributionGroupResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag.String()}},
Expand All @@ -360,7 +360,7 @@ func (m *Machine) DistributionGroup() ([]instance.ID, error) {

// SetInstanceInfo implements MachineProvisioner.SetInstanceInfo.
func (m *Machine) SetInstanceInfo(
id instance.ID, nonce string, characteristics *instance.HardwareCharacteristics,
id instance.Id, nonce string, characteristics *instance.HardwareCharacteristics,
networkConfig []params.NetworkConfig, volumes []params.Volume,
volumeAttachments map[string]params.VolumeAttachmentInfo, charmProfiles []string,
) error {
Expand All @@ -385,7 +385,7 @@ func (m *Machine) SetInstanceInfo(
}

// InstanceId implements MachineProvisioner.InstanceId.
func (m *Machine) InstanceId() (instance.ID, error) {
func (m *Machine) InstanceId() (instance.Id, error) {
var results params.StringResults
args := params.Entities{
Entities: []params.Entity{{Tag: m.tag.String()}},
Expand All @@ -401,7 +401,7 @@ func (m *Machine) InstanceId() (instance.ID, error) {
if result.Error != nil {
return "", result.Error
}
return instance.ID(result.Result), nil
return instance.Id(result.Result), nil
}

// KeepInstance implements MachineProvisioner.KeepInstance.
Expand Down
10 changes: 5 additions & 5 deletions api/provisioner/mocks/machine_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions api/provisioner/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (s *provisionerSuite) TestSetInstanceInfo(c *gc.C) {
instanceId, err := apiMachine.InstanceId()
c.Assert(err, jc.Satisfies, params.IsCodeNotProvisioned)
c.Assert(err, gc.ErrorMatches, "machine 1 not provisioned")
c.Assert(instanceId, gc.Equals, instance.ID(""))
c.Assert(instanceId, gc.Equals, instance.Id(""))

hwChars := instance.MustParseHardware("cores=123", "mem=4G")

Expand All @@ -303,7 +303,7 @@ func (s *provisionerSuite) TestSetInstanceInfo(c *gc.C) {

instanceId, err = apiMachine.InstanceId()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instanceId, gc.Equals, instance.ID("i-will"))
c.Assert(instanceId, gc.Equals, instance.Id("i-will"))

// Try it again - should fail.
err = apiMachine.SetInstanceInfo("i-wont", "fake", nil, nil, nil, nil, nil)
Expand All @@ -313,7 +313,7 @@ func (s *provisionerSuite) TestSetInstanceInfo(c *gc.C) {
apiMachine = s.assertGetOneMachine(c, s.machine.MachineTag())
instanceId, err = apiMachine.InstanceId()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instanceId, gc.Equals, instance.ID("i-manager"))
c.Assert(instanceId, gc.Equals, instance.Id("i-manager"))

// Now check volumes and volume attachments.
sb, err := state.NewStorageBackend(s.State)
Expand Down Expand Up @@ -351,7 +351,7 @@ func (s *provisionerSuite) TestAvailabilityZone(c *gc.C) {
instanceId, err := apiMachine.InstanceId()
c.Assert(err, jc.Satisfies, params.IsCodeNotProvisioned)
c.Assert(err, gc.ErrorMatches, "machine 1 not provisioned")
c.Assert(instanceId, gc.Equals, instance.ID(""))
c.Assert(instanceId, gc.Equals, instance.Id(""))

availabilityZone := "ru-north-siberia"
hwChars := instance.MustParseHardware(fmt.Sprintf("availability-zone=%s", availabilityZone))
Expand Down Expand Up @@ -380,7 +380,7 @@ func (s *provisionerSuite) TestSetInstanceInfoProfiles(c *gc.C) {
instanceId, err := apiMachine.InstanceId()
c.Assert(err, jc.Satisfies, params.IsCodeNotProvisioned)
c.Assert(err, gc.ErrorMatches, "machine 1 not provisioned")
c.Assert(instanceId, gc.Equals, instance.ID(""))
c.Assert(instanceId, gc.Equals, instance.Id(""))

hwChars := instance.MustParseHardware("cores=123", "mem=4G")

Expand Down Expand Up @@ -531,7 +531,7 @@ func (s *provisionerSuite) TestDistributionGroup(c *gc.C) {
apiMachine := s.assertGetOneMachine(c, s.machine.MachineTag())
instances, err := apiMachine.DistributionGroup()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instances, gc.DeepEquals, []instance.ID{"i-manager"})
c.Assert(instances, gc.DeepEquals, []instance.Id{"i-manager"})

machine1, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, jc.ErrorIsNil)
Expand All @@ -553,7 +553,7 @@ func (s *provisionerSuite) TestDistributionGroup(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
instances, err := apiMachine.DistributionGroup()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instances, gc.DeepEquals, []instance.ID{"i-d"})
c.Assert(instances, gc.DeepEquals, []instance.Id{"i-d"})
}
}

Expand Down
2 changes: 1 addition & 1 deletion apiserver/common/credentialcommon/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Machine interface {

// InstanceId returns the provider specific instance id for this
// machine, or a NotProvisionedError, if not set.
InstanceId() (instance.ID, error)
InstanceId() (instance.Id, error)

// Id returns the machine id.
Id() string
Expand Down
2 changes: 1 addition & 1 deletion apiserver/common/credentialcommon/modelcredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func checkMachineInstances(backend PersistentBackend, provider CloudProvider, ca

instanceIds := set.NewStrings()
for _, instance := range instances {
id := string(instance.ID())
id := string(instance.Id())
instanceIds.Add(id)
if _, found := machinesByInstance[id]; !found {
results = append(results, serverError(errors.Errorf("no machine with instance %q", id)))
Expand Down
16 changes: 8 additions & 8 deletions apiserver/common/credentialcommon/modelcredential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (s *CheckMachinesSuite) TestCheckMachinesHandlesManual(c *gc.C) {

func (s *CheckMachinesSuite) TestCheckMachinesErrorGettingMachineInstanceId(c *gc.C) {
machine1 := createTestMachine("2", "")
machine1.instanceIdFunc = func() (instance.ID, error) { return "", errors.New("retrieval failure") }
machine1.instanceIdFunc = func() (instance.Id, error) { return "", errors.New("retrieval failure") }
s.backend.allMachinesFunc = func() ([]credentialcommon.Machine, error) {
return []credentialcommon.Machine{s.machine, machine1}, nil
}
Expand All @@ -158,7 +158,7 @@ func (s *CheckMachinesSuite) TestCheckMachinesErrorGettingMachineInstanceId(c *g

func (s *CheckMachinesSuite) TestCheckMachinesErrorGettingMachineInstanceIdNonFatal(c *gc.C) {
machine1 := createTestMachine("2", "")
machine1.instanceIdFunc = func() (instance.ID, error) { return "", errors.New("retrieval failure") }
machine1.instanceIdFunc = func() (instance.Id, error) { return "", errors.New("retrieval failure") }
s.machine.instanceIdFunc = machine1.instanceIdFunc
s.backend.allMachinesFunc = func() ([]credentialcommon.Machine, error) {
return []credentialcommon.Machine{s.machine, machine1}, nil
Expand All @@ -180,7 +180,7 @@ func (s *CheckMachinesSuite) TestCheckMachinesErrorGettingMachineInstanceIdNonFa

func (s *CheckMachinesSuite) TestCheckMachinesNotProvisionedError(c *gc.C) {
machine2 := createTestMachine("2", "")
machine2.instanceIdFunc = func() (instance.ID, error) { return "", errors.NotProvisionedf("machine 2") }
machine2.instanceIdFunc = func() (instance.Id, error) { return "", errors.NotProvisionedf("machine 2") }
s.backend.allMachinesFunc = func() ([]credentialcommon.Machine, error) {
return []credentialcommon.Machine{s.machine, machine2}, nil
}
Expand Down Expand Up @@ -448,15 +448,15 @@ type mockInstance struct {
id string
}

func (i *mockInstance) Id() instance.ID {
return instance.ID(i.id)
func (i *mockInstance) Id() instance.Id {
return instance.Id(i.id)
}

type mockMachine struct {
id string
container bool
manualFunc func() (bool, error)
instanceIdFunc func() (instance.ID, error)
instanceIdFunc func() (instance.Id, error)
}

func (m *mockMachine) IsManual() (bool, error) {
Expand All @@ -467,7 +467,7 @@ func (m *mockMachine) IsContainer() bool {
return m.container
}

func (m *mockMachine) InstanceId() (instance.ID, error) {
func (m *mockMachine) InstanceId() (instance.Id, error) {
return m.instanceIdFunc()
}

Expand All @@ -479,7 +479,7 @@ func createTestMachine(id, instanceId string) *mockMachine {
return &mockMachine{
id: id,
manualFunc: func() (bool, error) { return false, nil },
instanceIdFunc: func() (instance.ID, error) { return instance.ID(instanceId), nil },
instanceIdFunc: func() (instance.Id, error) { return instance.Id(instanceId), nil },
}
}

Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/instanceidgetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewInstanceIdGetter(st state.EntityFinder, getCanRead GetAuthFunc) *Instanc
}
}

func (ig *InstanceIdGetter) getInstanceId(tag names.Tag) (instance.ID, error) {
func (ig *InstanceIdGetter) getInstanceId(tag names.Tag) (instance.Id, error) {
entity0, err := ig.st.FindEntity(tag)
if err != nil {
return "", err
Expand Down Expand Up @@ -58,7 +58,7 @@ func (ig *InstanceIdGetter) InstanceId(args params.Entities) (params.StringResul
}
err = ErrPerm
if canRead(tag) {
var instanceId instance.ID
var instanceId instance.Id
instanceId, err = ig.getInstanceId(tag)
if err == nil {
result.Results[i].Result = string(instanceId)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/instanceidgetter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ type fakeInstanceIdGetter struct {
fetchError
}

func (f *fakeInstanceIdGetter) InstanceId() (instance.ID, error) {
func (f *fakeInstanceIdGetter) InstanceId() (instance.Id, error) {
if f.err != "" {
return "", fmt.Errorf(f.err)
}
return instance.ID(f.instanceId), nil
return instance.Id(f.instanceId), nil
}

func (*instanceIdGetterSuite) TestInstanceId(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/common/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (st *stateShim) Machine(id string) (Machine, error) {

type Machine interface {
Id() string
InstanceId() (instance.ID, error)
InstanceId() (instance.Id, error)
WantsVote() bool
HasVote() bool
Status() (status.StatusInfo, error)
Expand Down
6 changes: 3 additions & 3 deletions apiserver/common/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *machineSuite) TestMachineHardwareInfo(c *gc.C) {
func (s *machineSuite) TestMachineInstanceInfo(c *gc.C) {
st := mockState{
machines: map[string]*mockMachine{
"1": {id: "1", instId: instance.ID("123"), status: status.Down, hasVote: true, wantsVote: true},
"1": {id: "1", instId: instance.Id("123"), status: status.Down, hasVote: true, wantsVote: true},
},
}
info, err := common.ModelMachineInfo(&st)
Expand Down Expand Up @@ -168,7 +168,7 @@ type mockMachine struct {
life state.Life
containerType instance.ContainerType
hw *instance.HardwareCharacteristics
instId instance.ID
instId instance.Id
hasVote, wantsVote bool
status status.Status
statusErr error
Expand All @@ -188,7 +188,7 @@ func (m *mockMachine) Life() state.Life {
return m.life
}

func (m *mockMachine) InstanceId() (instance.ID, error) {
func (m *mockMachine) InstanceId() (instance.Id, error) {
return m.instId, nil
}

Expand Down
2 changes: 1 addition & 1 deletion apiserver/common/networkingcommon/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (cache *addSubnetsCache) cacheSubnets(ctx context.ProviderCallContext) erro
if err != nil {
return errors.Trace(err)
}
subnetInfo, err := netEnv.Subnets(ctx, instance.UnknownID, nil)
subnetInfo, err := netEnv.Subnets(ctx, instance.UnknownId, nil)
if err != nil {
return errors.Annotate(err, "cannot get provider subnets")
}
Expand Down
8 changes: 4 additions & 4 deletions apiserver/common/networkingcommon/subnets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,13 @@ func (s *SubnetsSuite) TestAddSubnetsParamsCombinations(c *gc.C) {
apiservertesting.BackingCall("ModelConfig"),
apiservertesting.BackingCall("CloudSpec"),
apiservertesting.ProviderCall("Open", apiservertesting.BackingInstance.EnvConfig),
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownID, []network.Id(nil)),
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownId, []network.Id(nil)),

// caching subnets (4th attempt): succeeds
apiservertesting.BackingCall("ModelConfig"),
apiservertesting.BackingCall("CloudSpec"),
apiservertesting.ProviderCall("Open", apiservertesting.BackingInstance.EnvConfig),
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownID, []network.Id(nil)),
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownId, []network.Id(nil)),

// caching spaces (1st and 2nd attempts)
apiservertesting.BackingCall("AllSpaces"),
Expand Down Expand Up @@ -600,12 +600,12 @@ func (s *SubnetsSuite) CheckAddSubnetsFails(
case apiservertesting.StubNetworkingEnvironName:
expectedCalls = append(
expectedCalls,
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownID, []network.Id(nil)),
apiservertesting.NetworkingEnvironCall("Subnets", callCtx, instance.UnknownId, []network.Id(nil)),
)
case apiservertesting.StubZonedNetworkingEnvironName:
expectedCalls = append(
expectedCalls,
apiservertesting.ZonedNetworkingEnvironCall("Subnets", callCtx, instance.UnknownID, []network.Id(nil)),
apiservertesting.ZonedNetworkingEnvironCall("Subnets", callCtx, instance.UnknownId, []network.Id(nil)),
)
}

Expand Down
Loading

0 comments on commit d89f8de

Please sign in to comment.