Skip to content

Commit 71aaecc

Browse files
author
Charly Molter
authored
Merge pull request #1 from koyeb/cleanup
Prepare for OSS
2 parents b0c06dc + cafc9c1 commit 71aaecc

File tree

9 files changed

+77
-10
lines changed

9 files changed

+77
-10
lines changed

.github/workflows/prb.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- uses: actions/setup-go@v2
9+
with:
10+
go-version: "1.16"
11+
- run: make check

.github/workflows/release.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
on:
2+
release:
3+
types: [created]
4+
jobs:
5+
check:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-go@v2
10+
with:
11+
go-version: "1.16"
12+
- run: make check

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing
2+
3+
Feel free to open PRs. There isn't a formal process yet.

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2011-2021 GitHub Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tidy:
2+
test "${CI}" || go mod tidy
3+
4+
fmt:
5+
test "${CI}" || gofmt -s -w .
6+
test "${CI}" == "" || test -z "`gofmt -d . | tee /dev/stderr`"
7+
8+
vet:
9+
go vet ./...
10+
11+
test:
12+
go test -v ./...
13+
14+
check: tidy fmt vet test
15+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ It's therefore necessary to make execution of the reconciler as observable as po
2525
At Koyeb we've built reconcilers that helps keeping our models in sync with [Hashicorp Nomad](https://www.nomadproject.io/) and [Kuma](kuma.io/).
2626

2727

28+
## Contributing
29+
30+
See [Contributing](CONTRIBUTING.md).

pkg/reconciler/api.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Config struct {
2828
// MaxReconcileTime the maximum time a handle of an item should take
2929
MaxReconcileTime time.Duration
3030
// Observability configuration for logs, metrics and traces
31-
Observability Observability
31+
Observability Observability
3232
}
3333

3434
func DefaultConfig() Config {
@@ -53,6 +53,7 @@ type Handler interface {
5353

5454
// HandlerFunc see Handler
5555
type HandlerFunc func(ctx context.Context, id string) Result
56+
5657
func (f HandlerFunc) Handle(ctx context.Context, id string) Result {
5758
return f(ctx, id)
5859
}
@@ -84,7 +85,6 @@ type Error interface {
8485
RetryDelay() time.Duration
8586
}
8687

87-
8888
// WorkerHasher specifies which of the control-loop workers should handle this specific item.
8989
type WorkerHasher interface {
9090
// Route decide on which worker this item will go (return a value < 0 to drop this item), count is the number of items
@@ -93,6 +93,7 @@ type WorkerHasher interface {
9393

9494
// WorkerHasherFunc see WorkerHasher
9595
type WorkerHasherFunc func(ctx context.Context, id string, count int) (int, error)
96+
9697
func (f WorkerHasherFunc) Route(ctx context.Context, id string, count int) (int, error) {
9798
return f(ctx, id, count)
9899
}
@@ -114,6 +115,7 @@ type EventHandler interface {
114115

115116
// EventHandlerFunc see EventHandler
116117
type EventHandlerFunc func(ctx context.Context, jobId string) error
118+
117119
func (f EventHandlerFunc) Handle(ctx context.Context, jobId string) error {
118120
return f(ctx, jobId)
119121
}
@@ -145,6 +147,7 @@ type EventStream interface {
145147

146148
// EventStreamFunc see EventStream
147149
type EventStreamFunc func(ctx context.Context, handler EventHandler) error
150+
148151
func (f EventStreamFunc) Subscribe(ctx context.Context, handler EventHandler) error {
149152
return f(ctx, handler)
150153
}

pkg/reconciler/observability.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Observability struct {
1313
metric.Meter
1414
trace.Tracer
1515
}
16+
1617
var DefaultObservability = NewObservability(NoopLogger{}, otel.GetMeterProvider(), otel.GetTracerProvider())
1718

1819
// LoggerWithCtx add the tracing context to the logger
@@ -25,7 +26,6 @@ func NewObservability(l Logger, m metric.MeterProvider, t trace.TracerProvider)
2526
return Observability{Logger: l, Meter: m.Meter("kreconciler"), Tracer: t.Tracer("kreconciler")}
2627
}
2728

28-
2929
type Logger interface {
3030
With(keyValues ...interface{}) Logger
3131
Debug(msg string, keyValues ...interface{})
@@ -34,7 +34,8 @@ type Logger interface {
3434
Error(msg string, keyValues ...interface{})
3535
}
3636

37-
type NoopLogger struct {}
37+
type NoopLogger struct{}
38+
3839
func (n NoopLogger) With(keyValues ...interface{}) Logger {
3940
return n
4041
}
@@ -50,4 +51,3 @@ func (n NoopLogger) Warn(msg string, keyValues ...interface{}) {
5051

5152
func (n NoopLogger) Error(msg string, keyValues ...interface{}) {
5253
}
53-

pkg/reconciler/observability_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func (o obsTest) SpanRecorder() *oteltest.StandardSpanRecorder {
2626
func (o obsTest) Observability() Observability {
2727
return Observability{
2828
Logger: o.log,
29-
Meter: o.contr.MeterProvider().Meter("test"),
30-
Tracer: oteltest.NewTracerProvider(oteltest.WithSpanRecorder(o.sr)).Tracer("test"),
29+
Meter: o.contr.MeterProvider().Meter("test"),
30+
Tracer: oteltest.NewTracerProvider(oteltest.WithSpanRecorder(o.sr)).Tracer("test"),
3131
}
3232
}
3333

3434
type testLog struct {
35-
t *testing.T
35+
t *testing.T
3636
args []string
3737
}
3838

@@ -41,12 +41,12 @@ func (l testLog) With(kv ...interface{}) Logger {
4141
for _, v := range l.args {
4242
args = append(args, v)
4343
}
44-
for i := 0; i < len(kv); i+=2 {
44+
for i := 0; i < len(kv); i += 2 {
4545
args = append(args, fmt.Sprintf("%s=%v", kv[i], kv[i+1]))
4646
}
4747

4848
return testLog{
49-
t: l.t,
49+
t: l.t,
5050
args: args,
5151
}
5252
}

0 commit comments

Comments
 (0)