mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
Some checks failed
Post / images (amd64, placement) (push) Failing after 50s
Post / images (amd64, registration) (push) Failing after 41s
Post / images (amd64, registration-operator) (push) Failing after 40s
Post / images (amd64, work) (push) Failing after 44s
Post / images (arm64, addon-manager) (push) Failing after 41s
Post / images (arm64, placement) (push) Failing after 42s
Post / images (arm64, registration) (push) Failing after 41s
Post / images (amd64, addon-manager) (push) Failing after 5m29s
Post / images (arm64, registration-operator) (push) Failing after 43s
Post / images (arm64, work) (push) Failing after 5m35s
Post / image manifest (addon-manager) (push) Has been skipped
Post / image manifest (placement) (push) Has been skipped
Post / image manifest (registration) (push) Has been skipped
Post / image manifest (registration-operator) (push) Has been skipped
Post / image manifest (work) (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 40m4s
Scorecard supply-chain security / Scorecard analysis (push) Failing after 4m1s
Signed-off-by: Yang Le <yangle@redhat.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package token
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
"open-cluster-management.io/ocm/pkg/registration/register"
|
|
)
|
|
|
|
// Option contains configuration for the token driver
|
|
type Option struct {
|
|
// ExpirationSeconds is the requested duration of validity of the token.
|
|
// This is used to configure the ServiceAccount token projection.
|
|
// Default is 31536000 seconds (1 year)
|
|
ExpirationSeconds int64
|
|
}
|
|
|
|
// Ensure Option implements register.TokenConfiguration interface at compile time
|
|
var _ register.TokenConfiguration = &Option{}
|
|
|
|
func NewTokenOption() *Option {
|
|
return &Option{
|
|
ExpirationSeconds: 31536000, // Default 1 year
|
|
}
|
|
}
|
|
|
|
func (o *Option) AddFlags(fs *pflag.FlagSet) {
|
|
fs.Int64Var(&o.ExpirationSeconds, "addon-token-expiration-seconds", o.ExpirationSeconds,
|
|
"Requested duration of validity of the token in seconds. Used for ServiceAccount token projection. Minimum 600 seconds (10 minutes)")
|
|
}
|
|
|
|
func (o *Option) Validate() error {
|
|
if o.ExpirationSeconds < 600 {
|
|
return errors.New("token expiration seconds must be at least 600 (10 minutes)")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (o *Option) GetExpirationSeconds() int64 {
|
|
return o.ExpirationSeconds
|
|
}
|