Commit Graph

10 Commits

Author SHA1 Message Date
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Victor Agababov c451e3c37f
Various cleanups around the codebase (#1630)
* Various cleanups around the codebase

- unindent the else after return
- make things private that are not used anywhere
- rearrange params
- etc

* add
2020-08-17 19:11:13 -07:00
Markus Thömmes c75d324f8b
Code hygiene: Remove unused, use common constructs. (#1320) 2020-05-13 22:20:58 -07:00
Markus Thömmes 56c2594e4f Assorted linting fixes. (#840)
* Remove unused code.

* Remove unneeded loops.

* Remove unneeded Printf calls.

* Use time.Since instead of time.Now().Sub.

* Remove unused values.

* Rename error variable according to conventions.

* Return error last.

* Simplify array allocations.

* Remove leaky ticker.

* Remove Yoda conditions.

* Remove deprecated function to talk to GKE.

* Remove dot import.

* Remove empty critical section and replace with a channel operation.

* Add linter directives to explicitly state wanted weirdness.

* Update deps.

* Fix broken line.
2019-11-01 12:49:12 -07:00
Victor Agababov 74c5d67ea0 Fix the issues pointed out by staticcheck (#541)
* Fix the issues pointed out by staticcheck

* review fix
2019-07-23 13:13:36 -07:00
fatkun a3e4b8d9f7 Improve kmp.ShortDiff when one object is invalid (#528)
* Improve kmp.ShortDiff when one object is invalid

* Both are invalid throw an error

* If x is invalid and y is valid, add '+' prefix and no '-'

* If x is valid and y is invalid, add '-' prefix and not '+'

* * Extract diffString method for reduce duplicated code

* Add a map with missing key test case

* * Direct return diff string

* Map add a key unit test
2019-07-17 14:26:29 -07:00
Dan Gerdesmeier 1095a4eab0 Upgrade go-cmp and add new diff options to kmp (#382)
* Upgrade go-cmp and add new diff options to kmp

* Upgrades go-cmp to master
* Adds new kmp diff options (FieldListReporter and ShortDiffReporter)
* Update comments

FieldListReporter can be used to programatically find what fields differ
between two objects. This is useful in webhook object validation.

ShortDiffReporter was added as the default behavior for cmp.Diff is to
provide more context. The ShortDiff reporter is useful for use on API
fields where context is not necessarily as valuable. This keeps the
output short for use in log and error messages.

* Change from override to constraint

* Code Review Comments

* Improve test coverage

* Use JSON field names when present

No longer lowercase golang field names.

* Strip JSON non-key tag content
2019-04-15 13:41:00 -07:00
Victor Agababov a330baa9b0 Grep fix formatting issues (#233)
* Some fixes to the spoof.go and exporter.go

While reviewing some other CL, I saw some avenues for improving
spoof.go, to log the URL that's being fetched, which would help in test
debugging and to use switch construct, rather than nested if's.

While testing the change, I noticed some shifty loggin from the
exporter, so I fixed that as well while I was there.

* Continuation of the previous cleanups.

* Fix the issues with formatting by executing a grep

* and fix compilation error

* lowercase error

* fix the newly changed unit test
2019-01-18 14:33:32 -08:00
Dave Protasowski d6a2e27f7b 🦆 Duck Typing - add a ConformsToType helper (#220)
* duck typing - add a ConformsToType helper

Unlike VerifyType, ConformsToType will return the following:
- an error when any marshalling/unmarshalling fails
- false when the concrete type does not implement the duck type
- true when the concrete type implements the duck type

* use knative/pkg kmp to handle panics raised by go-cmp
2019-01-09 19:58:42 -08:00
jonjohnsonjr 3043da57e9 Add kmp, a safe wrapper for google/go-cmp (#197)
* Add kcmp, a safe wrapper for google/go-cmp

* Returns an error instead of panicking.
* Holds common options that we use.

* Rename things

kcmp -> kmp
Diff -> SafeDiff
2018-12-08 08:39:27 -08:00