Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
159 changes: 122 additions & 37 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Available Commands:
details Show details for a deployment
help Help about any command
list List deployments attached to account
logfiles Commands for logfiles
recipe Show details of a recipe
recipes Show Recipes related to deployment
scale Show scale information for a deployment
Expand Down Expand Up @@ -68,6 +69,10 @@ bach backups [command]
restore Restore a deployment
start Start backups for a deployment

bach logfiles [command]
get Show Logfile details for deployment
list Show Logfiles for deployment

bach user [command]
add Add user
del Delete user
Expand Down
17 changes: 17 additions & 0 deletions cmd/backupget.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ package cmd
import (
"fmt"
"log"
"net/url"
"path/filepath"

"github.com/spf13/cobra"
)

var downloadBackupNow bool

// backupgetCmd represents the backups get command
var backupgetCmd = &cobra.Command{
Use: "get [deployment id] [backup id/name]",
Expand Down Expand Up @@ -51,6 +55,18 @@ var backupgetCmd = &cobra.Command{
fmt.Printf("%15s: %s\n", "Type", backup.Type)
fmt.Printf("%15s: %s\n", "Status", backup.Status)
fmt.Printf("%15s: %s\n", "Download Link", backup.DownloadLink)

if downloadBackupNow && backup.IsDownloadable {
u, err := url.Parse(backup.DownloadLink)
err = DownloadFile(filepath.Base(u.Path), backup.DownloadLink)
if err != nil {
fmt.Printf("Error downloading: %s\n", err)
} else {
fmt.Printf("Downloaded: %s\n", backup.Name)
}
} else if downloadBackupNow && !backup.IsDownloadable {
fmt.Println("Backup is not downloadable - Download skipped")
}
} else {
printAsJSON(backup)
}
Expand All @@ -60,4 +76,5 @@ var backupgetCmd = &cobra.Command{

func init() {
backupsCmd.AddCommand(backupgetCmd)
backupgetCmd.Flags().BoolVarP(&downloadBackupNow, "download", "d", false, "Download the selected backup")
}
75 changes: 75 additions & 0 deletions cmd/logfileget.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright © 2017 Compose, an IBM Company
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"
"log"

"github.com/spf13/cobra"
)

var downloadLogfileNow bool

// logfilegetCmd represents the logfiles get command
var logfilegetCmd = &cobra.Command{
Use: "get [deployment id] logfile id/name]",
Short: "Show Logfile details for deployment",
Long: `Show the Logfile details for a deployment's Logfile`,
Run: func(cmd *cobra.Command, args []string) {
c := getComposeAPI()
if len(args) != 2 {
log.Fatal("Need a deployment id/name and a logfile id")
}
depid, err := resolveDepID(c, args[0])
if err != nil {
log.Fatal(err)
}
logfileid := args[1]
if outputRaw {
text, errs := c.GetLogfileDetailsForDeploymentJSON(depid, logfileid)
bailOnErrs(errs)
fmt.Println(text)
} else {
logfile, errs := c.GetLogfileDetailsForDeployment(depid, logfileid)
bailOnErrs(errs)

if !outputJSON {
fmt.Printf("%15s: %s\n", "Logfile ID", logfile.ID)
fmt.Printf("%15s: %s\n", "Deployment ID", logfile.Deploymentid)
fmt.Printf("%15s: %s\n", "Capsule ID", logfile.Capsuleid)
fmt.Printf("%15s: %s\n", "Logfile Name", logfile.Name)
fmt.Printf("%15s: %s\n", "Status", logfile.Status)
fmt.Printf("%15s: %s\n", "Download Link", logfile.DownloadLink)

if downloadLogfileNow {
err := DownloadFile(logfile.Name, logfile.DownloadLink)
if err != nil {
fmt.Printf("Error downloading: %s\n", err)
} else {
fmt.Printf("Downloaded: %s\n", logfile.Name)
}
}
} else {
printAsJSON(logfile)
}
}
},
}

func init() {
logfilesCmd.AddCommand(logfilegetCmd)
logfilegetCmd.Flags().BoolVarP(&downloadLogfileNow, "download", "d", false, "Download the selected logfile")
}
Loading