mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
kubeadm: make the active timeouts structure accessible from anywhere
Currently, timeouts are only accessible if a kubeadm runtime.Object{}
like InitConfiguration is passed around.
Any time a config is loaded or defaulted, store the Timeouts
structure in a thread-safe way in the main kubeadm API package
with SetActiveTimeouts(). Optionally, a deep-copy can be
performed before calling SetActiveTimeouts(). Make this struct
accessible with GetActiveTimeouts(). Ensure these functions
are thread safe.
On init() make sure the struct is defaulted, so that unit
tests can work with these values.
This commit is contained in:
@@ -62,13 +62,20 @@ func SetJoinControlPlaneDefaults(cfg *kubeadmapi.JoinControlPlane) error {
|
||||
// Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc)
|
||||
// Lastly, the internal config is validated and returned.
|
||||
func LoadOrDefaultJoinConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1.JoinConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.JoinConfiguration, error) {
|
||||
var (
|
||||
config *kubeadmapi.JoinConfiguration
|
||||
err error
|
||||
)
|
||||
if cfgPath != "" {
|
||||
// Loads configuration from config file, if provided
|
||||
// Nb. --config overrides command line flags, TODO: fix this
|
||||
return LoadJoinConfigurationFromFile(cfgPath, opts)
|
||||
config, err = LoadJoinConfigurationFromFile(cfgPath, opts)
|
||||
} else {
|
||||
config, err = DefaultedJoinConfiguration(defaultversionedcfg, opts)
|
||||
}
|
||||
|
||||
return DefaultedJoinConfiguration(defaultversionedcfg, opts)
|
||||
if err == nil {
|
||||
prepareStaticVariables(config)
|
||||
}
|
||||
return config, err
|
||||
}
|
||||
|
||||
// LoadJoinConfigurationFromFile loads versioned JoinConfiguration from file, converts it to internal, defaults and validates it
|
||||
|
||||
Reference in New Issue
Block a user