Skip to content

Commit

Permalink
fix readme. fix typo. change URL to Hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
fffunke committed Aug 14, 2019
1 parent f6f39ce commit 36c491e
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM alpine:3.9
COPY mittnite /usr/bin/mittnite
EXPOSE 9102
ENTRYPOINT ["mittnite"]
CMD ["--config-dir", "/etc/mittnite.d"]
CMD ["up","--config-dir", "/etc/mittnite.d"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It offers the following features:
Start as follows:

```
$ mittnite --config-dir /etc/mittnite.d
$ mittnite up --config-dir /etc/mittnite.d
```

Or use it in a container image:
Expand All @@ -25,10 +25,10 @@ Or use it in a container image:
FROM quay.io/mittwald/mittnite:stable
COPY nginx.hcl /etc/mittnite.d/webserver.hcl
COPY fpm.hcl /etc/mittnite.d/fpm.hcl
CMD ["-.config-dir", "/etc/mittnite.d"]
CMD ["up", "--config-dir", "/etc/mittnite.d"]
```

The directory specified with `--config-dir` can contain any number of `.hcl` configuration files; all files in that directory are loaded by Mittnite on startup and can contain any of the configuration directives described in the following section:
The directory specified with `--config-dir` or the shorthand `-c` can contain any number of `.hcl` configuration files; all files in that directory are loaded by Mittnite on startup and can contain any of the configuration directives described in the following section:

## Configuration directives

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var rootCmd = &cobra.Command{
Short: "Mittnite - Smart init system for containers",
Long: "Mittnite is a small, but smart init system designed for usage as `ENTRYPOINT` in container images.",
Run: func(cmd *cobra.Command, args []string) {
log.Warn("Using mittnite without 'up'. This will change in future releases!")
up.Run(cmd, args)
},
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/onsi/gomega v1.5.0 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.3.2
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94
github.com/stretchr/testify v1.3.0 // indirect
github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65 // indirect
Expand Down
4 changes: 2 additions & 2 deletions pkg/probe/helper.go → internal/helper/helper.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package probe
package helper

import (
"os"
"strings"
)

func resolveEnv(in string) string {
func ResolveEnv(in string) string {
if strings.HasPrefix(in, "ENV:") {
return os.Getenv(in[4:])
}
Expand Down
4 changes: 2 additions & 2 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type Credentials struct {
}

type Host struct {
URL string
Port string
Hostname string
Port string
}

type MySQLConfig struct {
Expand Down
13 changes: 7 additions & 6 deletions pkg/probe/probe_amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package probe

import (
"fmt"
"github.com/mittwald/mittnite/internal/helper"
"github.com/mittwald/mittnite/internal/types"
log "github.com/sirupsen/logrus"
"github.com/streadway/amqp"
Expand All @@ -21,19 +22,19 @@ type amqpProbe struct {
}

func NewAmqpProbe(cfg *types.AmqpConfig) *amqpProbe {
cfg.User = resolveEnv(cfg.User)
cfg.Password = resolveEnv(cfg.Password)
cfg.URL = resolveEnv(cfg.URL)
cfg.Port = resolveEnv(cfg.Port)
cfg.VirtualHost = resolveEnv(cfg.VirtualHost)
cfg.User = helper.ResolveEnv(cfg.User)
cfg.Password = helper.ResolveEnv(cfg.Password)
cfg.Hostname = helper.ResolveEnv(cfg.Hostname)
cfg.Port = helper.ResolveEnv(cfg.Port)
cfg.VirtualHost = helper.ResolveEnv(cfg.VirtualHost)
if cfg.VirtualHost == "" {
cfg.VirtualHost = defaultVirtualHost
}

connCfg := amqpProbe{
user: cfg.User,
password: cfg.Password,
hostname: cfg.URL,
hostname: cfg.Hostname,
virtualHost: cfg.VirtualHost,
port: cfg.Port,
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/probe/probe_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package probe

import (
"fmt"
"github.com/mittwald/mittnite/internal/helper"
"github.com/mittwald/mittnite/internal/types"
log "github.com/sirupsen/logrus"
"net/http"
Expand All @@ -17,19 +18,19 @@ type httpGetProbe struct {
}

func NewHttpProbe(cfg *types.HttpGetConfig) *httpGetProbe {
cfg.Scheme = resolveEnv(cfg.Scheme)
cfg.URL = resolveEnv(cfg.URL)
cfg.Port = resolveEnv(cfg.Port)
cfg.Path = resolveEnv(cfg.Path)
cfg.Timeout = resolveEnv(cfg.Timeout)
cfg.Scheme = helper.ResolveEnv(cfg.Scheme)
cfg.Hostname = helper.ResolveEnv(cfg.Hostname)
cfg.Port = helper.ResolveEnv(cfg.Port)
cfg.Path = helper.ResolveEnv(cfg.Path)
cfg.Timeout = helper.ResolveEnv(cfg.Timeout)

if cfg.Scheme == "" {
cfg.Scheme = "http"
}

host := cfg.Host.URL
host := cfg.Host.Hostname
if cfg.Host.Port != "" {
host += fmt.Sprintf("%s:%s", cfg.URL, cfg.Port)
host += fmt.Sprintf("%s:%s", cfg.Hostname, cfg.Port)
}

connCfg := httpGetProbe{
Expand Down
11 changes: 6 additions & 5 deletions pkg/probe/probe_mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package probe
import (
"context"
"fmt"
"github.com/mittwald/mittnite/internal/helper"
"github.com/mittwald/mittnite/internal/types"
log "github.com/sirupsen/logrus"
"go.mongodb.org/mongo-driver/mongo"
Expand All @@ -21,15 +22,15 @@ type mongoDBProbe struct {
}

func NewMongoDBProbe(cfg *types.MongoDBConfig) *mongoDBProbe {
cfg.User = resolveEnv(cfg.User)
cfg.Password = resolveEnv(cfg.Password)
cfg.URL = resolveEnv(cfg.URL)
cfg.Database = resolveEnv(cfg.Database)
cfg.User = helper.ResolveEnv(cfg.User)
cfg.Password = helper.ResolveEnv(cfg.Password)
cfg.Hostname = helper.ResolveEnv(cfg.Hostname)
cfg.Database = helper.ResolveEnv(cfg.Database)

connCfg := mongoDBProbe{
user: cfg.User,
password: cfg.Password,
hostname: cfg.URL,
hostname: cfg.Hostname,
database: cfg.Database,
port: cfg.Port,
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/probe/probe_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"github.com/go-sql-driver/mysql"
"github.com/mittwald/mittnite/internal/helper"
"github.com/mittwald/mittnite/internal/types"
log "github.com/sirupsen/logrus"
)
Expand All @@ -13,11 +14,11 @@ type mySQLProbe struct {
}

func NewMySQLProbe(cfg *types.MySQLConfig) *mySQLProbe {
cfg.User = resolveEnv(cfg.User)
cfg.Database = resolveEnv(cfg.Database)
cfg.Password = resolveEnv(cfg.Password)
cfg.URL = resolveEnv(cfg.URL)
cfg.Port = resolveEnv(cfg.Port)
cfg.User = helper.ResolveEnv(cfg.User)
cfg.Database = helper.ResolveEnv(cfg.Database)
cfg.Password = helper.ResolveEnv(cfg.Password)
cfg.Hostname = helper.ResolveEnv(cfg.Hostname)
cfg.Port = helper.ResolveEnv(cfg.Port)

connCfg := mysql.Config{
User: cfg.User,
Expand Down
9 changes: 5 additions & 4 deletions pkg/probe/probe_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package probe
import (
"fmt"
"github.com/go-redis/redis"
"github.com/mittwald/mittnite/internal/helper"
"github.com/mittwald/mittnite/internal/types"
log "github.com/sirupsen/logrus"
)
Expand All @@ -13,12 +14,12 @@ type redisProbe struct {
}

func NewRedisProbe(cfg *types.RedisConfig) *redisProbe {
cfg.URL = resolveEnv(cfg.URL)
cfg.Password = resolveEnv(cfg.Password)
cfg.Port = resolveEnv(cfg.Port)
cfg.Hostname = helper.ResolveEnv(cfg.Hostname)
cfg.Password = helper.ResolveEnv(cfg.Password)
cfg.Port = helper.ResolveEnv(cfg.Port)

return &redisProbe{
addr: fmt.Sprintf("%s:%s", cfg.URL, cfg.Port),
addr: fmt.Sprintf("%s:%s", cfg.Hostname, cfg.Port),
password: cfg.Password,
}
}
Expand Down

0 comments on commit 36c491e

Please sign in to comment.