Skip to content

Commit 9610e12

Browse files
pacostaspaketo-bot
authored andcommitted
fix: linting issues
1 parent 2396ebb commit 9610e12

5 files changed

Lines changed: 34 additions & 22 deletions

File tree

build.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,21 @@ func Build(logger scribe.Emitter, reloader Reloader) packit.BuildFunc {
4545
arg = fmt.Sprintf("cd %s && %s", projectPath, arg)
4646
}
4747

48-
// ubuntu uses dash as the default shell while ubi uses bash as the default shell
49-
// The version of bash on the current ubi images does not work properly with the
50-
// signal handling added in the script. Running with bash -c and escaping quotes in
51-
// the command changes the behavior so that it matches that when running with dash
52-
// This is fixed in more recent versions of bash ( 5.x and greater) but it will be some
53-
// time before ubi (and ubuntu it seems) will use that new a version of bash. This work
54-
// around is needed until then.
48+
/*
49+
Ubuntu uses Dash as the default shell, while UBI uses Bash.
50+
The version of Bash on the current UBI images does not properly handle
51+
the signal handling logic added in the script. Running the command using bash -c
52+
and escaping the quotes changes the behavior to match that of of running with Dash.
53+
This issue is fixed in more recent versions of Bash (>=5.x), however until UBI and Ubuntu
54+
begin using this version, the following workaround is necesary.
55+
*/
5556
etcOsReleaseFileContent, err := os.ReadFile(filepath.Join("/etc/os-release"))
5657
if err == nil {
5758
re := regexp.MustCompile(`ID=(rhel|"rhel")`)
5859

5960
match := re.FindStringSubmatch(string(etcOsReleaseFileContent))
6061
if match != nil {
61-
arg = fmt.Sprintf("bash -c \"%s\"", strings.Replace(arg, `"`, `\"`, -1))
62+
arg = fmt.Sprintf("bash -c \"%s\"", strings.ReplaceAll(arg, `"`, `\"`))
6263
}
6364
}
6465

integration/app_with_start_cmd_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ func testAppWithStartCmd(t *testing.T, context spec.G, it spec.S) {
8989

9090
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
9191
Expect(err).NotTo(HaveOccurred())
92-
defer response.Body.Close()
92+
defer func() {
93+
Expect(response.Body.Close()).To(Succeed())
94+
}()
9395

9496
Expect(response.StatusCode).To(Equal(http.StatusOK))
9597

@@ -145,7 +147,9 @@ func testAppWithStartCmd(t *testing.T, context spec.G, it spec.S) {
145147

146148
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
147149
Expect(err).NotTo(HaveOccurred())
148-
defer response.Body.Close()
150+
defer func() {
151+
Expect(response.Body.Close()).To(Succeed())
152+
}()
149153

150154
Expect(response.StatusCode).To(Equal(http.StatusOK))
151155

@@ -162,7 +166,7 @@ func testAppWithStartCmd(t *testing.T, context spec.G, it spec.S) {
162166
Eventually(cLogs).Should(ContainSubstring("start:dev"))
163167
})
164168

165-
it("builds a working OCI image and runs a start cmd with arg", func() {
169+
it("builds a working OCI image and runs a start cmd with arg", func() {
166170
var err error
167171
source, err = occam.Source(filepath.Join("testdata", "app_with_start_cmd"))
168172
Expect(err).NotTo(HaveOccurred())
@@ -194,7 +198,9 @@ it("builds a working OCI image and runs a start cmd with arg", func() {
194198

195199
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
196200
Expect(err).NotTo(HaveOccurred())
197-
defer response.Body.Close()
201+
defer func() {
202+
Expect(response.Body.Close()).To(Succeed())
203+
}()
198204

199205
Expect(response.StatusCode).To(Equal(http.StatusOK))
200206

integration/graceful_shutdown_app_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ func testGracefulShutdown(t *testing.T, context spec.G, it spec.S) {
9090

9191
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
9292
Expect(err).NotTo(HaveOccurred())
93-
defer response.Body.Close()
93+
defer func() {
94+
Expect(response.Body.Close()).To(Succeed())
95+
}()
9496

9597
Expect(response.StatusCode).To(Equal(http.StatusOK))
9698

integration/init_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ var settings struct {
5252
func TestIntegration(t *testing.T) {
5353
Expect := NewWithT(t).Expect
5454

55-
file, err := os.Open("../integration.json")
55+
integrationFile, err := os.Open("../integration.json")
5656
Expect(err).NotTo(HaveOccurred())
57-
defer file.Close()
58-
59-
Expect(json.NewDecoder(file).Decode(&settings.Config)).To(Succeed())
60-
61-
file, err = os.Open("../buildpack.toml")
57+
err = json.NewDecoder(integrationFile).Decode(&settings.Config)
6258
Expect(err).NotTo(HaveOccurred())
59+
Expect(integrationFile.Close()).To(Succeed())
6360

64-
_, err = toml.NewDecoder(file).Decode(&settings.Buildpack)
61+
buildpackFile, err := os.Open("../buildpack.toml")
62+
Expect(err).NotTo(HaveOccurred())
63+
_, err = toml.NewDecoder(buildpackFile).Decode(&settings.Buildpack)
6564
Expect(err).NotTo(HaveOccurred())
6665

6766
root, err := filepath.Abs("./..")

integration/project_path_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ func testProjectPath(t *testing.T, context spec.G, it spec.S) {
9898

9999
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
100100
Expect(err).NotTo(HaveOccurred())
101-
defer response.Body.Close()
101+
defer func() {
102+
Expect(response.Body.Close()).To(Succeed())
103+
}()
102104

103105
Expect(response.StatusCode).To(Equal(http.StatusOK))
104106

@@ -161,7 +163,9 @@ func testProjectPath(t *testing.T, context spec.G, it spec.S) {
161163

162164
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
163165
Expect(err).NotTo(HaveOccurred())
164-
defer response.Body.Close()
166+
defer func() {
167+
Expect(response.Body.Close()).To(Succeed())
168+
}()
165169

166170
Expect(response.StatusCode).To(Equal(http.StatusOK))
167171

0 commit comments

Comments
 (0)