Commit Graph

19 Commits

Author SHA1 Message Date
Dave Protasowski ee1db869c7
Update linter config and address lint warnings/failures (#3068)
* fix whitespace linter

* fix usestdlibvars

* fix staticheck

* ignore spancheck warning

* fix linter perfsprint

* fix nolintlint feedback

* fix nilerr lint checks

* fix misspell

* fix mirror lint

* fix intrange linter

* fix gofumpt linter

* fix gosec linter - ignore warning since default min tls version is 1.3

* fix gocritic linter

* fix whitespace

* fix fatcontext linter

* fix errorlint

* fix errname linter

* fix copyloopvar (go1.22) linter

* fix bodyclose linter

* update linter config

* add script to format code

* fix unit test
2024-06-25 14:49:36 +00:00
Dave Protasowski 8535fcc248
gofumpt the repo (#3067)
* gofumpt the repo

* don't prefix numbers with 0 - otherwise they're octal
2024-06-25 07:27:07 +00:00
Markus Thömmes 980a33719a
Fix revive related linting issues (#2131) 2021-05-26 01:10:28 -07:00
Markus Thömmes 5fbbde31b3
Align linters with serving (enables stylecheck and asciicheck) (#1738) 2020-09-23 07:37:40 -07:00
Victor Agababov eb05e8dd5b
Various cleanups (#1446)
Thanks @markusthoemmes for the tool :)
2020-06-24 14:04:28 -07:00
Weston Haught c88f43eed9
Create a common method for processing reconciliation on generic KRShaped (#1284)
* Split KResource into a file. Include an interface.

* Update apis/duck/v1/kresource_type.go

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* type

* rename to KRShaped

* Create common logic for bumping obsgen

* fix typo

* remove interface cast

* missed a spot

* Update to use ObjectMetaAccessor

* switch alias to duckv1

* fix var names

* include a reason

* Switch to preprocess

* rename variable from new to resource

* Create a table style test

* missed a spot

* update deps

* fix nits

* fix gomod deps

* update with new KRshaped

* Update reconciler/reconcile_common_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update reconciler/reconcile_common_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update reconciler/reconcile_common_test.go

Co-authored-by: Matt Moore <mattmoor@vmware.com>

Co-authored-by: Matt Moore <mattmoor@vmware.com>
Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-05-06 17:10:44 -07:00
Markus Thömmes d29cf98a77
Assorted linting fixes. (#1249)
* Remove unused code.

* Use raw strings to avoid escaping.

* Remove unneeded type conversions.

* Preallocate slices where possible.

* Use semantic equality in psbinding reconciler.
2020-04-28 08:20:51 -07:00
Kenjiro Nakayama fcff978f32
Do not set to unknown status when all dependents passed happy check (#1187)
* Do not set to unknown status when all dependents passed unhappy check

`accessor.GetConditions()` in `findUnhappyDependent()` gets status
filed from runtime. So, if an object has following status:

```
  status:
    address:
      url: http://hello-example.default.svc.cluster.local
    conditions:
    - lastTransitionTime: "2020-04-02T09:49:03Z"
      status: "True"
      type: AllTrafficAssigned
    - lastTransitionTime: "2020-04-02T09:49:03Z"
      message: autoTLS is not enabled
      reason: AutoTLSNotEnabled
      severity: Info
      status: "True"
      type: CertificateProvisioned
    - lastTransitionTime: "2020-04-02T09:49:05Z"
      status: "True"
      type: IngressReady
    - lastTransitionTime: "2020-04-02T09:49:05Z"
      status: "True"
      type: Ready
```

`accessor.GetConditions()` returns AllTrafficAssigned,
CertificateProvisioned, IngressReady (and Ready).

Then, current code (`len(r.dependents) != len(conditions)`) sets to
Unknown if all conditions are not unhappy. However, it does not work
if we added a new dependent and downgraded the cluster because
the number of dependents is less than current status conditions.

If all dependents are verified, it should not set to unknown
status. So, this patch changed it.

* Add unit test
2020-04-04 11:10:18 -07:00
Kenjiro Nakayama c13e86e2d4
Add MarkTrueWithReason function to ConditionManager (#1148)
* Add MarkTrueWithReason function to ConditionManager

When using `MarkTrue()` function, it does not allow us to add the reason and message.
Also, if we use `SetCondition()` instead, it does not update the happy condtion.

So, this PR adds new `MarkTrueWithReason(reason, message)` function.

* Make test better

* Add unit test for MarkTrueWithReason

* Rename markHappy with recomputeHappiness
2020-03-19 09:36:06 -07:00
Dave Protasowski 5bc49f27e6
use interfaces when testing conditions so we don't need versioned methods (#1120) 2020-02-24 09:23:08 -08:00
Scott Nichols d9a38f13e8
Nil check conditions (#1112)
* Realized a corner case on ordering and False > Unknown states.

* add test with unknown fall through.

* I guess some integartions allow nil happy

* add unit tests for GetMessage and GetReason

* all conditons can be nil.

* Search for unhappy dependents.

* update codegen

* Remove KResource from v1alpha1 ducks.
2020-02-20 11:20:06 -08:00
Scott Nichols d38e1f8bde
Realized a corner case on ordering and False > Unknown states. (#1110)
* Realized a corner case on ordering and False > Unknown states.

* add test with unknown fall through.
2020-02-20 06:55:06 -08:00
Scott Nichols 5c9bc970ce
Clear falied propagation status of the top level condition if cleared. (#1108) 2020-02-19 21:16:06 -08:00
capri-xiyue fa1c639c93 Add helper methods in conditon_set (#965)
* added isUnknown in condition_set

* added IsFalse for condition set

* added GetHappyCondition

* modified comments

* modified the code based on cr

* renamed the method and removed isXXX() methods

* modified comments
2020-01-06 08:00:49 -08:00
Andrew Poydence 972acd413f apis: fix typo in ConditionSet.Manage comment (#551) 2019-07-30 08:52:43 -07:00
Johnu George 86f49e59e0 Implement ClearCondition for ConditionManager (#538)
* Implement RemoveCondition for ConditionManager

This implements RemoveCondition to remove a condition that matches
the condition type. Happy condition is changed appropriately if it
is a terminal and satifies one of the following conditions
1. RemovedCondition is false and happy is false
    Happy can change from false to unknown or true
2. RemovedCondition is unknown and happy is unknown
    Happy can change from unknown to true

* comment edit

* Addresses review comments

* Support only non terminal conditions

* Fix check
2019-07-24 14:22:35 -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
Matt Moore 31649c272a Start to lay the groundwork for Status conversion. (#373)
The backbone of our Condition system is our "happy" condition and
the semantics governing how other subconditions influence that condition.
When looking towards Conversion, it is possible for the set of conditions
to vary between `v1alpha1` and `v1beta1`, but the "happy" condition should
remain consistent across versions.

The main changes:
1. Provide a `ConvertTo` helper for "converting" between `duckv1beta1.Status`
 types in this "lowest common denominator" sense, where we just copy the
 happy condition.
2. When `InitializeConditions()` (plural) is called, seed the initial state
 of sub-conditions from the initial state of the "happy" condition, if True.

This change enables us to completely change the condition space across
versions, while maintaining the consistency of the happy condition.

A couple peripheral changes:
1. Add `context.Context` to the `apis.Convertible` interface.
2. Drop `InitializeCondition()` (singular) from the `ConditionsManager` interface (I don't see any usage outside of this file).
2019-04-09 08:22:59 -07:00
Matt Moore 281cda84ce Move Condition stuff to apis, add a v1beta1 Status. (#361)
This moves the common Condition stuff to apis, and creates a v1beta1 form of Status that uses the Condition it defines (changing this in v1alpha1 is too breaking).

There aren't really any meaningful changes in this PR, mostly reorganization.  Enumerating what I did:
1. Copied `condition_set*.go` to `apis/`,
1. Copied the `Condition` portions of `conditions_types.go` to `apis/`,
1. Copied the balance of `conditions_types.go` to `apis/duck/v1beta1/status_types.go`,
1. Changed the parts of the above to reference things in the appropriate new places,
1. Removed the reflection-based `ConditionsAccessor` stuff, implementing it instead on `duckv1beta1.Status`.
1. Incorporate: https://github.com/knative/pkg/pull/358
2019-04-02 09:51:55 -07:00