Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hardcoded deployment defaults #78

Merged
merged 11 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
- name: Setup golang
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.23.x
- name: Check out code
uses: actions/checkout@v3
- name: Install Requirements
run: |
GO111MODULES=off; go mod vendor
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
- name: Setup SSH Key Build and run e2e
run : |
make e2e-build
Expand Down
17 changes: 7 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 1
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 10m
deadline: 3m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down Expand Up @@ -45,7 +45,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -66,8 +66,7 @@ linters-settings:
check-blank: true
govet:
# report about shadowed variables
check-shadowing: true

shadow: true
# Obtain type information from installed (to $GOPATH/pkg) package files:
# golangci-lint will execute `go install -i` and `go test -i` for analyzed packages
# before analyzing them.
Expand All @@ -81,7 +80,7 @@ linters-settings:
# 2. you use go >= 1.10
# 3. you do repeated runs (false for CI) or cache $GOPATH/pkg or `go env GOCACHE` dir in CI.
use-installed-packages: false
revive:
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gofmt:
Expand Down Expand Up @@ -145,26 +144,24 @@ linters-settings:
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default
goimports:
local-prefixes: github.com/skycoin/skywire-services


linters:
enable:
- revive
- goimports
- unused
- unparam
- errcheck
- gosimple
- staticcheck
- unused
- ineffassign
- typecheck
- gosec
- megacheck
- misspell
- nakedret
enable-all: false
disable:
disable-all: true
presets:
fast: false
Expand Down
60 changes: 59 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,65 @@ test: ## Run tests for net
go test ${TEST_OPTS} -mod=vendor ./internal/...
go test ${TEST_OPTS} -mod=vendor ./pkg/...

check: lint test lint-shell ## Run lint and test
check: lint check-help test lint-shell ## Run lint and test

check-help: ## Cursory check of the help menus
@echo "checking help menus for compilation without errors"
@echo
go run cmd/skywire-services/services.go --help
@echo
go run cmd/skywire-services/services.go ar --help
@echo
go run cmd/skywire-services/services.go confbs --help
@echo
go run cmd/skywire-services/services.go kg --help
@echo
go run cmd/skywire-services/services.go nv --help
@echo
go run cmd/skywire-services/services.go rf --help
@echo
go run cmd/skywire-services/services.go se --help
@echo
go run cmd/skywire-services/services.go tpd --help
@echo
go run cmd/skywire-services/services.go tps --help
@echo
go run cmd/skywire-services/services.go ut --help
@echo
go run cmd/config-bootstrapper/config.go --help
@echo
go run cmd/tpd-monitor/tpd-monitor.go --help
@echo
go run cmd/transport-discovery/transport-discovery.go --help
@echo
go run cmd/keys-gen/keys-gen.go --help
@echo
go run cmd/skysocks-monitor/skysocks-monitor.go --help
@echo
go run cmd/sw-env/sw-env.go --help
@echo
go run cmd/uptime-tracker/uptime-tracker.go --help
@echo
go run cmd/route-finder/route-finder.go --help
@echo
go run cmd/setup-node/setup-node.go --help
@echo
go run cmd/transport-setup/transport-setup.go --help
@echo
go run cmd/public-visor-monitor/public-visor-monitor.go --help
@echo
go run cmd/node-visualizer/node-visualizer.go --help
@echo
# go run cmd/skysocks-lite-client/skysocks-lite-client.go --help
# @echo
go run cmd/vpn-monitor/vpn-monitor.go --help
@echo
go run cmd/address-resolver/address-resolver.go --help
@echo
# go run cmd/vpn-lite-client/vpn-lite-client.go --help
# @echo
go run cmd/network-monitor/network-monitor.go --help
@echo

## : ## _ [E2E tests suite]

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ Check the [docs](docs/Deployments.md) for more documentation on the deployments.
- [Dmsg Server](https://github.com/skycoin/dmsg/blob/develop/cmd/dmsg-server/README.md)
- [Service Discovery](https://github.com/skycoin/skycoin-service-discovery/blob/master/README.md#http-api)
- [Uptime Tracker](cmd/uptime-tracker/README.md)

## Dependency Graph

made with [goda](https://github.com/loov/goda)

```
goda graph github.com/skycoin/skywire-services/... | dot -Tsvg -o docs/skywire-services-goda-graph.svg
```

![Dependency Graph](docs/skywire-services-goda-graph.svg "github.com/skycoin/skywire-services Dependency Graph")
50 changes: 6 additions & 44 deletions cmd/address-resolver/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"
"time"

cc "github.com/ivanpirog/coloredcobra"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand All @@ -20,7 +19,6 @@ import (
"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-utilities/pkg/skyenv"
"github.com/skycoin/skywire-utilities/pkg/storeconfig"
"github.com/skycoin/skywire-utilities/pkg/tcpproxy"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -57,20 +55,15 @@ func init() {
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
RootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "[info|error|warn|debug|trace|panic]\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", dmsg.DiscAddr(false), "url of dmsg discovery\033[0m")
RootCmd.Flags().StringVar(&whitelistKeys, "whitelist-keys", "", "list of whitelisted keys of network monitor used for deregistration\033[0m")
RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
RootCmd.Flags().StringVar(&dmsgServerType, "dmsg-server-type", "", "type of dmsg server on dmsghttp handler")
var helpflag bool
RootCmd.SetUsageTemplate(help)
RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for address-resolver")
RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
RootCmd.PersistentFlags().MarkHidden("help") //nolint
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\033[0m\n\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\033[0m")
RootCmd.Flags().StringVar(&dmsgServerType, "dmsg-server-type", "", "type of dmsg server on dmsghttp handler\033[0m")
}

// RootCmd contains the root command
Expand Down Expand Up @@ -133,14 +126,7 @@ skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 a
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 Expand Up @@ -232,33 +218,9 @@ skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 a
},
}

// Execute executes root CLI command.
// Execute executes root CLI command
func Execute() {
cc.Init(&cc.Config{
RootCmd: RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
})
if err := RootCmd.Execute(); err != nil {
log.Fatal("Failed to execute command: ", err)

}
}

const help = "Usage:\r\n" +
" {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" +
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " +
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" +
"Flags:\r\n" +
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" +
"Global Flags:\r\n" +
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n"
8 changes: 4 additions & 4 deletions cmd/config-bootstrapper/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func init() {
RootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
RootCmd.Flags().StringVarP(&stunPath, "config", "c", "./config.json", "stun server list file location\033[0m")
RootCmd.Flags().StringVarP(&domain, "domain", "d", "skywire.skycoin.com", "the domain of the endpoints\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
RootCmd.Flags().StringVar(&dmsgServerType, "dmsg-server-type", "", "type of dmsg server on dmsghttp handler")
RootCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "D", dmsg.DiscAddr(false), "url of dmsg-discovery\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\033[0m\n\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\033[0m")
RootCmd.Flags().StringVar(&dmsgServerType, "dmsg-server-type", "", "type of dmsg server on dmsghttp handler\033[0m")
}

// RootCmd contains the root command
Expand Down
16 changes: 0 additions & 16 deletions cmd/dmsg-monitor/README.md

This file was deleted.

Loading
Loading