commit
e045366e82
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ all: dagger
|
|||||||
|
|
||||||
.PHONY: dagger
|
.PHONY: dagger
|
||||||
dagger:
|
dagger:
|
||||||
go build -o ./cmd/dagger/ ./cmd/dagger/
|
CGO_ENABLED=0 go build -o ./cmd/dagger/ -ldflags '-s -w' ./cmd/dagger/
|
||||||
|
|
||||||
.PHONY: dagger-debug
|
.PHONY: dagger-debug
|
||||||
dagger-debug:
|
dagger-debug:
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
goVersion "github.com/hashicorp/go-version"
|
goVersion "github.com/hashicorp/go-version"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
@ -20,7 +21,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
defaultVersion = "devel"
|
defaultVersion = "devel"
|
||||||
versionFile = "$HOME/.dagger/version-check"
|
versionFile = "~/.dagger/version-check"
|
||||||
versionURL = "https://releases.dagger.io/dagger/latest_version"
|
versionURL = "https://releases.dagger.io/dagger/latest_version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +50,12 @@ var versionCmd = &cobra.Command{
|
|||||||
)
|
)
|
||||||
|
|
||||||
if check := viper.GetBool("check"); check {
|
if check := viper.GetBool("check"); check {
|
||||||
_ = os.Remove(os.ExpandEnv(versionFile))
|
versionFilePath, err := homedir.Expand(versionFile)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = os.Remove(versionFilePath)
|
||||||
checkVersion()
|
checkVersion()
|
||||||
if !warnVersion() {
|
if !warnVersion() {
|
||||||
fmt.Println("dagger is up to date.")
|
fmt.Println("dagger is up to date.")
|
||||||
@ -155,7 +161,10 @@ func checkVersion() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
versionFilePath := os.ExpandEnv(versionFile)
|
versionFilePath, err := homedir.Expand(versionFile)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
baseDir := path.Dir(versionFilePath)
|
baseDir := path.Dir(versionFilePath)
|
||||||
|
|
||||||
if _, err := os.Stat(baseDir); os.IsNotExist(err) {
|
if _, err := os.Stat(baseDir); os.IsNotExist(err) {
|
||||||
|
1
go.mod
1
go.mod
@ -14,6 +14,7 @@ require (
|
|||||||
github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea
|
github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea
|
||||||
github.com/mattn/go-colorable v0.1.8 // indirect
|
github.com/mattn/go-colorable v0.1.8 // indirect
|
||||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
|
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/moby/buildkit v0.8.3
|
github.com/moby/buildkit v0.8.3
|
||||||
github.com/morikuni/aec v1.0.0
|
github.com/morikuni/aec v1.0.0
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
|
@ -5,22 +5,22 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"filippo.io/age"
|
"filippo.io/age"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Path() (string, error) {
|
func Path() (string, error) {
|
||||||
usr, err := user.Current()
|
h, err := homedir.Dir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.Join(usr.HomeDir, ".dagger", "keys.txt"), nil
|
return path.Join(h, ".dagger", "keys.txt"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Default(ctx context.Context) (string, error) {
|
func Default(ctx context.Context) (string, error) {
|
||||||
|
Reference in New Issue
Block a user