Skip to content

Commit

Permalink
feat: agent register
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Mar 12, 2020
1 parent 1f3983d commit b2b0803
Show file tree
Hide file tree
Showing 19 changed files with 1,093 additions and 631 deletions.
1 change: 1 addition & 0 deletions api/errcode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ enum ErrCode {
ErrCouponExpired = 4062;
ErrCouponNotFound = 4063;
ErrUserDoesNotBelongToTeam = 4064;
ErrInactiveAgent = 4065;

//// Pathwar Server (starting at 5001)

Expand Down
3 changes: 3 additions & 0 deletions api/pwapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ message AgentRegister {
string arch = 4 [(gogoproto.moretags) = "url:\"arch\""];
string version = 5 [(gogoproto.moretags) = "url:\"version\""];
repeated string tags = 6 [(gogoproto.moretags) = "url:\"tags\""];
string domain_suffix = 7 [(gogoproto.moretags) = "url:\"domain_suffix\""];
string metadata = 8 [(gogoproto.moretags) = "url:\"metadata\""];
int32 nginx_port = 9 [(gogoproto.moretags) = "url:\"nginx_port\""];
// FIXME: capabilities
}
message Output {
Expand Down
9 changes: 7 additions & 2 deletions api/pwdb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ message Agent {
string arch = 105;
string version = 106;
string tags = 107;
google.protobuf.Timestamp last_registration_at = 108 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
google.protobuf.Timestamp last_seen_at = 109 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
string domain_suffix = 108;
int32 nginx_port = 109;
string metadata = 110;
int32 times_seen = 111;
int32 times_registered = 112;
google.protobuf.Timestamp last_registration_at = 113 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
google.protobuf.Timestamp last_seen_at = 114 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
// FIXME: capabilities
// FIXME: metrics -> cpu/memory/containers/etc

Expand Down
6 changes: 3 additions & 3 deletions docs/gen.sum

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

16 changes: 1 addition & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ module pathwar.land/v2

require (
github.com/Bearer/bearer-go v1.2.1
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/brianvoe/gofakeit v3.18.0+incompatible
github.com/bwmarrin/snowflake v0.3.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/go-chi/chi v4.0.2+incompatible
github.com/go-sql-driver/mysql v1.4.1
github.com/gobuffalo/envy v1.8.1 // indirect
github.com/gobuffalo/logger v1.0.3 // indirect
github.com/gobuffalo/packr/v2 v2.7.1
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.1
Expand All @@ -28,36 +23,27 @@ require (
github.com/moby/moby v1.13.1
github.com/oklog/run v1.0.0
github.com/olekukonko/tablewriter v0.0.4
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opentracing/opentracing-go v1.1.0
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
github.com/openzipkin/zipkin-go v0.2.1
github.com/peterbourgon/ff v1.7.0
github.com/pkg/errors v0.8.1
github.com/rogpeppe/go-internal v1.5.1 // indirect
github.com/rs/cors v1.7.0
github.com/soheilhy/cmux v0.1.4
github.com/stretchr/testify v1.4.0
github.com/treastech/logger v0.0.0-20180705232552-e381e9ecf2e3
go.uber.org/atomic v1.5.1 // indirect
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.13.0
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect
golang.org/x/tools v0.0.0-20191230220329-2aa90c603ae3 // indirect
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc v1.26.0
gopkg.in/gormigrate.v1 v1.6.0
gopkg.in/yaml.v2 v2.2.7 // indirect
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71
moul.io/godev v1.5.0
moul.io/srand v1.4.0
moul.io/zapgorm v1.0.0
pathwar.land/go v0.0.0-20200221213905-360dbeca3133
)

replace (
Expand Down
4 changes: 4 additions & 0 deletions go.sum

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

3 changes: 3 additions & 0 deletions go/cmd/pathwar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
agentNginxDockerImage string
agentRunOnce bool
agentSalt string
agentNoRun bool
apiDBURN string
bearerSecretKey string
composeDownKeepVolumes bool
Expand Down Expand Up @@ -141,6 +142,7 @@ func main() {

agentFlags.BoolVar(&agentClean, "clean", false, "remove all pathwar instances before executing")
agentFlags.BoolVar(&agentRunOnce, "once", false, "run once and don't start daemon loop")
agentFlags.BoolVar(&agentNoRun, "no-run", false, "stop after agent initialization (register and cleanup)")
agentFlags.DurationVar(&agentLoopDelay, "delay", 10*time.Second, "delay between each loop iteration")
agentFlags.StringVar(&httpAPIAddr, "http-api-addr", defaultHTTPApiAddr, "HTTP API address")
agentFlags.StringVar(&ssoClientID, "sso-clientid", defaultSSOClientID, "SSO ClientID")
Expand Down Expand Up @@ -685,6 +687,7 @@ func main() {
NginxDockerImage: agentNginxDockerImage,
Cleanup: agentClean,
RunOnce: agentRunOnce,
NoRun: agentNoRun,
LoopDelay: agentLoopDelay,
Name: agentName,
Logger: logger,
Expand Down
6 changes: 3 additions & 3 deletions go/gen.sum

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

Loading

0 comments on commit b2b0803

Please sign in to comment.