Skip to content

Commit 8ccad1d

Browse files
authored
Merge pull request #34 from getsumio/develop
Develop
2 parents 2e9c12e + 214677f commit 8ccad1d

File tree

8 files changed

+28
-18
lines changed

8 files changed

+28
-18
lines changed

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:buster-slim
2+
WORKDIR /app
3+
RUN apt update
4+
RUN apt install -y ca-certificates
5+
RUN apt install openssl
6+
RUN update-ca-certificates --fresh
7+
ARG listen=0.0.0.0
8+
ARG port=8088
9+
ENV listen=$listen
10+
ENV port=$port
11+
COPY builds/linux/amd64/getsum ./
12+
CMD /app/getsum -s -l $listen -p $port -dir /tmp
13+
EXPOSE $port

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v2.0

cmd/getsum/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131

3232
//if user defined set log level
3333
logger.SetLevel(*config.LogLevel)
34-
logger.Debug("Application started, using config %v", parser.ConfigJson)
34+
logger.Debug("Application started, using config %v", string(parser.ConfigJson))
3535

3636
//check if user wants to run in listen mode
3737
if *config.Serve {

docker-build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
VERSION=$(cat VERSION)
3+
docker build -t getsum:$VERSION .

generateReleases.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
VERSION=$(cat VERSION)
23
for GOOS in darwin linux windows openbsd freebsd ; do
34
for GOARCH in 386 amd64; do
45
GO_BIN_PATH="builds/$GOOS/$GOARCH"
@@ -8,7 +9,7 @@ for GOOS in darwin linux windows openbsd freebsd ; do
89
EXTENSION=".exe"
910
fi
1011
time GOOS=$GOOS GOARCH=$GOARCH go build -a -v -o ./$GO_BIN_PATH/getsum$EXTENSION ./cmd/getsum/main.go
11-
TAR_FILE=$(pwd)/$GO_BIN_PATH/getsum-$GOOS-$GOARCH.tar.gz
12+
TAR_FILE=$(pwd)/$GO_BIN_PATH/getsum-$GOOS-$GOARCH-$VERSION.tar.gz
1213
tar -czvf $TAR_FILE $GO_BIN_PATH
1314
done
1415
done

internal/config/parser.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
)
2828

2929
var defaultConfig string = ".getsum" + string(os.PathSeparator) + "servers.yml"
30-
var ConfigJson string
30+
var ConfigJson []byte
3131

3232
//checks first if user specified a config file via params
3333
//if not then checks $HOME/.getsum/servers.yml file if exist
@@ -135,11 +135,10 @@ func ParseConfig() (*Config, error) {
135135

136136
}
137137

138-
configBytes, err := json.Marshal(*c)
138+
ConfigJson, err = json.Marshal(*c)
139139
if err != nil {
140140
return nil, err
141141
}
142-
ConfigJson = string(configBytes)
143142

144143
return c, nil
145144
}

internal/provider/onpremiseprovider.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,9 @@ func setErrorStatus(err error, r *RemoteProvider) {
4545
func remoteRun(l *RemoteProvider) {
4646

4747
l.status = &status.Status{}
48-
//parse config to json
49-
body, err := json.Marshal(*l.config)
50-
if err != nil {
51-
setErrorStatus(err, l)
52-
l.hasRunError = true
53-
return
54-
}
5548

5649
//send config to server, this only POST request so no need other param
57-
resp, err := l.client.Post(l.address, "application/json", bytes.NewBuffer(body))
50+
resp, err := l.client.Post(l.address, "application/json", bytes.NewBuffer(config.ConfigJson))
5851
defer closeResponse(resp)
5952
if err != nil {
6053
//set error as provider status

internal/validation/validator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func ValidateConfig(config *Config, onPremise bool) error {
1515
if *config.File == "" && !*config.Serve {
1616
return errors.New("No file path/url provided, example usage: getsum /tmp/file ")
1717
}
18-
if *config.RemoteOnly {
18+
if !onPremise && *config.RemoteOnly {
1919
if *config.LocalOnly {
2020
return errors.New("You can not set -localOnly and -remoteOnly at the same time")
2121
}
@@ -40,7 +40,7 @@ func ValidateConfig(config *Config, onPremise bool) error {
4040
return errors.New("Unrecognized algorithm, [" + a + "] supported types: " + supportedAlgs)
4141
}
4242
}
43-
if *config.Dir != "" {
43+
if !onPremise && *config.Dir != "" {
4444
fi, err := os.Stat(*config.Dir)
4545
if os.IsNotExist(err) {
4646
return errors.New("Given -dir parameter " + *config.Dir + "doesnt exist")
@@ -49,14 +49,14 @@ func ValidateConfig(config *Config, onPremise bool) error {
4949
return errors.New("Given -dir parameter is not a directory!")
5050
}
5151
}
52-
if *config.TLSKey != "" && *config.TLSCert == "" {
52+
if !onPremise && *config.TLSKey != "" && *config.TLSCert == "" {
5353
return errors.New("You specified -tlskey but not -tlscert, both parameter required for https/tls mode")
5454
}
55-
if *config.TLSKey == "" && *config.TLSCert != "" {
55+
if !onPremise && *config.TLSKey == "" && *config.TLSCert != "" {
5656
return errors.New("You specified -tlscert but not -tlskey, both parameter required for https/tls mode")
5757
}
5858

59-
if *config.Key != "" && *config.Supplier != "go" {
59+
if !onPremise && *config.Key != "" && *config.Supplier != "go" {
6060
return errors.New("-key parameter only used on go libs currently, set -lib go")
6161
}
6262

0 commit comments

Comments
 (0)