Skip to content

Commit 9878f94

Browse files
committed
Modified the root directory
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 63d0c39 commit 9878f94

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM alpine:3.7
22

3+
RUN apk add --no-cache ca-certificates
4+
35
COPY dist/linux_amd64/tunnel /usr/local/bin
46

57
ENTRYPOINT ["tunnel"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
IMAGE = labstack/tunnel
2-
VERSION = 0.2.8
2+
VERSION = 0.2.9
33

44
publish:
55
git tag $(VERSION)

cmd/root.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"net/http"
66
"os"
7+
"path/filepath"
78

89
"github.com/go-resty/resty"
910
"github.com/labstack/gommon/log"
@@ -100,7 +101,7 @@ func Execute() {
100101

101102
func init() {
102103
cobra.OnInitialize(initConfig)
103-
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file (default is $HOME/.tunnel.yaml)")
104+
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file (default is $HOME/tunnel/config.yaml)")
104105
rootCmd.PersistentFlags().StringVarP(&name, "name", "n", "", "config name from the dashboard")
105106
rootCmd.PersistentFlags().BoolVarP(&tcp, "tcp", "", false, "tcp tunnel")
106107
rootCmd.PersistentFlags().BoolVarP(&tls, "tls", "", false, "tls tunnel")
@@ -112,15 +113,22 @@ func initConfig() {
112113
// Use config file from the flag
113114
viper.SetConfigFile(configFile)
114115
} else {
115-
// Find home directory
116-
home, err := homedir.Dir()
116+
// Create directories
117+
dir, err := homedir.Dir()
117118
if err != nil {
118119
log.Fatalf("failed to find the home directory: %v", err)
119120
}
121+
root := filepath.Join(dir, ".tunnel")
122+
if err = os.MkdirAll(filepath.Join(root, "pid"), 0755); err != nil {
123+
log.Fatalf("failed to create pid directory: %v", err)
124+
}
125+
if err = os.MkdirAll(filepath.Join(root, "log"), 0755); err != nil {
126+
log.Fatalf("failed to create log directory: %v", err)
127+
}
120128

121-
// Search config in home directory with name ".tunnel" (without extension)
122-
viper.AddConfigPath(home)
123-
viper.SetConfigName(".tunnel")
129+
// Search config in home directory with name "config" (without extension)
130+
viper.AddConfigPath(root)
131+
viper.SetConfigName("config")
124132
}
125133
viper.AutomaticEnv() // Read in environment variables that match
126134
viper.ReadInConfig()

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var (
1212
Short: "Print the version of Tunnel",
1313
// Long: ``,
1414
Run: func(cmd *cobra.Command, args []string) {
15-
fmt.Println("0.2.8")
15+
fmt.Println("0.2.9")
1616
},
1717
}
1818
)

0 commit comments

Comments
 (0)