Skip to content

Commit 693afa0

Browse files
(devena-mono) Add golines pre-commit hook
The motivation here is have to think less about code formatting when writing code, e.g. " Should I break this long list of args up? Should I add a newline between all of these args". The `golangci-lint` team don't want to inlcude this there for reasons[1] so run it instead via `pre-commit`. This is using a fork which just has one extra commit[2] until [3] is merged upstream [1] golangci/golangci-lint#1914 [2] segmentio/golines@dedb5a0 [3] segmentio/golines#103
1 parent 45ac5b2 commit 693afa0

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

kustomize-build-dirs/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ Will result in the built manifests being placed at
2727
To avoid requiring extra broadly scoped credentials this program will empty
2828
any files containing secrets before running `kustomize build`. So the contents
2929
of any secrets will not be present in the output.
30-
*/
31-
package main
30+
*/package main
3231

3332
import (
3433
"errors"

kustomize-build-dirs/main_test.go

+27-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ func TestFailsWhenFailingToWriteManifest(t *testing.T) {
207207
buildDir := filepath.Join(outDir, manifestDir)
208208
require.NoError(t, os.Mkdir(outDir, 0o700))
209209
require.NoError(t, os.Mkdir(buildDir, 0o500))
210-
expectedErrPrefix := fmt.Sprintf("error writing to '%s'", filepath.Join(buildDir, manifestFileName))
210+
expectedErrPrefix := fmt.Sprintf(
211+
"error writing to '%s'",
212+
filepath.Join(buildDir, manifestFileName),
213+
)
211214

212215
deploymentPath := filepath.Join(manifestDir, "deployment.yaml")
213216
repoFiles := map[string]string{
@@ -252,8 +255,11 @@ secretGenerator:
252255
`
253256

254257
repoFiles := map[string]string{
255-
"secrets.yaml": "encryptedNonsensehere\xff\xff\n",
256-
".gitattributes": fmt.Sprintf("%s filter=strongbox diff=strongbox\n", "secrets.yaml"),
258+
"secrets.yaml": "encryptedNonsensehere\xff\xff\n",
259+
".gitattributes": fmt.Sprintf(
260+
"%s filter=strongbox diff=strongbox\n",
261+
"secrets.yaml",
262+
),
257263
"kustomization.yaml": kustomizationContent,
258264
}
259265

@@ -281,7 +287,12 @@ func readOutDir(t *testing.T, outDir string) map[string]string {
281287
return outfileContents
282288
}
283289

284-
func compareResults(t *testing.T, outDir string, expected map[string]string, got map[string]string) {
290+
func compareResults(
291+
t *testing.T,
292+
outDir string,
293+
expected map[string]string,
294+
got map[string]string,
295+
) {
285296
for relPath, expectedManifest := range expected {
286297
expectedPath := filepath.Join(outDir, relPath, manifestFileName)
287298
gotManifest, ok := got[expectedPath]
@@ -346,7 +357,10 @@ func TestWriteMultipleManifests(t *testing.T) {
346357
"second-project": secondDeploymentcontent,
347358
}
348359

349-
require.NoError(t, kustomizeBuildDirs(outDir, false, []string{firstDeploymentPath, secondDeploymentPath}))
360+
require.NoError(
361+
t,
362+
kustomizeBuildDirs(outDir, false, []string{firstDeploymentPath, secondDeploymentPath}),
363+
)
350364
compareResults(t, outDir, expectedContents, readOutDir(t, outDir))
351365
}
352366

@@ -378,6 +392,13 @@ resources:
378392
manifestsDir: expectedContent,
379393
}
380394

381-
require.NoError(t, kustomizeBuildDirs(outDir, true, []string{filepath.Join(manifestsDir, "kustomization.yaml")}))
395+
require.NoError(
396+
t,
397+
kustomizeBuildDirs(
398+
outDir,
399+
true,
400+
[]string{filepath.Join(manifestsDir, "kustomization.yaml")},
401+
),
402+
)
382403
compareResults(t, outDir, expectedContents, readOutDir(t, outDir))
383404
}

validate-opslevel-annotations/main_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ func TestFailsOnInvalidManifests(t *testing.T) {
6767
expectedOut, err := os.ReadFile(filepath.Join(invalidManifestsDir, expectedOutFile))
6868
require.NoErrorf(t, err, "Can't find output file for %s", entry.Name())
6969
// .out files contain trailing newlines, but the error will not
70-
expectedErr := strings.TrimSuffix(fmt.Sprintf("failed validating manifests from %s: %s", manifest, string(expectedOut)), "\n")
70+
expectedErr := strings.TrimSuffix(
71+
fmt.Sprintf(
72+
"failed validating manifests from %s: %s",
73+
manifest,
74+
string(expectedOut),
75+
),
76+
"\n",
77+
)
7178

7279
gotErr := validateOpsLevelAnnotationsForManifests([]string{manifest})
7380
require.Error(t, gotErr)

0 commit comments

Comments
 (0)