Skip to content

Commit

Permalink
Merge pull request #38 from iawells/doc-fix
Browse files Browse the repository at this point in the history
Change server,cli make targets to build for running platform
  • Loading branch information
mmlb committed Nov 15, 2023
2 parents 4a14709 + 2b6d7e6 commit 471c8d4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ RUN apk add --no-cache --update --upgrade ca-certificates
RUN apk add --no-cache --update --upgrade --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing cfssl
COPY entrypoint.sh /entrypoint.sh
COPY tls /tls
COPY --from=builder /src/cacher-linux-x86_64 /cacher
COPY --from=builder /src/cacher /cacher
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
server := cacher-linux-x86_64
cli := cmd/cacherc/cacherc-linux-x86_64
binaries := ${server} ${cli}
all: ${binaries}
server := cacher
cli := cmd/cacherc/cacherc

.PHONY: server ${binaries} cli gen test
server: ${server}
.PHONY: all
all: ${server} ${cli}

.PHONY: cli ${cli}
cli: ${cli}

.PHONY: server ${server}
server: ${server}

${cli} ${server}: protos/cacher/cacher.pb.go
CGO_ENABLED=0 GOOS=linux go build -o $@ ./$(@D)
CGO_ENABLED=0 go build -o $@ ./$(@D)

.PHONY: gen
gen: protos/cacher/cacher.pb.go

protos/cacher/cacher.pb.go: protos/cacher/cacher.proto
go generate ./...
goimports -w $@

.PHONY: test
test: lint test-only

.PHONY: test-only
test-only: server
CGO_ENABLED=1 go test -race -coverprofile=coverage.txt -covermode=atomic ${TEST_ARGS} ./...

run: ${binaries}
.PHONY: run
run:
docker-compose up --build server

.PHONY: lint
include lint.mk
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Cacher

[![Build Status](https://cloud.drone.io/api/badges/packethost/cacher/status.svg)](https://cloud.drone.io/packethost/cacher)

This is cacher, it gets some data from api and puts it into memory then serves it up.
Expand All @@ -8,16 +9,11 @@ That is all.

### Build

From the root directory execute `make cli`

or

Enter into the cmd/cacher folder and execute `go build .`

From the root directory execute `make cli` (file will be named `cmd/cacherc/cacherc`)

### Example output

```
```bash-session
./cacherc

cacher client
Expand All @@ -40,17 +36,29 @@ Usage:

### Example commands

`cacherc -f dfw2 all`
```bash-session
cacherc -f dfw2 all
```

`cacherc -f ewr1 mac 2c:60:0c:6e:82:a7 | jq '.network_ports[0].connected_ports'`
```bash-session
cacherc -f ewr1 mac 2c:60:0c:6e:82:a7 | jq '.network_ports[0].connected_ports'
```

`cacherc -f ny5 all | jq '.id as $id | .network_ports | map(select(.data.mac == "34:48:ed:ed:08:e2") | [$id, .data.mac])[] | @tsv' -r 2>/dev/null`
```bash-session
cacherc -f ny5 all | jq '.id as $id | .network_ports | map(select(.data.mac == "34:48:ed:ed:08:e2") | [$id, .data.mac])[] | @tsv' -r 2>/dev/null
```

`cacherc -f ewr1 id 478f2376-87b3-4fb6-a52f-1fbcd83820a3 | jq '.instance.operating_system_version'`
```bash-session
cacherc -f ewr1 id 478f2376-87b3-4fb6-a52f-1fbcd83820a3 | jq '.instance.operating_system_version'
```

`cacherc -f iad1 mac ac:1f:6b:2d:33:48 | jq '.instance.ip_addresses[0].address'`
```bash-session
cacherc -f iad1 mac ac:1f:6b:2d:33:48 | jq '.instance.ip_addresses[0].address'
```

`cacherc -f dfw2 id ac8eeb4e-a520-4582-b5b7-ea4fab6ebbd9 | jq `
```bash-session
cacherc -f dfw2 id ac8eeb4e-a520-4582-b5b7-ea4fab6ebbd9 | jq
```

## OpenTelemetry

Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestNoIngest(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "./cacher-linux-x86_64")
cmd := exec.CommandContext(ctx, "./cacher")
cmd.Env = []string{}
err := cmd.Run()

Expand All @@ -27,7 +27,7 @@ func TestNoIngest(t *testing.T) {
assert.Equal(t, 2, eerr.ExitCode())
})
t.Run("IngestDisabled", func(t *testing.T) {
cmd := exec.Command("./cacher-linux-x86_64")
cmd := exec.Command("./cacher")
cmd.Env = []string{
"CACHER_NO_INGEST=true",
}
Expand Down

0 comments on commit 471c8d4

Please sign in to comment.