1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Able to include and extract state file in snapshot

This commit is contained in:
Sebastiaan van Steenis
2020-03-30 21:16:47 +02:00
parent e2b5828e5b
commit 9bca29befb
8 changed files with 161 additions and 10 deletions

View File

@@ -228,6 +228,19 @@ func GetCertificateDirPath(configPath, configDir string) string {
return trimmedName + certDirExt
}
func StringToFullState(ctx context.Context, stateFileContent string) (*FullState, error) {
rkeFullState := &FullState{}
logrus.Tracef("stateFileContent: %s", stateFileContent)
if err := json.Unmarshal([]byte(stateFileContent), rkeFullState); err != nil {
return rkeFullState, err
}
rkeFullState.DesiredState.CertificatesBundle = pki.TransformPEMToObject(rkeFullState.DesiredState.CertificatesBundle)
rkeFullState.CurrentState.CertificatesBundle = pki.TransformPEMToObject(rkeFullState.CurrentState.CertificatesBundle)
logrus.Tracef("rkeFullState: %+v", rkeFullState)
return rkeFullState, nil
}
func ReadStateFile(ctx context.Context, statePath string) (*FullState, error) {
rkeFullState := &FullState{}
fp, err := filepath.Abs(statePath)