mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
svcacct: default expiration of TokenRequest
* default expiration seconds to 1 hour
This commit is contained in:
parent
d594a13d69
commit
e1586eaca0
@ -143,6 +143,7 @@ func TestDefaulting(t *testing.T) {
|
|||||||
{Group: "storage.k8s.io", Version: "v1beta1", Kind: "StorageClassList"}: {},
|
{Group: "storage.k8s.io", Version: "v1beta1", Kind: "StorageClassList"}: {},
|
||||||
{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClass"}: {},
|
{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClass"}: {},
|
||||||
{Group: "storage.k8s.io", Version: "v1", Kind: "StorageClassList"}: {},
|
{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))
|
f := fuzz.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1))
|
||||||
|
@ -17,9 +17,17 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
return RegisterDefaults(scheme)
|
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
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
v1 "k8s.io/api/authentication/v1"
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,5 +29,10 @@ import (
|
|||||||
// Public to allow building arbitrary schemes.
|
// Public to allow building arbitrary schemes.
|
||||||
// All generated defaulters are covering - they call all nested defaulters.
|
// All generated defaulters are covering - they call all nested defaulters.
|
||||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||||
|
scheme.AddTypeDefaultingFunc(&v1.TokenRequest{}, func(obj interface{}) { SetObjectDefaults_TokenRequest(obj.(*v1.TokenRequest)) })
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetObjectDefaults_TokenRequest(in *v1.TokenRequest) {
|
||||||
|
SetDefaults_TokenRequestSpec(&in.Spec)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user