-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
971c46c
commit b7ae955
Showing
11 changed files
with
136 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v1 | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type MicroclusterConfig interface { | ||
ToMicrocluster() (map[string]string, error) | ||
} | ||
|
||
// ToMicrocluster implements the conversion to Microcluster for any MicroclusterConfig. | ||
func ToMicrocluster(m MicroclusterConfig, key string) (map[string]string, error) { | ||
config, err := json.Marshal(m) | ||
if err != nil { | ||
return nil, fmt.Errorf("Failed to marshal config %s: %w", key, err) | ||
} | ||
return map[string]string{key: string(config)}, nil | ||
} | ||
|
||
// ConfigFromMicrocluster parses a Microcluster map[string]string and retrieves the Config structure based on the provided MicroclusterConfig type. | ||
func ConfigFromMicrocluster(m map[string]string, key string, target MicroclusterConfig) error { | ||
if err := json.Unmarshal([]byte(m[key]), target); err != nil { | ||
return fmt.Errorf("failed to unmarshal %s: %w", key, err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package v1 | ||
|
||
type ControlPlaneNodeJoinConfig struct { | ||
APIServerCert *string `json:"apiserver-crt,omitempty" yaml:"apiserver-crt,omitempty"` | ||
APIServerKey *string `json:"apiserver-key,omitempty" yaml:"apiserver-key,omitempty"` | ||
KubeletCert *string `json:"kubelet-crt,omitempty" yaml:"kubelet-crt,omitempty"` | ||
KubeletKey *string `json:"kubelet-key,omitempty" yaml:"kubelet-key,omitempty"` | ||
} | ||
|
||
type WorkerNodeJoinConfig struct { | ||
KubeletCert *string `json:"kubelet-crt,omitempty" yaml:"kubelet-crt,omitempty"` | ||
KubeletKey *string `json:"kubelet-key,omitempty" yaml:"kubelet-key,omitempty"` | ||
} | ||
|
||
func (c *ControlPlaneNodeJoinConfig) GetAPIServerCert() string { return getField(c.APIServerCert) } | ||
func (c *ControlPlaneNodeJoinConfig) GetAPIServerKey() string { return getField(c.APIServerKey) } | ||
func (c *ControlPlaneNodeJoinConfig) GetKubeletCert() string { return getField(c.KubeletCert) } | ||
func (c *ControlPlaneNodeJoinConfig) GetKubeletKey() string { return getField(c.KubeletKey) } | ||
|
||
func (w *WorkerNodeJoinConfig) GetKubeletCert() string { return getField(w.KubeletCert) } | ||
func (w *WorkerNodeJoinConfig) GetKubeletKey() string { return getField(w.KubeletKey) } | ||
|
||
// ToMicrocluster converts a BootstrapConfig to a map[string]string for use in microcluster. | ||
func (j *ControlPlaneNodeJoinConfig) ToMicrocluster() (map[string]string, error) { | ||
return ToMicrocluster(j, "joinClusterConfig") | ||
} | ||
|
||
// ToMicrocluster converts a BootstrapConfig to a map[string]string for use in microcluster. | ||
func (w *WorkerNodeJoinConfig) ToMicrocluster() (map[string]string, error) { | ||
return ToMicrocluster(w, "joinClusterConfig") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters