33// these should not happen in the first place.
44package defaults
55
6- var (
7- // DefaultProvider holds the default provider and is used by the exported functions.
8- DefaultProvider = NewProvider ("" )
9- )
10-
116var (
127 // provider holds a global reference to the default provider.
138 provider * Provider
@@ -16,88 +11,97 @@ var (
1611// Holds the default no proxy values.
1712var DefaultNoProxy = []string {"localhost" , "127.0.0.1" , ".default" , ".local" , ".svc" , "kubernetes" , "kotsadm-rqlite" }
1813
19- const ProxyRegistryAddress = "proxy.replicated.com"
14+ var ProxyRegistryAddress = "proxy.replicated.com"
2015
2116const KotsadmNamespace = "kotsadm"
2217const SeaweedFSNamespace = "seaweedfs"
2318const RegistryNamespace = "registry"
2419const VeleroNamespace = "velero"
2520
21+ // def returns a global reference to the default provider. creates one if not
22+ // already created.
23+ func def () * Provider {
24+ if provider == nil {
25+ provider = NewProvider ("" )
26+ }
27+ return provider
28+ }
29+
2630// BinaryName calls BinaryName on the default provider.
2731func BinaryName () string {
28- return DefaultProvider .BinaryName ()
32+ return def () .BinaryName ()
2933}
3034
3135// EmbeddedClusterBinsSubDir calls EmbeddedClusterBinsSubDir on the default provider.
3236func EmbeddedClusterBinsSubDir () string {
33- return DefaultProvider .EmbeddedClusterBinsSubDir ()
37+ return def () .EmbeddedClusterBinsSubDir ()
3438}
3539
3640// EmbeddedClusterChartsSubDir calls EmbeddedClusterChartsSubDir on the default provider.
3741func EmbeddedClusterChartsSubDir () string {
38- return DefaultProvider .EmbeddedClusterChartsSubDir ()
42+ return def () .EmbeddedClusterChartsSubDir ()
3943}
4044
4145// EmbeddedClusterImagesSubDir calls EmbeddedClusterImagesSubDir on the default provider.
4246func EmbeddedClusterImagesSubDir () string {
43- return DefaultProvider .EmbeddedClusterImagesSubDir ()
47+ return def () .EmbeddedClusterImagesSubDir ()
4448}
4549
4650// EmbeddedClusterLogsSubDir calls EmbeddedClusterLogsSubDir on the default provider.
4751func EmbeddedClusterLogsSubDir () string {
48- return DefaultProvider .EmbeddedClusterLogsSubDir ()
52+ return def () .EmbeddedClusterLogsSubDir ()
4953}
5054
5155// K0sBinaryPath calls K0sBinaryPath on the default provider.
5256func K0sBinaryPath () string {
53- return DefaultProvider .K0sBinaryPath ()
57+ return def () .K0sBinaryPath ()
5458}
5559
5660// PathToEmbeddedClusterBinary calls PathToEmbeddedClusterBinary on the default provider.
5761func PathToEmbeddedClusterBinary (name string ) string {
58- return DefaultProvider .PathToEmbeddedClusterBinary (name )
62+ return def () .PathToEmbeddedClusterBinary (name )
5963}
6064
6165// PathToLog calls PathToLog on the default provider.
6266func PathToLog (name string ) string {
63- return DefaultProvider .PathToLog (name )
67+ return def () .PathToLog (name )
6468}
6569
6670// PathToKubeConfig calls PathToKubeConfig on the default provider.
6771func PathToKubeConfig () string {
68- return DefaultProvider .PathToKubeConfig ()
72+ return def () .PathToKubeConfig ()
6973}
7074
7175// PreferredNodeIPAddress calls PreferredNodeIPAddress on the default provider.
7276func PreferredNodeIPAddress () (string , error ) {
73- return DefaultProvider .PreferredNodeIPAddress ()
77+ return def () .PreferredNodeIPAddress ()
7478}
7579
7680// TryDiscoverPublicIP calls TryDiscoverPublicIP on the default provider.
7781func TryDiscoverPublicIP () string {
78- return DefaultProvider .TryDiscoverPublicIP ()
82+ return def () .TryDiscoverPublicIP ()
7983}
8084
8185// PathToK0sConfig calls PathToK0sConfig on the default provider.
8286func PathToK0sConfig () string {
83- return DefaultProvider .PathToK0sConfig ()
87+ return def () .PathToK0sConfig ()
8488}
8589
8690// PathToK0sStatusSocket calls PathToK0sStatusSocket on the default provider.
8791func PathToK0sStatusSocket () string {
88- return DefaultProvider .PathToK0sStatusSocket ()
92+ return def () .PathToK0sStatusSocket ()
8993}
9094
9195func PathToK0sContainerdConfig () string {
92- return DefaultProvider .PathToK0sContainerdConfig ()
96+ return def () .PathToK0sContainerdConfig ()
9397}
9498
9599// EmbeddedClusterHomeDirectory calls EmbeddedClusterHomeDirectory on the default provider.
96100func EmbeddedClusterHomeDirectory () string {
97- return DefaultProvider .EmbeddedClusterHomeDirectory ()
101+ return def () .EmbeddedClusterHomeDirectory ()
98102}
99103
100104// PathToEmbeddedClusterSupportFile calls PathToEmbeddedClusterSupportFile on the default provider.
101105func PathToEmbeddedClusterSupportFile (name string ) string {
102- return DefaultProvider .PathToEmbeddedClusterSupportFile (name )
106+ return def () .PathToEmbeddedClusterSupportFile (name )
103107}
0 commit comments