Files
open-cluster-management/pkg/registration/register/token/options.go
Yang Le 9d1a993e2c
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
add token driver for addon registration (#1343)
Signed-off-by: Yang Le <yangle@redhat.com>
2026-01-28 05:41:52 +00:00

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
}