Skip to content

Commit cc4d9c2

Browse files
committed
Delete dead/unused code
Using https://github.com/3rf/codecoroner
1 parent 1cb9c09 commit cc4d9c2

File tree

148 files changed

+16
-2446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+16
-2446
lines changed

agent/agent.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,6 @@ func (s APIHostPortsSetter) SetAPIHostPorts(servers [][]network.HostPort) error
8181
})
8282
}
8383

84-
// StateServingInfoSetter trivially wraps an Agent to implement
85-
// worker/certupdater/SetStateServingInfo.
86-
type StateServingInfoSetter struct {
87-
Agent
88-
}
89-
90-
// SetStateServingInfo is the SetStateServingInfo interface.
91-
func (s StateServingInfoSetter) SetStateServingInfo(info params.StateServingInfo) error {
92-
return s.ChangeConfig(func(c ConfigSetter) error {
93-
c.SetStateServingInfo(info)
94-
return nil
95-
})
96-
}
97-
9884
// Paths holds the directory paths used by the agent.
9985
type Paths struct {
10086
// DataDir is the data directory where each agent has a subdirectory

agent/export_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,6 @@
33

44
package agent
55

6-
import (
7-
"fmt"
8-
"os"
9-
10-
"github.com/juju/juju/state/multiwatcher"
11-
)
12-
13-
func PatchConfig(config Config, fieldName string, value interface{}) error {
14-
conf := config.(*configInternal)
15-
switch fieldName {
16-
case "Paths":
17-
paths := value.(Paths)
18-
if paths.DataDir != "" {
19-
conf.paths.DataDir = paths.DataDir
20-
}
21-
if paths.LogDir != "" {
22-
conf.paths.LogDir = paths.LogDir
23-
}
24-
case "Jobs":
25-
conf.jobs = value.([]multiwatcher.MachineJob)[:]
26-
case "DeleteValues":
27-
for _, key := range value.([]string) {
28-
delete(conf.values, key)
29-
}
30-
case "Values":
31-
for key, val := range value.(map[string]string) {
32-
if conf.values == nil {
33-
conf.values = make(map[string]string)
34-
}
35-
conf.values[key] = val
36-
}
37-
default:
38-
return fmt.Errorf("unknown field %q", fieldName)
39-
}
40-
conf.configFilePath = ConfigPath(conf.paths.DataDir, conf.tag)
41-
return nil
42-
}
43-
44-
func ConfigFileExists(config Config) bool {
45-
conf := config.(*configInternal)
46-
_, err := os.Lstat(conf.configFilePath)
47-
return err == nil
48-
}
49-
506
func EmptyConfig() Config {
517
return &configInternal{}
528
}

api/application/export_test.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

api/backups/base_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
gc "gopkg.in/check.v1"
1010

1111
"github.com/juju/juju/api/backups"
12-
apiserverbackups "github.com/juju/juju/apiserver/backups"
1312
"github.com/juju/juju/apiserver/params"
1413
jujutesting "github.com/juju/juju/juju/testing"
1514
stbackups "github.com/juju/juju/state/backups"
@@ -30,11 +29,6 @@ func (s *baseSuite) SetUpTest(c *gc.C) {
3029
s.client = client
3130
}
3231

33-
func (s *baseSuite) metadataResult() *params.BackupsMetadataResult {
34-
result := apiserverbackups.ResultFromMetadata(s.Meta)
35-
return &result
36-
}
37-
3832
func (s *baseSuite) checkMetadataResult(c *gc.C, result *params.BackupsMetadataResult, meta *stbackups.Metadata) {
3933
var finished, stored time.Time
4034
if meta.Finished != nil {

api/meterstatus/export_test.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

api/uniter/export_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func PatchUnitResponse(p testing.Patcher, u *Unit, expectedRequest string, respo
3333
})
3434
}
3535

36-
// PatchUnitFacadeCall changes the internal FacadeCaller to one that calls the provided request handler function.
37-
func PatchUnitFacadeCall(p testing.Patcher, u *Unit, respFunc func(request string, params, response interface{}) error) {
38-
testing.PatchFacadeCall(p, &u.st.facade, respFunc)
39-
}
40-
4136
// CreateUnit creates uniter.Unit for tests.
4237
func CreateUnit(st *State, tag names.UnitTag) *Unit {
4338
return &Unit{st, tag, params.Alive}

api/uniter/unit_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"gopkg.in/juju/names.v2"
1616

1717
"github.com/juju/juju/api"
18-
"github.com/juju/juju/api/base"
1918
"github.com/juju/juju/api/uniter"
2019
"github.com/juju/juju/apiserver/common"
2120
"github.com/juju/juju/apiserver/params"
@@ -825,16 +824,6 @@ func (s *unitSuite) TestWatchMeterStatus(c *gc.C) {
825824
wc.AssertOneChange()
826825
}
827826

828-
func (s *unitSuite) patchNewState(
829-
c *gc.C,
830-
patchFunc func(_ base.APICaller, _ names.UnitTag) *uniter.State,
831-
) {
832-
s.uniterSuite.patchNewState(c, patchFunc)
833-
var err error
834-
s.apiUnit, err = s.uniter.Unit(s.wordpressUnit.Tag().(names.UnitTag))
835-
c.Assert(err, jc.ErrorIsNil)
836-
}
837-
838827
type unitMetricBatchesSuite struct {
839828
testing.JujuConnSuite
840829

api/uniter/uniter_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
jc "github.com/juju/testing/checkers"
88
"github.com/juju/utils"
99
gc "gopkg.in/check.v1"
10-
"gopkg.in/juju/names.v2"
1110

1211
"github.com/juju/juju/api"
13-
"github.com/juju/juju/api/base"
1412
"github.com/juju/juju/api/uniter"
1513
"github.com/juju/juju/juju/testing"
1614
"github.com/juju/juju/state"
@@ -122,17 +120,6 @@ func (s *uniterSuite) assertInScope(c *gc.C, relUnit *state.RelationUnit, inScop
122120
c.Assert(ok, gc.Equals, inScope)
123121
}
124122

125-
func (s *uniterSuite) patchNewState(
126-
c *gc.C,
127-
patchFunc func(_ base.APICaller, _ names.UnitTag) *uniter.State,
128-
) {
129-
s.PatchValue(&uniter.NewState, patchFunc)
130-
var err error
131-
s.uniter, err = s.st.Uniter()
132-
c.Assert(err, jc.ErrorIsNil)
133-
c.Assert(s.uniter, gc.NotNil)
134-
}
135-
136123
func (s *uniterSuite) TestSLALevel(c *gc.C) {
137124
err := s.State.SetSLA("essential", "bob", []byte("creds"))
138125
c.Assert(err, jc.ErrorIsNil)

apiserver/admin_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,6 @@ func (s *loginSuite) TestLoginAsDeactivatedUser(c *gc.C) {
161161
})
162162
}
163163

164-
func (s *baseLoginSuite) runLoginSetsLogIdentifier(c *gc.C) {
165-
info, srv := newServer(c, s.State)
166-
defer assertStop(c, srv)
167-
168-
machine, password := s.Factory.MakeMachineReturningPassword(
169-
c, &factory.MachineParams{Nonce: "fake_nonce"})
170-
171-
info.Tag = machine.Tag()
172-
info.Password = password
173-
info.Nonce = "fake_nonce"
174-
175-
apiConn, err := api.Open(info, fastDialOpts)
176-
c.Assert(err, jc.ErrorIsNil)
177-
defer apiConn.Close()
178-
179-
apiMachine, err := apimachiner.NewState(apiConn).Machine(machine.MachineTag())
180-
c.Assert(err, jc.ErrorIsNil)
181-
c.Assert(apiMachine.Tag(), gc.Equals, machine.Tag())
182-
}
183-
184164
func (s *loginSuite) TestLoginAddrs(c *gc.C) {
185165
info, srv := s.newMachineAndServer(c)
186166
defer assertStop(c, srv)

apiserver/application/backend.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package application
55

66
import (
7-
"github.com/juju/errors"
87
"gopkg.in/juju/charm.v6-unstable"
98
csparams "gopkg.in/juju/charmrepo.v2-unstable/csclient/params"
109
"gopkg.in/juju/names.v2"
@@ -266,35 +265,17 @@ type Subnet interface {
266265
VLANTag() int
267266
ProviderId() network.Id
268267
ProviderNetworkId() network.Id
269-
AvailabilityZones() []string
270268
}
271269

272270
type subnetShim struct {
273271
*state.Subnet
274272
}
275273

276-
func (s *subnetShim) AvailabilityZones() []string {
277-
return []string{s.Subnet.AvailabilityZone()}
278-
}
279-
280274
type Space interface {
281275
Name() string
282-
Subnets() ([]Subnet, error)
283276
ProviderId() network.Id
284277
}
285278

286279
type spaceShim struct {
287280
*state.Space
288281
}
289-
290-
func (s *spaceShim) Subnets() ([]Subnet, error) {
291-
subnets, err := s.Space.Subnets()
292-
if err != nil {
293-
return nil, errors.Trace(err)
294-
}
295-
result := make([]Subnet, len(subnets))
296-
for i, subnet := range subnets {
297-
result[i] = &subnetShim{subnet}
298-
}
299-
return result, nil
300-
}

apiserver/application/export_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33

44
package application
55

6-
import "github.com/juju/errors"
7-
86
var (
97
ParseSettingsCompatible = parseSettingsCompatible
108
NewStateStorage = &newStateStorage
119
)
12-
13-
func IsMinJujuVersionError(err error) bool {
14-
_, ok := errors.Cause(err).(minJujuVersionErr)
15-
return ok
16-
}

apiserver/application/mock_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ type mockModel struct {
4444
owner string
4545
}
4646

47-
func (m *mockModel) UUID() string {
48-
return m.uuid
49-
}
50-
5147
func (m *mockModel) ModelTag() names.ModelTag {
5248
return names.NewModelTag(m.uuid)
5349
}
@@ -190,10 +186,6 @@ func (m *mockSpace) Name() string {
190186
return m.name
191187
}
192188

193-
func (m *mockSpace) Subnets() ([]application.Subnet, error) {
194-
return m.subnets, nil
195-
}
196-
197189
func (m *mockSpace) ProviderId() network.Id {
198190
return m.providerId
199191
}
@@ -222,18 +214,6 @@ func (m *mockSubnet) ProviderNetworkId() network.Id {
222214
return m.providerNetworkId
223215
}
224216

225-
func (m *mockSubnet) AvailabilityZones() []string {
226-
return m.zones
227-
}
228-
229-
type mockConnectionStatus struct {
230-
count int
231-
}
232-
233-
func (m *mockConnectionStatus) ConnectionCount() int {
234-
return m.count
235-
}
236-
237217
type mockBackend struct {
238218
jtesting.Stub
239219
application.Backend
@@ -445,18 +425,6 @@ func (m *mockBackend) AllModels() ([]application.Model, error) {
445425
return []application.Model{m.model}, nil
446426
}
447427

448-
type mockStatePool struct {
449-
st map[string]application.Backend
450-
}
451-
452-
func (st *mockStatePool) Get(modelUUID string) (application.Backend, func(), error) {
453-
backend, ok := st.st[modelUUID]
454-
if !ok {
455-
return nil, nil, errors.NotFoundf("model for uuid %s", modelUUID)
456-
}
457-
return backend, func() {}, nil
458-
}
459-
460428
type mockBlockChecker struct {
461429
jtesting.Stub
462430
}

apiserver/client/api_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
jc "github.com/juju/testing/checkers"
11-
"github.com/juju/utils/clock"
1211
gc "gopkg.in/check.v1"
1312
"gopkg.in/juju/charm.v6-unstable"
1413
"gopkg.in/juju/names.v2"
@@ -22,7 +21,6 @@ import (
2221
"github.com/juju/juju/feature"
2322
"github.com/juju/juju/instance"
2423
"github.com/juju/juju/juju/testing"
25-
"github.com/juju/juju/mongo"
2624
"github.com/juju/juju/state"
2725
"github.com/juju/juju/state/multiwatcher"
2826
"github.com/juju/juju/state/presence"
@@ -77,26 +75,6 @@ func setDefaultStatus(c *gc.C, entity setStatuser) {
7775
c.Assert(err, jc.ErrorIsNil)
7876
}
7977

80-
func (s *baseSuite) tryOpenState(c *gc.C, e apiAuthenticator, password string) error {
81-
stateInfo := s.MongoInfo(c)
82-
stateInfo.Tag = e.Tag()
83-
stateInfo.Password = password
84-
st, err := state.Open(state.OpenParams{
85-
Clock: clock.WallClock,
86-
ControllerTag: s.State.ControllerTag(),
87-
ControllerModelTag: s.State.ModelTag(),
88-
MongoInfo: stateInfo,
89-
MongoDialOpts: mongo.DialOpts{
90-
Timeout: 25 * time.Millisecond,
91-
},
92-
})
93-
94-
if err == nil {
95-
st.Close()
96-
}
97-
return err
98-
}
99-
10078
// openAs connects to the API state as the given entity
10179
// with the default password for that entity.
10280
func (s *baseSuite) openAs(c *gc.C, tag names.Tag) api.Connection {

0 commit comments

Comments
 (0)