35 lines
677 B
Go
35 lines
677 B
Go
package main
|
|
|
|
import (
|
|
"backup-tool/s3helper"
|
|
"context"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func main() {
|
|
|
|
accessKeyID, secretAccessKey := getCredentials()
|
|
s3helper.UploadFile(context.Background(), accessKeyID, secretAccessKey)
|
|
|
|
}
|
|
|
|
func getCredentials() (string, string) {
|
|
// get credentials from env vars
|
|
err := godotenv.Load()
|
|
if err != nil {
|
|
log.Fatalf("error loading .env file: (%s)", err.Error())
|
|
}
|
|
keyName := os.Getenv("KEY_ID")
|
|
if keyName == "" {
|
|
log.Fatal("missing or empty KEY_ID")
|
|
}
|
|
applicationKey := os.Getenv("APPLICATION_KEY")
|
|
if applicationKey == "" {
|
|
log.Fatal("missing or empty APPLICATION_KEY")
|
|
}
|
|
return keyName, applicationKey
|
|
}
|