Replace XenitAB PKG with internal package
This commit is contained in:
parent
a32ca43fdb
commit
ffe07c766d
@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- [#411](https://github.com/spegel-org/spegel/pull/411) Replace XenitAB pkg with internal package.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
@ -5,6 +5,7 @@ COPY go.mod go.mod
|
||||
COPY go.sum go.sum
|
||||
RUN go mod download
|
||||
COPY main.go main.go
|
||||
COPY internal/ internal/
|
||||
COPY pkg/ pkg/
|
||||
RUN CGO_ENABLED=0 go build -installsuffix 'static' -o spegel .
|
||||
|
||||
|
1
go.mod
1
go.mod
@ -22,7 +22,6 @@ require (
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/spf13/afero v1.11.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/xenitab/pkg/channels v0.0.2
|
||||
github.com/xenitab/pkg/gin v0.0.9
|
||||
github.com/xenitab/pkg/kubernetes v0.0.4
|
||||
go.etcd.io/bbolt v1.3.9
|
||||
|
2
go.sum
2
go.sum
@ -1427,8 +1427,6 @@ github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSD
|
||||
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k=
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc=
|
||||
github.com/xenitab/pkg/channels v0.0.2 h1:nCMsjEyhJedmAimYPOobzJl/yj7byU9h6IHEPc4QlPg=
|
||||
github.com/xenitab/pkg/channels v0.0.2/go.mod h1:/MCBlje0/98BdAF7LetkSK1+lXeUpScIbTENGaWjGRg=
|
||||
github.com/xenitab/pkg/gin v0.0.9 h1:BGdxnKoXAJBkthQTwQdaRdN7jTiNO+/C8hIexBrasfU=
|
||||
github.com/xenitab/pkg/gin v0.0.9/go.mod h1:8rzqJ8X5KJOo31PBOD4/Wtlt2ac8hCjN1mpOf1YAFs4=
|
||||
github.com/xenitab/pkg/kubernetes v0.0.4 h1:muVWzci89l611bd4FzWlDsHm2zwwzNpxA2TvY9svebI=
|
||||
|
27
internal/channel/channel.go
Normal file
27
internal/channel/channel.go
Normal file
@ -0,0 +1,27 @@
|
||||
package channel
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
func Merge[T any](cs ...<-chan T) <-chan T {
|
||||
var wg sync.WaitGroup
|
||||
out := make(chan T)
|
||||
|
||||
output := func(c <-chan T) {
|
||||
for n := range c {
|
||||
out <- n
|
||||
}
|
||||
wg.Done()
|
||||
}
|
||||
wg.Add(len(cs))
|
||||
for _, c := range cs {
|
||||
go output(c)
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(out)
|
||||
}()
|
||||
return out
|
||||
}
|
@ -22,8 +22,9 @@ import (
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/xenitab/pkg/channels"
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
"github.com/spegel-org/spegel/internal/channel"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -165,7 +166,7 @@ func (c *Containerd) Subscribe(ctx context.Context) (<-chan ImageEvent, <-chan e
|
||||
imgCh <- ImageEvent{Image: img, Type: eventType}
|
||||
}
|
||||
}()
|
||||
return imgCh, channels.Merge(errCh, cErrCh)
|
||||
return imgCh, channel.Merge(errCh, cErrCh)
|
||||
}
|
||||
|
||||
func (c *Containerd) ListImages(ctx context.Context) ([]Image, error) {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/xenitab/pkg/channels"
|
||||
|
||||
"github.com/spegel-org/spegel/internal/channel"
|
||||
"github.com/spegel-org/spegel/pkg/metrics"
|
||||
"github.com/spegel-org/spegel/pkg/oci"
|
||||
"github.com/spegel-org/spegel/pkg/routing"
|
||||
@ -21,7 +21,7 @@ func Track(ctx context.Context, ociClient oci.Client, router routing.Router, res
|
||||
immediate <- time.Now()
|
||||
expirationTicker := time.NewTicker(routing.KeyTTL - time.Minute)
|
||||
defer expirationTicker.Stop()
|
||||
ticker := channels.Merge(immediate, expirationTicker.C)
|
||||
ticker := channel.Merge(immediate, expirationTicker.C)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
Loading…
x
Reference in New Issue
Block a user