Skip to content

Commit fb7057c

Browse files
jfmyers9xoebus
authored andcommitted
Remove unused functions and functionality
1 parent fb87713 commit fb7057c

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

src/bpm/config/bpm_config.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ func (c *BPMConfig) JobDir() string {
103103
return filepath.Join(c.boshRoot, "jobs", c.jobName)
104104
}
105105

106-
func (c *BPMConfig) ConfigDir() string {
107-
return filepath.Join(c.JobDir(), "config")
108-
}
109-
110106
func (c *BPMConfig) JobConfig() string {
111-
return filepath.Join(c.ConfigDir(), "bpm.yml")
107+
return filepath.Join(c.JobDir(), "config", "bpm.yml")
112108
}
113109

114110
func (c *BPMConfig) BPMLog() string {
@@ -123,7 +119,7 @@ func (c *BPMConfig) RootFSPath() string {
123119
return filepath.Join(c.BundlePath(), "rootfs")
124120
}
125121

126-
func (c *BPMConfig) ContainerID(encoded bool) string {
122+
func (c *BPMConfig) ContainerID() string {
127123
var containerID string
128124

129125
if c.jobName == c.procName {
@@ -132,15 +128,11 @@ func (c *BPMConfig) ContainerID(encoded bool) string {
132128
containerID = fmt.Sprintf("%s.%s", c.jobName, c.procName)
133129
}
134130

135-
if encoded {
136-
containerID = Encode(containerID)
137-
}
138-
139-
return containerID
131+
// runc spec only allows `^[\w+-\.]+$`
132+
// https://github.com/opencontainers/runc/blob/master/libcontainer/factory_linux.go
133+
return Encode(containerID)
140134
}
141135

142-
// runc spec only allows `^[\w+-\.]+$`
143-
// https://github.com/opencontainers/runc/blob/master/libcontainer/factory_linux.go
144136
func Encode(containerID string) string {
145137
enc := base32.StdEncoding
146138
enc = enc.WithPadding('-')

src/bpm/config/bpm_config_test.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,21 @@ var _ = Describe("Config", func() {
4949
bpmCfg = config.NewBPMConfig("", "foo", "foo")
5050
})
5151

52-
It("encodes when passed true", func() {
53-
encoded := bpmCfg.ContainerID(true)
52+
It("encodes", func() {
53+
encoded := bpmCfg.ContainerID()
5454
Expect(encoded).To(Equal("MZXW6---"))
5555
})
56-
57-
It("doesn't encode when passed false", func() {
58-
plain := bpmCfg.ContainerID(false)
59-
Expect(plain).To(Equal("foo"))
60-
})
6156
})
6257

6358
Context("when the job name and process name are not the same", func() {
6459
BeforeEach(func() {
6560
bpmCfg = config.NewBPMConfig("", "foo", "bar")
6661
})
6762

68-
It("encodes when passed the true", func() {
69-
encoded := bpmCfg.ContainerID(true)
63+
It("encodes", func() {
64+
encoded := bpmCfg.ContainerID()
7065
Expect(encoded).To(Equal("MZXW6LTCMFZA----"))
7166
})
72-
73-
It("doesn't encode when passed false", func() {
74-
encoded := bpmCfg.ContainerID(false)
75-
Expect(encoded).To(Equal("foo.bar"))
76-
})
7767
})
7868
})
7969
})

src/bpm/runc/lifecycle/lifecycle.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (j *RuncLifecycle) StartProcess(logger lager.Logger, bpmCfg *config.BPMConf
145145
return j.runcClient.RunContainer(
146146
bpmCfg.PidFile(),
147147
bpmCfg.BundlePath(),
148-
bpmCfg.ContainerID(true),
148+
bpmCfg.ContainerID(),
149149
stdout,
150150
stderr,
151151
)
@@ -156,7 +156,7 @@ func (j *RuncLifecycle) StartProcess(logger lager.Logger, bpmCfg *config.BPMConf
156156
// - nil,nil if the process is not running and there is no other error
157157
// - nil,error if there is any other error getting the process beyond it not running
158158
func (j *RuncLifecycle) GetProcess(cfg *config.BPMConfig) (*models.Process, error) {
159-
container, err := j.runcClient.ContainerState(cfg.ContainerID(true))
159+
container, err := j.runcClient.ContainerState(cfg.ContainerID())
160160
if err != nil {
161161
return nil, err
162162
}
@@ -173,7 +173,7 @@ func (j *RuncLifecycle) GetProcess(cfg *config.BPMConfig) (*models.Process, erro
173173
}
174174

175175
func (j *RuncLifecycle) OpenShell(cfg *config.BPMConfig, stdin io.Reader, stdout, stderr io.Writer) error {
176-
return j.runcClient.Exec(cfg.ContainerID(true), "/bin/bash", stdin, stdout, stderr)
176+
return j.runcClient.Exec(cfg.ContainerID(), "/bin/bash", stdin, stdout, stderr)
177177
}
178178

179179
func (j *RuncLifecycle) ListProcesses() ([]*models.Process, error) {
@@ -195,12 +195,12 @@ func (j *RuncLifecycle) ListProcesses() ([]*models.Process, error) {
195195
}
196196

197197
func (j *RuncLifecycle) StopProcess(logger lager.Logger, cfg *config.BPMConfig, exitTimeout time.Duration) error {
198-
err := j.runcClient.SignalContainer(cfg.ContainerID(true), client.Term)
198+
err := j.runcClient.SignalContainer(cfg.ContainerID(), client.Term)
199199
if err != nil {
200200
return err
201201
}
202202

203-
state, err := j.runcClient.ContainerState(cfg.ContainerID(true))
203+
state, err := j.runcClient.ContainerState(cfg.ContainerID())
204204
if err != nil {
205205
logger.Error("failed-to-fetch-state", err)
206206
} else {
@@ -216,7 +216,7 @@ func (j *RuncLifecycle) StopProcess(logger lager.Logger, cfg *config.BPMConfig,
216216
for {
217217
select {
218218
case <-stateTicker.C():
219-
state, err = j.runcClient.ContainerState(cfg.ContainerID(true))
219+
state, err = j.runcClient.ContainerState(cfg.ContainerID())
220220
if err != nil {
221221
logger.Error("failed-to-fetch-state", err)
222222
} else {
@@ -225,7 +225,7 @@ func (j *RuncLifecycle) StopProcess(logger lager.Logger, cfg *config.BPMConfig,
225225
}
226226
}
227227
case <-timeout.C():
228-
err := j.runcClient.SignalContainer(cfg.ContainerID(true), client.Quit)
228+
err := j.runcClient.SignalContainer(cfg.ContainerID(), client.Quit)
229229
if err != nil {
230230
logger.Error("failed-to-sigquit", err)
231231
}
@@ -237,7 +237,7 @@ func (j *RuncLifecycle) StopProcess(logger lager.Logger, cfg *config.BPMConfig,
237237
}
238238

239239
func (j *RuncLifecycle) RemoveProcess(cfg *config.BPMConfig) error {
240-
err := j.runcClient.DeleteContainer(cfg.ContainerID(true))
240+
err := j.runcClient.DeleteContainer(cfg.ContainerID())
241241
if err != nil {
242242
return err
243243
}

0 commit comments

Comments
 (0)