Skip to content

Commit a648c53

Browse files
committed
fix decorator test
1 parent a8e6ff2 commit a648c53

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/authorization/decorator_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"github.com/google/go-cmp/cmp"
2525

26-
auditapis "k8s.io/apiserver/pkg/apis/audit"
2726
"k8s.io/apiserver/pkg/audit"
2827
"k8s.io/apiserver/pkg/authorization/authorizer"
2928
)
@@ -218,17 +217,14 @@ func TestDecorator(t *testing.T) {
218217
} {
219218
t.Run(name, func(t *testing.T) {
220219
ctx := audit.WithAuditContext(context.Background())
221-
auditCtx := audit.AuditContextFrom(ctx)
222-
auditCtx.Event = auditapis.Event{
223-
Level: auditapis.LevelMetadata,
224-
}
220+
225221
attr := authorizer.AttributesRecord{}
226222
dec, reason, _ := tc.authz.Authorize(ctx, attr)
227223
if dec != tc.wantDecision {
228224
t.Errorf("want decision %v got %v", tc.wantDecision, dec)
229225
}
230-
ev := audit.AuditEventFrom(ctx)
231-
if diff := cmp.Diff(tc.wantAudit, ev.Annotations); diff != "" {
226+
ev := audit.AuditContextFrom(ctx)
227+
if diff := cmp.Diff(tc.wantAudit, ev.GetEventAnnotations()); diff != "" {
232228
t.Errorf("audit log annotations differ: %v", diff)
233229
}
234230
if tc.wantReason != reason {

pkg/features/kcp_features.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var DefaultFeatureGate = utilfeature.DefaultFeatureGate
6868
func init() {
6969
utilruntime.Must(utilfeature.DefaultMutableFeatureGate.AddVersioned(defaultVersionedGenericControlPlaneFeatureGates))
7070

71-
disableFeatures()
71+
utilruntime.Must(disableFeatures())
7272
}
7373

7474
func KnownFeatures() []string {
@@ -163,13 +163,17 @@ var defaultVersionedGenericControlPlaneFeatureGates = map[featuregate.Feature]fe
163163
}
164164

165165
// disableFeatures sets features that kcp wants disabled/enabled by default.
166-
func disableFeatures() {
166+
func disableFeatures() error {
167167
toDisable := map[featuregate.Feature]bool{
168168
// We disable SizeBasedListCostEstimate by default in kcp as stats collector does not have cluster awarness yet.
169169
// We add this here to track changes in future k8s releases.
170170
genericfeatures.SizeBasedListCostEstimate: false,
171171
}
172172
for f, v := range toDisable {
173-
utilfeature.DefaultMutableFeatureGate.Set(fmt.Sprintf("%s=%v", f, v))
173+
err := utilfeature.DefaultMutableFeatureGate.Set(fmt.Sprintf("%s=%v", f, v))
174+
if err != nil {
175+
return err
176+
}
174177
}
178+
return nil
175179
}

0 commit comments

Comments
 (0)