mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #59428 from mikedanese/id-defaults
Automatic merge from submit-queue (batch tested with PRs 59052, 59157, 59428, 59949, 60151). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. svcacct: default expiration of TokenRequest * default expiration seconds to 1 hour ```release-note NONE ```
This commit is contained in:
commit
814615aa84
@ -145,6 +145,7 @@ func TestDefaulting(t *testing.T) {
|
||||
{Group: "storage.k8s.io", Version: "v1beta1", Kind: "StorageClassList"}: {},
|
||||
{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClass"}: {},
|
||||
{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClassList"}: {},
|
||||
{Group: "authentication.k8s.io", Version: "v1", Kind: "TokenRequest"}: {},
|
||||
}
|
||||
|
||||
f := fuzz.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1))
|
||||
|
@ -17,9 +17,17 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
authenticationv1 "k8s.io/api/authentication/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_TokenRequestSpec(obj *authenticationv1.TokenRequestSpec) {
|
||||
if obj.ExpirationSeconds == nil {
|
||||
hour := int64(60 * 60)
|
||||
obj.ExpirationSeconds = &hour
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/authentication/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@ -28,5 +29,10 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v1.TokenRequest{}, func(obj interface{}) { SetObjectDefaults_TokenRequest(obj.(*v1.TokenRequest)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_TokenRequest(in *v1.TokenRequest) {
|
||||
SetDefaults_TokenRequestSpec(&in.Spec)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user