mirror of https://github.com/mitchell/selfpass.git
Refactored Docker and Make files; increased command context timeouts;
add dockerignore
This commit is contained in:
parent
db246df3d6
commit
b76d5dffa3
|
@ -0,0 +1 @@
|
|||
certs
|
|
@ -1,12 +1,13 @@
|
|||
FROM golang:1.11.5 as build
|
||||
WORKDIR /go/src/github.com/mitchell/selfpass
|
||||
COPY . .
|
||||
ENV GO111MODULE=on
|
||||
RUN make gen-certs-go
|
||||
ENV GO111MODULE on
|
||||
RUN make build
|
||||
|
||||
FROM debian:stable-20190506-slim
|
||||
WORKDIR /usr/bin
|
||||
COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server .
|
||||
COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server /usr/bin/server
|
||||
RUN groupadd -r selfpass && useradd --no-log-init -r -g selfpass selfpass
|
||||
USER selfpass
|
||||
WORKDIR /home/selfpass
|
||||
ENTRYPOINT ["server"]
|
||||
EXPOSE 8080
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,15 +1,15 @@
|
|||
.PHONY: all build clean format test
|
||||
.PHONY: all build clean format test gen-certs-go
|
||||
|
||||
build: clean format
|
||||
env CGO_ENABLED=0 go build -o ./bin/server ./cmd/server
|
||||
rm ./cmd/server/certs.go
|
||||
|
||||
clean:
|
||||
rm -rf ./bin
|
||||
go mod tidy
|
||||
|
||||
docker:
|
||||
docker: gen-certs-go
|
||||
docker-compose build
|
||||
rm ./cmd/server/certs.go
|
||||
|
||||
local:
|
||||
docker-compose up -d
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue