Skip to content

Commit

Permalink
remove hardcoded defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Sep 21, 2024
1 parent b4fd021 commit 42b0b41
Show file tree
Hide file tree
Showing 21 changed files with 3,612 additions and 88 deletions.
40 changes: 16 additions & 24 deletions cmd/service-discovery/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands

import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
Expand All @@ -12,13 +13,13 @@ import (
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
"github.com/skycoin/skywire"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
"github.com/skycoin/skywire-utilities/pkg/httpauth"
"github.com/skycoin/skywire-utilities/pkg/logging"
"github.com/skycoin/skywire-utilities/pkg/metricsutil"
"github.com/skycoin/skywire"
"github.com/skycoin/skywire-utilities/pkg/storeconfig"
"github.com/skycoin/skywire-utilities/pkg/tcpproxy"
"github.com/spf13/cobra"
Expand All @@ -35,26 +36,24 @@ var log = logging.MustGetLogger("service-discovery")
const redisPrefix = "service-discovery"

var (
addr string
metricsAddr string
redisURL string
pgHost string
pgPort string
testMode bool
apiKey string
dmsgDisc string
whitelistKeys string
testEnvironment bool
sk cipher.SecKey
dmsgPort uint16
dmsgServerType string
addr string
metricsAddr string
redisURL string
pgHost string
pgPort string
testMode bool
apiKey string
dmsgDisc string
whitelistKeys string
sk cipher.SecKey
dmsgPort uint16
dmsgServerType string
)

func init() {
var envServices skywire.EnvServices
var services skywire.Services
var sdURL string
if err := json.Unmarshal([]byte(jsonData), &envServices); err == nil {
if err := json.Unmarshal([]byte(skywire.ServicesJSON), &envServices); err == nil {
if err := json.Unmarshal(envServices.Prod, &services); err == nil {
dmsgDisc = services.DmsgDiscovery
}
Expand All @@ -69,7 +68,6 @@ func init() {
RootCmd.Flags().StringVarP(&apiKey, "api-key", "g", "", "geo API key")
RootCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "d", dmsgDisc, "url of dmsg-discovery")
RootCmd.Flags().StringVar(&dmsgServerType, "dmsg-server-type", "", "type of dmsg server on dmsghttp handler")
RootCmd.Flags().BoolVarP(&testEnvironment, "test-environment", "n", false, "distinguished between prod and test environment")
RootCmd.Flags().VarP(&sk, "sk", "s", "dmsg secret key\n")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value")
}
Expand All @@ -90,7 +88,7 @@ keys-gen | tee sd-config.json
PG_USER="postgres" PG_DATABASE="sd" PG_PASSWORD="" service-discovery --sk $(tail -n1 sd-config.json)`,
Run: func(_ *cobra.Command, _ []string) {
if dmsgDisc == "" {
dmsgDisc = skyenv.DmsgDiscAddr
dmsgDisc = dmsg.DmsgDiscAddr(false)
}
if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil {
log.Printf("Failed to output build info: %v", err)
Expand Down Expand Up @@ -159,12 +157,6 @@ PG_USER="postgres" PG_DATABASE="sd" PG_PASSWORD="" service-discovery --sk $(tail
var whitelistPKs []string
if whitelistKeys != "" {
whitelistPKs = strings.Split(whitelistKeys, ",")
} else {
if testEnvironment {
whitelistPKs = strings.Split(skyenv.TestNetworkMonitorPKs, ",")
} else {
whitelistPKs = strings.Split(skyenv.NetworkMonitorPKs, ",")
}
}
for _, v := range whitelistPKs {
api.WhitelistPKs.Set(v)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ require (
)

// Uncomment it for tests with alternative branches and run `make dep`
// replace github.com/skycoin/dmsg => ../dmsg
replace github.com/skycoin/dmsg => ../dmsg

replace github.com/skycoin/skywire => ../skywire

//replace github.com/skycoin/dmsg => github.com/skycoin/dmsg

// replace github.com/skycoin/skywire => ../skywire
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,10 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skycoin/dmsg v1.3.25 h1:Gs4aRhLq/ZCo5I0vN3nTv/N5/MC6sunWCuS50Tct6qI=
github.com/skycoin/dmsg v1.3.25/go.mod h1:3pyc9MmDJQYP0spTAWKLMctz4+ZKjMZgXtdMmXpYolw=
github.com/skycoin/dmsg v1.3.26-0.20240910062314-dc25f3d9ea6c h1:7miiImujaW74EAD/cqs6tAXzoVRK7K9yk69R8oqKC/g=
github.com/skycoin/dmsg v1.3.26-0.20240910062314-dc25f3d9ea6c/go.mod h1:3pyc9MmDJQYP0spTAWKLMctz4+ZKjMZgXtdMmXpYolw=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o=
github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I=
github.com/skycoin/skycoin v0.27.1/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw=
github.com/skycoin/skywire v1.3.25-beta h1:F3oDF36CaK3YAFogl2/jNkAqJWHaJP4HVBVFRpP72BU=
github.com/skycoin/skywire v1.3.25-beta/go.mod h1:TAUZX3dAcvsJhblLMuwZ1MjmIJL85He73MZdKT95Qv4=
github.com/skycoin/skywire-utilities v1.3.25 h1:mk8dUonFdhVopFF3d9wbOyXXoiuAO+mN1y+ve6SzgX4=
github.com/skycoin/skywire-utilities v1.3.25/go.mod h1:yFKWpL1bDRPKU3uK+cTF4PnYUMe+eyIj5N2bk4sF5Cw=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
Expand Down
23 changes: 20 additions & 3 deletions vendor/github.com/skycoin/dmsg/pkg/dmsg/const.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 0 additions & 51 deletions vendor/github.com/skycoin/skywire-utilities/pkg/skyenv/values.go

This file was deleted.

5 changes: 5 additions & 0 deletions vendor/github.com/skycoin/skywire/.dockerignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions vendor/github.com/skycoin/skywire/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 42b0b41

Please sign in to comment.