forked from knative/serving
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't default Revision values when BYO name is unchanged. (knative#13565
) (#205) * Don't default Revision values when BYO name is unchanged. Fixes knative#11512 * Switch to using a context-passed ConfigurationSpec reference instead of hard-coding Configuration and Service. * Complete docstring for WithConfigurationSpec * Update naming per dave's feedback Co-authored-by: Evan Anderson <[email protected]>
- Loading branch information
1 parent
fb79933
commit bd52068
Showing
3 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |
"github.com/google/go-cmp/cmp" | ||
authv1 "k8s.io/api/authentication/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"knative.dev/pkg/apis" | ||
"knative.dev/pkg/ptr" | ||
|
@@ -173,6 +174,46 @@ func TestConfigurationDefaulting(t *testing.T) { | |
} | ||
} | ||
|
||
func TestBYORevisionName(t *testing.T) { | ||
new := &Configuration{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "thing", | ||
Annotations: map[string]string{"annotated": "yes"}, | ||
}, | ||
Spec: ConfigurationSpec{ | ||
Template: RevisionTemplateSpec{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "thing-2022", | ||
}, | ||
Spec: RevisionSpec{ | ||
PodSpec: corev1.PodSpec{ | ||
Containers: []corev1.Container{{ | ||
Image: "busybox", | ||
}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
old := new.DeepCopy() | ||
old.ObjectMeta.Annotations = map[string]string{} | ||
|
||
want := new.DeepCopy() | ||
|
||
ctx := apis.WithinUpdate(context.Background(), old) | ||
new.SetDefaults(ctx) | ||
|
||
if diff := cmp.Diff(want, new); diff != "" { | ||
t.Errorf("SetDefaults (-want, +got) = %v", diff) | ||
} | ||
|
||
new.SetDefaults(context.Background()) | ||
if cmp.Equal(want, new, ignoreUnexportedResources) { | ||
t.Errorf("Expected diff, got none! object: %v", new) | ||
} | ||
} | ||
|
||
func TestConfigurationUserInfo(t *testing.T) { | ||
const ( | ||
u1 = "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters