Refactored Docker and Make files; increased command context timeouts;

add dockerignore
This commit is contained in:
Mitchell 2019-05-29 23:32:56 -07:00
parent db246df3d6
commit b76d5dffa3
7 changed files with 34 additions and 15 deletions

View file

@ -91,7 +91,7 @@ password.`,
check(survey.AskOne(prompt, &cpass, nil))
if ci.Password != cpass {
fmt.Println("passwords didn't match'")
fmt.Println("passwords didn't match")
os.Exit(1)
}
}
@ -127,7 +127,7 @@ password.`,
}
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
c, err := initClient(ctx).Create(ctx, ci)

View file

@ -21,7 +21,7 @@ func MakeDelete(initConfig CredentialClientInit) *cobra.Command {
check(survey.AskOne(prompt, &confirmed, nil))
if confirmed {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
check(initConfig(ctx).Delete(ctx, args[0]))

View file

@ -25,7 +25,7 @@ decrypting password.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
cred, err := initClient(ctx).Get(ctx, args[0])

View file

@ -3,9 +3,11 @@ package commands
import (
"context"
"fmt"
"time"
"os"
"os/exec"
"github.com/spf13/cobra"
"gopkg.in/AlecAivazis/survey.v1"
)
func MakeList(initClient CredentialClientInit) *cobra.Command {
@ -18,13 +20,14 @@ func MakeList(initClient CredentialClientInit) *cobra.Command {
includes almost all the information but the most sensitive.`,
Run: func(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
defer cancel()
ctx := context.Background()
mdch, errch := initClient(ctx).GetAllMetadata(ctx, sourceHost)
fmt.Println()
receive:
for {
for count := 0; ; count++ {
select {
case <-ctx.Done():
check(fmt.Errorf("context timeout"))
@ -37,6 +40,20 @@ includes almost all the information but the most sensitive.`,
break receive
}
if count != 0 && count%3 == 0 {
var proceed bool
prompt := &survey.Confirm{Message: "Next page?", Default: true}
check(survey.AskOne(prompt, &proceed, nil))
if !proceed {
break receive
}
clearCmd := exec.Command("clear")
clearCmd.Stdout = os.Stdout
check(clearCmd.Run())
}
fmt.Println(md)
}
}