Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add restore command #190

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ common:
client_id: <CLIENT_ID>
client_secret: <CLIENT_SECRET>
api_key: <API_KEY> //if not using github authentication
monitoring: true
```
**To run spinup**

Expand Down
12 changes: 7 additions & 5 deletions api/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (

// createBackupRequest holds the parameters needed to create a backup
type createBackupRequest struct {
ClusterID string `json:"cluster_id"`
Name string `json:"name"`
ApiKeyID string `json:"api_key_id"`
ApiKeySecret string `json:"api_key_secret"`
BucketName string `json:"bucket_name"`
ClusterID string `json:"cluster_id"`
Name string `json:"name"`
ApiKeyID string `json:"api_key_id"`
ApiKeySecret string `json:"api_key_secret"`
BucketName string `json:"bucket_name"`
Schedule map[string]interface{} `json:"schedule"`
}

type BackupHandler struct {
Expand Down Expand Up @@ -78,6 +79,7 @@ func (b BackupHandler) CreateBackup(w http.ResponseWriter, r *http.Request) {
}

backupCfg := metastore.BackupConfig{
Schedule: s.Schedule,
Dest: metastore.Destination{
Name: s.Name,
BucketName: s.BucketName,
Expand Down
1 change: 1 addition & 0 deletions api/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type clusterService interface {

type backupService interface {
CreateBackup(ctx context.Context, clusterID string, backupConfig metastore.BackupConfig) error
Restore(ctx context.Context, networkName, clusterID, backupName string) error
}
3 changes: 0 additions & 3 deletions api/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
func stringToJWT(key *rsa.PrivateKey, text string) (string, error) {
// Declare the expiration time of the token
// here, we have kept it as 2 days
log.Println("string to JWT:", text)
expirationTime := time.Now().Add(48 * time.Hour)
// Create the JWT claims, which includes the text and expiry time
claims := &Claims{
Expand Down Expand Up @@ -98,14 +97,12 @@ func JWTToString(publicKey *rsa.PublicKey, tokenString string) (string, error) {
return publicKey, nil
}
claims := &Claims{}
log.Println("JWT to string:", tokenString)
token, err := jwt.ParseWithClaims(tokenString, claims, keyFunc)
if err != nil {
return "", err
}
if !token.Valid {
return "", errors.New("invalid token")
}
log.Println("claims:", claims.Text)
return claims.Text, nil
}
1 change: 0 additions & 1 deletion api/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (g GithubAuthHandler) GithubAuth(w http.ResponseWriter, r *http.Request) {
type userAuth struct {
Code string `json:"code"`
}
log.Println("req::", r.Body)
var ua userAuth
// TODO: format this to include best practices https://www.alexedwards.net/blog/how-to-properly-parse-a-json-request-body
err := json.NewDecoder(r.Body).Decode(&ua)
Expand Down
3 changes: 2 additions & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ common:
projectDir: <PROJECT_DIR>
client_id: <CLIENT_ID> #optional
client_secret: <CLIENT_SECRET> #optional
api_key: <API_KEY> #if not using github authentication
api_key: <API_KEY> #if not using github authentication
monitoring: true
20 changes: 5 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,25 @@ module github.com/spinup-host/spinup
go 1.16

require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/containerd/containerd v1.7.0 // indirect
github.com/docker/docker v23.0.1+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/go-chi/chi/v5 v5.0.8
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc1 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/robfig/cron/v3 v3.0.1
github.com/rs/cors v1.8.2
github.com/spf13/cobra v1.2.1
github.com/spf13/cobra v1.6.0
github.com/stretchr/testify v1.8.2
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.24.0
golang.org/x/net v0.0.0-20220921203646-d300de134e69 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.0.3 // indirect
modernc.org/sqlite v1.21.0
)
Loading