Skip to content

Commit

Permalink
Merge pull request #831 from k8up-io/cli-snapshot-restore
Browse files Browse the repository at this point in the history
Cli snapshot restore
  • Loading branch information
Kidswiss authored Mar 30, 2023
2 parents dd4a676 + 0567b02 commit 8f203d7
Show file tree
Hide file tree
Showing 14 changed files with 603 additions and 33 deletions.
3 changes: 3 additions & 0 deletions api/v1/snapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type SnapshotStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Date taken",type="string",JSONPath=`.spec.date`,description="Date when snapshot was taken"
// +kubebuilder:printcolumn:name="Paths",type="string",JSONPath=`.spec.paths[*]`,description="Snapshot's paths"
// +kubebuilder:printcolumn:name="Repository",type="string",JSONPath=`.spec.repository`,description="Repository Url"

// Snapshot is the Schema for the snapshots API
type Snapshot struct {
Expand Down
16 changes: 16 additions & 0 deletions cli/restore/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package restore

import (
"math/rand"
"time"
)

func RandomStringGenerator(n int) string {
var characters = []rune("abcdefghijklmnopqrstuvwxyz1234567890")
rand.Seed(time.Now().UnixNano())
b := make([]rune, n)
for i := range b {
b[i] = characters[rand.Intn(len(characters))]
}
return string(b)
}
46 changes: 46 additions & 0 deletions cli/restore/restore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package restore

var (
Cfg = &RestoreConfig{}
)

type RestoreConfig struct {
// spec.restoreMethod.folder.claimName
ClaimName string
Kubeconfig string
Namespace string
// metadata.name
RestoreName string
// spec.podSecurityContext.runAsUser
RunAsUser int64
// one of restore methods s3 || pvc
RestoreMethod string
// spec.snapshot
Snapshot string
// spec.backend.repoPasswordSecretRef.name
SecretRef string
// spec.backend.repoPasswordSecretRef.key
SecretRefKey string

// spec.backend.s3.endpoint
S3Endpoint string
// spec.backend.s3.bucket
S3Bucket string
// spec.backend.s3.accessKeyIDSecretRef.name && spec.backend.s3.secretAccessKeySecretRef.name
S3SecretRef string
// spec.backend.s3.accessKeyIDSecretRef.key
S3SecretRefUsernameKey string
// spec.backend.s3.secretAccessKeySecretRef.key
S3SecretRefPasswordKey string

// spec.restoreMethod.s3.endpoint
RestoreToS3Endpoint string
// spec.restoreMethod.s3.bucket
RestoreToS3Bucket string
// spec.restoreMethod.s3.accessKeyIDSecretRef.name && spec.restoreMethod.s3.secretAccessKeySecretRef.name
RestoreToS3Secret string
// spec.restoreMethod.s3.accessKeyIDSecretRef.name
RestoreToS3SecretUsernameKey string
// spec.restoreMethod.s3.secretAccessKeySecretRef.name
RestoreToS3SecretPasswordKey string
}
Loading

0 comments on commit 8f203d7

Please sign in to comment.