cli: remove ambiguity in path for CR backups (#1719)

During upgrade all custom resources are backed up to files on the
local file system. Since old versions are also backed up, we need to
reflect the version in the name.
This commit is contained in:
Otto Bittner 2023-05-03 14:36:57 +02:00 committed by GitHub
parent d2cbf3dc83
commit d5fa614df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -63,7 +63,7 @@ func (c *Client) backupCRs(ctx context.Context, crds []apiextensionsv1.CustomRes
}
for _, cr := range crs {
targetFolder := filepath.Join(backupFolder, cr.GetKind(), cr.GetNamespace())
targetFolder := filepath.Join(backupFolder, gvr.Group, gvr.Version, cr.GetNamespace(), cr.GetKind())
if err := c.fs.MkdirAll(targetFolder); err != nil {
return fmt.Errorf("creating resource dir: %w", err)
}

View File

@ -133,7 +133,7 @@ func TestBackupCRs(t *testing.T) {
}
assert.NoError(err)
data, err := afero.ReadFile(memFs, filepath.Join(backupFolder, tc.resource.GetKind(), tc.resource.GetNamespace(), tc.resource.GetName()+".yaml"))
data, err := afero.ReadFile(memFs, filepath.Join(backupFolder, tc.crd.Spec.Group, tc.crd.Spec.Versions[0].Name, tc.resource.GetNamespace(), tc.resource.GetKind(), tc.resource.GetName()+".yaml"))
require.NoError(err)
assert.YAMLEq(tc.expectedFile, string(data))
})