[master] Auto-update dependencies (#270)

Produced via:
  `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh`
/assign n3wscott vagababov
/cc n3wscott vagababov
This commit is contained in:
Matt Moore 2020-05-11 09:08:47 -07:00 committed by GitHub
parent bed5ab4ba6
commit f41f931e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 13 deletions

4
go.mod
View File

@ -16,8 +16,8 @@ require (
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/code-generator v0.18.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176
knative.dev/pkg v0.0.0-20200509234445-b52862b1b3ea
knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5
)
replace (

8
go.sum
View File

@ -1371,15 +1371,15 @@ knative.dev/pkg v0.0.0-20191111150521-6d806b998379/go.mod h1:pgODObA1dTyhNoFxPZT
knative.dev/pkg v0.0.0-20200428194351-90fc61bae7f7/go.mod h1:o+e8OVEJKIuvXPsGVPIautjXgs05xbos7G+QMRjuUps=
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2 h1:Qu2NlOHb9p3g+CSL/ok9+FySowN60URFEKRSXfWtDv4=
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaCXJGgY8f90BmNBKSb8z6d/BTM=
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3 h1:qNt1XRLZriXPA6JLZvticQCWnNvJGiRaBPX34xlI2y8=
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3/go.mod h1:MUQe/bW75GmlVeyHmdKag77FJWQrNH3rxt2Q9E1JZJs=
knative.dev/pkg v0.0.0-20200509234445-b52862b1b3ea h1:pyaU/lOn4oJf3U1+2Nd28U2KbecmOwFaagaUfwYs6uQ=
knative.dev/pkg v0.0.0-20200509234445-b52862b1b3ea/go.mod h1:VR1a7CeToIFubOhOlipZn48szS34plPRwxJaOC6Rf9g=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55 h1:Ajn44+eHHjPQL/BQicj8LMy8VTD2ypMCfHJuZVGEtew=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c h1:GfRICwJBY2VmbzFzu/se73+gsfKEkc83qlTBcohJvN0=
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176 h1:Uab7/fRKm5lujDe+DorXGTA1v5ACzZ1wUwhcIvqcNjI=
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5 h1:4lQU2AMChE3Hb2WgHDFfhRbYlITCMUgQ2Y6eeIIEgxM=
knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=

View File

@ -22,6 +22,12 @@ import (
)
// VolatileTime wraps metav1.Time
//
// Unlike metav1.Time, VolatileTimes are considered semantically equal when
// using kubernetes semantic equality checks.
// Thus differing VolatileTime values are not considered different.
// Note, go-cmp will still return inequality, see unit test if you
// need this behavior for go-cmp.
type VolatileTime struct {
Inner metav1.Time
}
@ -39,7 +45,7 @@ func (t *VolatileTime) UnmarshalJSON(b []byte) error {
func init() {
equality.Semantic.AddFunc(
// Always treat VolatileTime fields as equivalent.
func(a, b VolatileTime) bool {
func(VolatileTime, VolatileTime) bool {
return true
},
)

View File

@ -211,6 +211,15 @@ func isNonNamespaced(tags map[string]map[string]string) bool {
return has
}
func isKRShaped(tags map[string]map[string]string) bool {
vals, has := tags["genclient"]
if !has {
return false
}
shaped, _ := vals["krshapedlogic"]
return shaped == "true"
}
func vendorless(p string) string {
if pos := strings.LastIndex(p, "/vendor/"); pos != -1 {
return p[pos+len("/vendor/"):]
@ -424,6 +433,7 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
extracted := extractCommentTags(t)
reconcilerClass, hasReconcilerClass := extractReconcilerClassTag(extracted)
nonNamespaced := isNonNamespaced(extracted)
isKRShaped := isKRShaped(extracted)
packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name))
@ -512,6 +522,7 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
reconcilerClass: reconcilerClass,
hasReconcilerClass: hasReconcilerClass,
nonNamespaced: nonNamespaced,
isKRShaped: isKRShaped,
})
return generators

View File

@ -40,6 +40,7 @@ type reconcilerReconcilerGenerator struct {
reconcilerClass string
hasReconcilerClass bool
nonNamespaced bool
isKRShaped bool
groupGoName string
groupVersion clientgentypes.GroupVersion
@ -74,6 +75,7 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
"version": namer.IC(g.groupVersion.Version.String()),
"class": g.reconcilerClass,
"hasClass": g.hasReconcilerClass,
"isKRShaped": g.isKRShaped,
"nonNamespaced": g.nonNamespaced,
"controllerImpl": c.Universe.Type(types.Name{
Package: "knative.dev/pkg/controller",
@ -309,9 +311,17 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
logger.Warnw("Failed to set finalizers", zap.Error(err))
}
{{if .isKRShaped}}
reconciler.PreProcessReconcile(ctx, resource)
{{end}}
// Reconcile this copy of the resource and then write back any status
// updates regardless of whether the reconciliation errored out.
reconcileEvent = r.reconciler.ReconcileKind(ctx, resource)
{{if .isKRShaped}}
reconciler.PostProcessReconcile(ctx, resource)
{{end}}
} else if fin, ok := r.reconciler.(Finalizer); ok {
// Append the target method to the logger.
logger = logger.With(zap.String("targetMethod", "FinalizeKind"))
@ -343,13 +353,19 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
if reconciler.EventAs(reconcileEvent, &event) {
logger.Infow("Returned an event", zap.Any("event", reconcileEvent))
r.Recorder.Eventf(resource, event.EventType, event.Reason, event.Format, event.Args...)
// the event was wrapped inside an error, consider the reconciliation as failed
if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent {
return reconcileEvent
}
return nil
} else {
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
return reconcileEvent
}
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
return reconcileEvent
}
return nil
}
`

View File

@ -452,6 +452,28 @@ value of the `<key>` annotation on a resource must match the value provided to
`NewImpl` (or `NewReconcile`) for `ReconcileKind` or `FinalizeKind` to be called
for that resource.
#### Annotation based common logic
**krshaped=true may become the default if omitted in the future**
Reconcilers can handle common logic for resources that conform to the KRShaped
interface. This allows the generated code to automatically increment
ObservedGeneration.
```go
// +genreconciler:krshapedlogic=true
```
Setting this annotation will emit the following in the generated reconciler.
```go
reconciler.PreProcessReconcile(ctx, resource)
reconcileEvent = r.reconciler.ReconcileKind(ctx, resource)
reconciler.PostProcessReconcile(ctx, resource)
```
#### Stubs
To get started, or to use as reference. It is intended to be copied out of the

4
vendor/modules.txt vendored
View File

@ -656,7 +656,7 @@ k8s.io/kube-openapi/pkg/util/sets
k8s.io/utils/buffer
k8s.io/utils/integer
k8s.io/utils/trace
# knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3
# knative.dev/pkg v0.0.0-20200509234445-b52862b1b3ea
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
knative.dev/pkg/apis/duck/v1
@ -676,7 +676,7 @@ knative.dev/pkg/metrics
knative.dev/pkg/metrics/metricskey
knative.dev/pkg/reconciler
knative.dev/pkg/tracker
# knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176
# knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5
knative.dev/test-infra/scripts
knative.dev/test-infra/tools/dep-collector
# sigs.k8s.io/yaml v1.1.0