Commit Graph

111 Commits

Author SHA1 Message Date
Laszlo Bence Nagy ab6c488967 Add exportTo field to Istio CRDs (#586) 2019-08-27 10:50:40 -07:00
Scott Nichols 85d7d7ec71 correct a unmarshal error for non pointer members of apis.URL if empty string. (#594) 2019-08-22 08:03:34 -07:00
Spencer Peterson 0a0c4972cd Add Destination constructors (#572)
* add helper constructors for destination

* flesh out destination constructors and path appending
2019-08-14 10:48:08 -07:00
Spencer Peterson 6a881edeba document ParseURL breaking the net/url api (#571) 2019-08-14 09:58:07 -07:00
Scott Nichols 11fec633e4 Adding Source ducktype. (#566)
* Adding Source ducktype.

* removing output format for now, revisit if we find more sources and consumers asking for it.
2019-08-13 10:58:06 -07:00
Scott Nichols a690d27530 Missed the deepcopy gen for Destination. Fixed. (#567) 2019-08-09 12:50:04 -07:00
mattmoor-sockpuppet a918c2d8f8 golang format tools (#565)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign @mattmoor
2019-08-09 12:11:06 -07:00
Scott Nichols 53034608f6 Adding apis/v1alpha1/Destination; future sink and subscriber object. (#561)
* adding apis/Destination; future sink and subscriber object.

* move Destination to a v1alpha1 dir.
2019-08-09 08:16:05 -07:00
Andrew Poydence 972acd413f apis: fix typo in ConditionSet.Manage comment (#551) 2019-07-30 08:52:43 -07:00
savitaashture cb7014ea6e Add validation for creator and lastModifier annotation (#539)
* Add validation for creator and lastModifier annotation

* Add test case for spec changes and /lastModifier updated changes
2019-07-28 21:51:04 -07:00
Spencer Peterson 154a0848d4 test for FieldError.Also(nil) (#545) 2019-07-28 09:36:04 -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
Jin Chi He 76da19bbc6 add openapi-gen=true for some structs (#510) 2019-07-11 21:17:33 -07:00
mattmoor-sockpuppet 1864f499dc golang format tools (#497)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign @mattmoor
2019-06-27 07:37:08 -07:00
Matt Moore 222dd25986 Migrate pkg to use the knative.dev/pkg import path (#489)
* Manual changes.

* scripted changes.
2019-06-26 13:02:06 -07:00
Ali Ok 9f8e0692b7 #457 Duck type user annotation logic (#467)
* #457 Duck type user annotation logic

* #457 Duck type user annotation logic - tests

* #457 Revert updater annotation key from lastModifier to updater

* #457 Rename HasSpec#GetSpec() to HasSpec#GetUntypedSpec()

* #457 Fix some indentation

* #457 Get group for user info annotations from the request

* #457 Reduce confusuion in webhook testing by using same group
2019-06-24 18:20:05 -07:00
Victor Agababov c2f344436b Better for loop for iterating over the channel (#458) 2019-06-12 13:40:44 -07:00
Matt Moore 262650b2c0 Incorporate the sub-resource context into the context state populated by the webhook. (#442) 2019-06-05 20:36:39 -07:00
Matt Moore 5fe2b490af Add a GetURL helper for consuming Addressable. (#434)
* Add a GetURL helper for consuming Addressable.

* Update apis/duck/v1alpha1/addressable_types_test.go

fix the copyright header

Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
2019-05-30 07:09:32 -07:00
Adriano Cunha c0132d9dde Update OWNERS to use OWNERS_ALIASES (#422) 2019-05-29 20:04:33 -07:00
Matt Moore 868008d0f8 Implement Addressable v1beta1 to use URL. (#401)
Fixes: https://github.com/knative/pkg/issues/395
2019-05-02 17:46:34 -07:00
Matt Moore 57fd07886b Add support for a structured URL type. (#400)
* Add support for a structured URL type.

This type can be used to accept `url: http://asdf.com` where in code we
get a `url.URL` to interact with.

* Propagate errors parsing, cast pointer instead of copying.
2019-05-01 18:40:33 -07:00
mattmoor-sockpuppet 105f928666 golang format tools (#397)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
2019-04-28 07:59:30 -07:00
lIuDuI 6916051a96 Using var() block to define variables (#394)
Signed-off-by: xichengliudui <1693291525@qq.com>
2019-04-23 08:53:29 -07:00
lIuDuI c697d0b0e1 Find some duplicate words for "the" and delete them (#392)
Signed-off-by: xichengliudui <1693291525@qq.com>
2019-04-22 10:54:28 -07:00
Scott Nichols 70ab9cc77d Adding Strict Validation based on struct.*Deprecated*Foo (#339)
* have simple tests. working on impl.

* strict setting, reflection based.

* ran codegen.

* adding license.

* update based on feedback and merge better.

* getting closer to something  simpler assuming shallow reflect.

* adding validation test.

* use the json tag.

* Golang things nil typed pointers are not nil.

* Use real value of reflect invalid.

* add a missing test.

* two methods, one for update, one for single check.

* checkdep is now in apis.

* fix pkg.

* Update apis/deprecated_test.go

Co-Authored-By: n3wscott <32305648+n3wscott@users.noreply.github.com>

* add code clarity.

* include inlined struct objects recursively.

* Update commnets and add a flatten error test for inlined.
2019-04-19 09:19:27 -07:00
Dan Gerdesmeier 6fa5cc22e3 Add CheckDisallowedFields (#389)
Adds a new function in FieldErrors for validating against fieldmasks.

See https://github.com/knative/serving/pull/3779 for usage.
2019-04-17 17:51:26 -07:00
Matt Moore efba541fdd Add support for the Istio 1.1 per-route Headers. (#385) 2019-04-15 14:37:00 -07:00
Matt Moore 2adf7f0c98 Add a few more general contexts built in serving. (#384)
Fix the user info annotation bug introduced along with the context stuff.

Fixes: https://github.com/knative/pkg/issues/383
2019-04-11 07:44:59 -07:00
Matt Moore 9eb762fd55 Add ObservedGeneration to what we convert. (#374) 2019-04-09 10:34:58 -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 f55c11c3ce ErrInvalidValue support for interface{} (#372) 2019-04-08 18:26:58 -07:00
Matt Moore e0fcca3e1d Enable our OOB error to take raw types. (#371) 2019-04-08 17:49:57 -07:00
Matt Moore 2b574edcd7 Deprecate apis.Immutable and apis.Annotatable. (#368)
This deprecates the `apis.Immutable` and `apis.Annotatable` interfaces,
which were both awkward niche extensions of `apis.Validatable` and
`apis.SetDefaults` for specific contexts that the former set didn't
cover well.

With this change, the expectation is that types that want to check
for immutability will instead access the "baseline" object via the
context from within updates.  For example:

```
func (new *Type) Validate(ctx context.Context) *apis.FieldError {
  if apis.IsInUpdate(ctx) {
    old := apis.GetBaseline(ctx).(*Type)
    // Update specific validation based on new and old.
  }
}
```

For applying user annotations, the type writer can write:

```
func (new *Type) SetDefaults(ctx context.Context) {
  if apis.IsInCreate(ctx) {
    ui := apis.GetUserInfo(ctx)
    // Set creator annotation from ui
  }

  if apis.IsInUpdate(ctx) {
    ui := apis.GetUserInfo(ctx)
    old := apis.GetBaseline(ctx).(*Type)
    // Compare old.Spec vs. new.Spec and on changes
    // update the "updater" annotation from ui.
  }
}
```

One of the key motivations for this refactoring was to enable us
to do more powerful validation in `apis.Validate` beyond the niche
of immutability checking (and without introducing yet-another
one-off niche interface).  In the BYO Revision name PoC I abused
`apis.Immutable` to do more arbitrary before/after validation,
which with this can simply be a part of `apis.Validatable`.

See: https://github.com/knative/serving/pull/3562

The general stance on deprecating interfaces such as these will be
to deprecate them in a non-breaking way (via a comment for now). They
will be hollowed out when the functionality is removed from the webhook,
but left in because of diamond dependency problems.  In this change
we remove the `apis.Annotatable` functionality and deprecate the
`apis.Immutable` functionality.
2019-04-08 10:26:58 -07:00
Matt Moore 42e08a4657 Add the Convertible interface. (#369)
This sketches the "Convertible" interface that @vagababov outlined in
last week's Serving API WG meeting.

See also: https://docs.google.com/document/d/1UFUfwIF4q4r6JVigom0jQivbcI8mFycWPc9z48yjSIc/edit#heading=h.9np2by1b65b
2019-04-08 07:21:58 -07:00
Victor Agababov 4993c57ea3 Share the common parts of Serving ObjectMeta validation (#367) (#370)
This assumes that we want to strictly allow DNS labels in names everywhere.
2019-04-07 15:19:57 -07:00
Matt Moore 21372d06ff Share the common parts of Serving ObjectMeta validation (#367)
This assumes that we want to strictly allow DNS labels in names everywhere.
2019-04-05 15:38:57 -07:00
Thomas Shafer c80cb7dee9 Remove unused receiver name (#366) 2019-04-05 11:01:57 -07:00
Thomas Shafer d5db385fcc Address some lint errors (#351)
* Fix lint error: Remove unused receiver name

* Fix lint error: consistent receiver name

* Update apis/duck/v1alpha1/conditions_types.go
Update apis/duck/v1alpha1/retired_targetable_types.go
Update apis/duck/v1alpha1/legacy_targetable_types.go

Co-Authored-By: trshafer <tshafer@google.com>
2019-04-05 08:52:57 -07:00
Victor Agababov 71f46d3165 Condition checkable utilities (#364)
* add the new files

* checkpoint

* use duck

* test –> testing
2019-04-05 07:26:57 -07:00
Zhimin Xiang ff46edef0a Add CredentialName into Gateway (#360) 2019-04-02 11:10:56 -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
Thomas Shafer 1d9d8f8871 Fix lint error: Address struct field naming (#352)
Ran ./hack/update-codegen.sh
2019-03-29 10:23:54 -07:00
Victor Agababov b032768e6d Fix v1beta1 deployment to v1 in test (#346) 2019-03-27 13:48:51 -07:00
Matt Moore a5a847fd5c Add a GetCondition method to Status (#336)
I wanted this when rewriting the Pipeline e2e test in Serving to use the dynamic client and checking status via this duck type.

See here: b0ad29dbc8/test/e2e/build_pipeline_test.go (L84)
2019-03-23 11:28:48 -07:00
Matt Moore 60fdcbcabd This threads a context.Context through the webhook interfaces we expose. (#332)
Related to: https://github.com/knative/pkg/issues/306
2019-03-21 10:48:48 -07:00
Scott Nichols 915415e7be Need to use patch merge for conditions. (#328)
* Need to use patch merge for conditions.

* use correct package.
2019-03-18 14:21:45 -07:00
Scott Nichols 587fb819f4 Add back KResourceStatus so eventing master can build serving 0.4 (#325)
* Add back KResourceStatus so eventing master can build serving 0.4

* update codegen.
2019-03-18 10:59:46 -07:00
Matt Moore 374ae9eb1f Expand the Conditions duck type to also encompass ObservedGeneration. (#324)
With this, the expectation is that folks can embed the following in
the status of their resource:

```go
type FooStatus struct {
	duckv1alpha1.Status `json:",inline"`

	// other fields
}
```

`ObservedGeneration` is important to the usefulness of our standard
conditions because `{Ready,Succeeded}: True` is only meaningful when
`.status.observedGeneration == .metadata.generation`.

When `.status.observedGeneration != .metadata.generation` it indicates
that the controller has not yet attempted to reconcile a change in the
desired state of the world (aka `spec:`).
2019-03-17 16:56:45 -07:00