Skip to content

Commit 3e04b3b

Browse files
Squashed commit of the following:
commit 4f13a99 Author: Devansh Mathur <[email protected]> Date: Thu Dec 5 16:51:14 2024 +0530 Adding multiline tests. commit ff7bb9a Author: Devansh Mathur <[email protected]> Date: Thu Dec 5 11:56:09 2024 +0530 Changing functionality of ParseKeyValue and adding tests. commit b8d1f0c Merge: d92cff4 cc345e6 Author: Devansh Mathur <[email protected]> Date: Tue Dec 3 19:35:44 2024 +0530 Merge branch 'CI-14828' of https://github.com/DevanshMathur19/drone-plugin-lib into CI-14828 Merging after rebase. commit d92cff4 Author: Devansh Mathur <[email protected]> Date: Tue Dec 3 19:34:26 2024 +0530 Rebasing and fixing. commit cc345e6 Author: Devansh Mathur <[email protected]> Date: Tue Dec 3 12:52:08 2024 +0530 Fixing lint errors. commit 4891b90 Author: Devansh Mathur <[email protected]> Date: Tue Dec 3 12:47:31 2024 +0530 Optimizing Tests. commit 05a2bbb Author: Devansh Mathur <[email protected]> Date: Tue Dec 3 12:07:56 2024 +0530 Adding UT's. commit ad9dad0 Merge: d58ad30 3de8df9 Author: OP (oppenheimer) <[email protected]> Date: Tue Dec 3 01:07:06 2024 +0530 Merge pull request drone-plugins#44 from drone-plugins/fix-staticcheck Fix staticcheck issue in .drone.yml commit 3de8df9 Author: OP (oppenheimer) <[email protected]> Date: Tue Dec 3 01:05:15 2024 +0530 Update .drone.yml commit deedf89 Author: OP (oppenheimer) <[email protected]> Date: Tue Dec 3 01:00:35 2024 +0530 Fix staticcheck issue in .drone.yml commit 85e2820 Author: Devansh Mathur <[email protected]> Date: Mon Dec 2 21:19:39 2024 +0530 Optimizing code . commit bbf67d8 Author: Devansh Mathur <[email protected]> Date: Wed Nov 20 16:21:19 2024 +0530 Adding new functions and updating Update and Delete methods.
1 parent 9be8372 commit 3e04b3b

File tree

4 files changed

+363
-13
lines changed

4 files changed

+363
-13
lines changed

.drone.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ steps:
1414
- name: staticcheck
1515
pull: always
1616
image: golang:1.19
17+
environment:
18+
GO111MODULE: "on" # Explicitly enable Go modules
1719
commands:
18-
- go get honnef.co/go/tools/cmd/staticcheck
19-
- go run honnef.co/go/tools/cmd/staticcheck ./...
20+
- go install honnef.co/go/tools/cmd/staticcheck@v0.4.3
21+
- staticcheck ./...
2022
volumes:
2123
- name: gopath
2224
path: /go

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
1212
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1313
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
1414
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15-
github.com/urfave/cli/v2 v2.11.1 h1:UKK6SP7fV3eKOefbS87iT9YHefv7iB/53ih6e+GNAsE=
16-
github.com/urfave/cli/v2 v2.11.1/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
17-
github.com/urfave/cli/v2 v2.23.5 h1:xbrU7tAYviSpqeR3X4nEFWUdB/uDZ6DE+HxmRU7Xtyw=
18-
github.com/urfave/cli/v2 v2.23.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
1915
github.com/urfave/cli/v2 v2.23.6 h1:iWmtKD+prGo1nKUtLO0Wg4z9esfBM4rAV4QRLQiEmJ4=
2016
github.com/urfave/cli/v2 v2.23.6/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
2117
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=

harness/variables.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func UpdateOrRemoveKeyValue(envVar, key, newValue string, delete bool) error {
129129
return WriteLines(filePath, updatedLines)
130130
}
131131

132-
// Helper function to read lines from a file.
132+
// ReadLines reads lines from a file and returns them as a slice of strings.
133133
func ReadLines(filename string) ([]string, error) {
134134
file, err := os.Open(filename)
135135
if err != nil {
@@ -145,7 +145,7 @@ func ReadLines(filename string) ([]string, error) {
145145
return lines, scanner.Err()
146146
}
147147

148-
// Helper function to write lines to a file.
148+
// WriteLines writes a slice of strings to a file, each string being written to a new line.
149149
func WriteLines(filename string, lines []string) error {
150150
file, err := os.Create(filename)
151151
if err != nil {
@@ -162,7 +162,7 @@ func WriteLines(filename string, lines []string) error {
162162
return nil
163163
}
164164

165-
// Helper function to parse a line into key and value, considering file format.
165+
// ParseKeyValue parses a key-value pair from a string and returns the key and value.
166166
func ParseKeyValue(line, ext string) (string, string) {
167167
if ext == ".env" {
168168
parts := strings.SplitN(line, "=", 2)
@@ -172,20 +172,20 @@ func ParseKeyValue(line, ext string) (string, string) {
172172
return strings.TrimSpace(parts[0]), ""
173173
} else if ext == ".out" {
174174
parts := strings.Fields(line)
175-
if len(parts) == 2 {
176-
return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
175+
if len(parts) > 1 {
176+
return strings.TrimSpace(parts[0]), strings.TrimSpace(strings.Join(parts[1:], " "))
177177
}
178178
return strings.TrimSpace(parts[0]), ""
179179
}
180180
return "", ""
181181
}
182182

183-
// Helper function to format a key-value pair as a line, considering file format.
183+
// FormatKeyValue formats a key-value pair into a string.
184184
func FormatKeyValue(key, value, ext string) string {
185185
if ext == ".env" {
186186
return fmt.Sprintf("%s=%s", key, value)
187187
} else if ext == ".out" {
188188
return fmt.Sprintf("%s %s", key, value)
189189
}
190190
return ""
191-
}
191+
}

0 commit comments

Comments
 (0)