Skip to content

Commit

Permalink
Update deps, adjust Readme for namespaces (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Apr 18, 2023
1 parent cbe26d8 commit d01b55e
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 177 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ func main() {
// create a ipamer with in memory storage
ipam := goipam.New()

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

bgCtx := context.Background()
// Optional with Namespace
ctx := goipam.NewContextWithNamespace(bgCtx, "tenant-a")

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
prefix, err := ipam.NewPrefix(ctx, "192.168.0.0/24")
if err != nil {
Expand Down Expand Up @@ -107,7 +112,12 @@ func main() {
connect.WithGRPC(),
)

result, err := c.CreatePrefix(context.Background(), connect.NewRequest(&v1.CreatePrefixRequest{Cidr: "192.168.0.0/16",}))
bgCtx := context.Background()

// Optional with Namespace
ctx := goipam.NewContextWithNamespace(bgCtx, "tenant-a")

result, err := c.CreatePrefix(ctx, connect.NewRequest(&v1.CreatePrefixRequest{Cidr: "192.168.0.0/16",}))
if err != nil {
panic(err)
}
Expand Down
130 changes: 88 additions & 42 deletions api/v1/apiv1connect/ipam.connect.go

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

2 changes: 1 addition & 1 deletion api/v1/ipam.pb.go

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

2 changes: 0 additions & 2 deletions etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ func (e *etcd) DeletePrefix(ctx context.Context, prefix Prefix, namespace string
func (e *etcd) CreateNamespace(ctx context.Context, namespace string) error {
e.lock.Lock()
defer e.lock.Unlock()
fmt.Printf("ETCD CREATE NAMESPACE: %s\n", namespace)
if _, ok := e.namespaces[namespace]; ok {
return nil
}
Expand All @@ -325,7 +324,6 @@ func (e *etcd) ListNamespaces(ctx context.Context) ([]string, error) {
return nil, err
}
var result []string
fmt.Printf("ALL KEYS: %v\n", res.Kvs)
for _, kv := range res.Kvs {
result = append(result, strings.TrimPrefix(string(kv.Key), key))
}
Expand Down
60 changes: 31 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,48 @@ go 1.20

require (
github.com/avast/retry-go/v4 v4.3.3
github.com/bufbuild/connect-go v1.5.2
github.com/bufbuild/connect-go v1.6.0
github.com/bufbuild/connect-grpchealth-go v1.0.0
github.com/bufbuild/connect-grpcreflect-go v1.0.0
github.com/jmoiron/sqlx v1.3.5
github.com/klauspost/connect-compress v1.0.0
github.com/lib/pq v1.10.7
github.com/lib/pq v1.10.8
github.com/metal-stack/v v1.0.3
github.com/redis/go-redis/v9 v9.0.2
github.com/stretchr/testify v1.8.1
github.com/testcontainers/testcontainers-go v0.18.0
github.com/urfave/cli/v2 v2.24.4
go.etcd.io/etcd/client/v3 v3.5.7
go.mongodb.org/mongo-driver v1.11.2
github.com/redis/go-redis/v9 v9.0.3
github.com/stretchr/testify v1.8.2
github.com/testcontainers/testcontainers-go v0.19.0
github.com/urfave/cli/v2 v2.25.1
go.etcd.io/etcd/client/v3 v3.5.8
go.mongodb.org/mongo-driver v1.11.4
go.uber.org/zap v1.24.0
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f
golang.org/x/net v0.7.0
go4.org/netipx v0.0.0-20230303233057-f1b76eb4bb35
golang.org/x/net v0.9.0
golang.org/x/sync v0.1.0
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.30.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.6.18 // indirect
github.com/containerd/containerd v1.7.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.1+incompatible // indirect
github.com/docker/docker v23.0.4+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
Expand All @@ -53,8 +54,8 @@ require (
github.com/montanaflynn/stats v0.7.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect
github.com/opencontainers/runc v1.1.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -64,17 +65,18 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.etcd.io/etcd/api/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
go.etcd.io/etcd/api/v3 v3.5.8 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.8 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc // indirect
google.golang.org/grpc v1.53.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.8.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
)
Loading

0 comments on commit d01b55e

Please sign in to comment.