-
Notifications
You must be signed in to change notification settings - Fork 31
feat: add linting to actions ci #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: "2" | ||
| linters: | ||
| enable: | ||
| - govet | ||
| - staticcheck | ||
| - errcheck | ||
| - gosec | ||
| run: | ||
| timeout: 5m | ||
| issues: | ||
| exclude-use-default: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
| "encoding/json" | ||
| "fmt" | ||
| "io" | ||
| "log" | ||
| "log/slog" | ||
| "net/http" | ||
| "time" | ||
|
|
@@ -106,7 +107,7 @@ func Handler(client *k8s.Client, cache *wasm.ModuleCache, controllers *atc.Contr | |
| continue | ||
| } | ||
|
|
||
| unstructured.SetNestedField(raw, originalStatus, "status") | ||
| _ = unstructured.SetNestedField(raw, originalStatus, "status") | ||
|
|
||
| data, err := json.Marshal(raw) | ||
| if err != nil { | ||
|
|
@@ -232,7 +233,10 @@ func Handler(client *k8s.Client, cache *wasm.ModuleCache, controllers *atc.Contr | |
|
|
||
| addRequestAttrs(r.Context(), slog.Bool("skipped", true)) | ||
|
|
||
| json.NewEncoder(w).Encode(&review) | ||
| if err := json.NewEncoder(w).Encode(&review); err != nil { | ||
| log.Fatalf("error in encoding: %v", err) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely cannot be fatal. Client connections to our server can dissappear, or there can be other reasons that we might fail to write to any give http.ResponseWriter. I believe we already have a logger in scope |
||
| } | ||
|
|
||
| return | ||
| } | ||
|
|
||
|
|
@@ -354,7 +358,9 @@ func Handler(client *k8s.Client, cache *wasm.ModuleCache, controllers *atc.Contr | |
| "allowed", review.Response.Allowed, | ||
| "details", review.Response.Result.Message, | ||
| )) | ||
| json.NewEncoder(w).Encode(review) | ||
| if err := json.NewEncoder(w).Encode(review); err != nil { | ||
| log.Fatalf("error in encoding: %v", err) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| } | ||
| }() | ||
|
|
||
| addRequestAttrs(r.Context(), slog.String("resourceId", internal.Canonical(prev))) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package main | |
|
|
||
| import ( | ||
| "encoding/json" | ||
| "log" | ||
| "os" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -12,7 +13,7 @@ import ( | |
|
|
||
| func main() { | ||
| // This flight needs cross-namespace to be set in order to work and serves to test that feature. | ||
| json.NewEncoder(os.Stdout).Encode(flight.Resources{ | ||
| if err := json.NewEncoder(os.Stdout).Encode(flight.Resources{ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just testing. If it fails it will get caught in the tests. _ = json.NewEncoder(...).Encode(...) |
||
| &corev1.ConfigMap{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: "v1", | ||
|
|
@@ -33,5 +34,7 @@ func main() { | |
| Namespace: "bar", | ||
| }, | ||
| }, | ||
| }) | ||
| }); err != nil { | ||
| log.Fatalf("error: %v\n", err) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package main | |
|
|
||
| import ( | ||
| "encoding/json" | ||
| "log" | ||
| "os" | ||
|
|
||
| batchv1 "k8s.io/api/batch/v1" | ||
|
|
@@ -12,7 +13,7 @@ import ( | |
| ) | ||
|
|
||
| func main() { | ||
| json.NewEncoder(os.Stdout).Encode(flight.Resources{ | ||
| if err := json.NewEncoder(os.Stdout).Encode(flight.Resources{ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| &batchv1.Job{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: batchv1.SchemeGroupVersion.Identifier(), | ||
|
|
@@ -37,5 +38,7 @@ func main() { | |
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| }); err != nil { | ||
| log.Fatalf("error: %v\n", err) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.