Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/assets/Operator-Design.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
261 changes: 183 additions & 78 deletions README.md

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ module github.com/0xSplits/kayron

go 1.24.0

toolchain go1.24.6

require (
github.com/0xSplits/otelgo v0.1.2
github.com/0xSplits/roghfs v0.1.0
github.com/0xSplits/workit v0.6.0
github.com/0xSplits/workit v0.7.0
github.com/aws/aws-sdk-go-v2 v1.39.0
github.com/aws/aws-sdk-go-v2/config v1.31.8
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.66.2
Expand All @@ -18,6 +16,7 @@ require (
github.com/distribution/reference v0.6.0
github.com/goccy/go-yaml v1.18.0
github.com/google/go-cmp v0.7.0
github.com/google/go-containerregistry v0.20.6
github.com/google/go-github/v73 v73.0.0
github.com/gorilla/mux v1.8.1
github.com/joho/godotenv v1.5.1
Expand Down Expand Up @@ -58,10 +57,8 @@ require (
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/go-containerregistry v0.20.6
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -71,20 +68,20 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/otlptranslator v0.0.2 // indirect
github.com/prometheus/otlptranslator v1.0.0 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/puzpuzpuz/xsync/v4 v4.1.0 // indirect
github.com/puzpuzpuz/xsync/v4 v4.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/vbatts/tar-split v0.12.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.60.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
google.golang.org/protobuf v1.36.9 // indirect
)
30 changes: 14 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/0xSplits/otelgo v0.1.2 h1:QjbUMNNQcUsnkOmZ35bc3Fbhz7u0PA611LYrh4aOpPk
github.com/0xSplits/otelgo v0.1.2/go.mod h1:YnmWxWUT7xaMQTF3FBmN8GuvIMafSJ/lYhlyIBlr99w=
github.com/0xSplits/roghfs v0.1.0 h1:E3BB8+w+X3g64ezuJ13FssmfNorqy/fx2RGWBFtVifw=
github.com/0xSplits/roghfs v0.1.0/go.mod h1:KVlXti9dNWj2YtskpRjZNFqccSKsh5K+UJs73GMXTJs=
github.com/0xSplits/workit v0.6.0 h1:h2LrDdkOTuokSOwt0E3dt8N90fsMsoNd3CCsyI3U0f8=
github.com/0xSplits/workit v0.6.0/go.mod h1:+SQ35oJXLBigYeA1VSrKkJNaX4KBLE+M4PuoBZT1xs0=
github.com/0xSplits/workit v0.7.0 h1:kBa6bJ/9mjUIJYhi+MzBI5kY1iEfSyAYGH+H7wrSMoY=
github.com/0xSplits/workit v0.7.0/go.mod h1:9vuuL6Lr+KfZuOKMihtymd11+8Yq5woBqRqra29gd6U=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/aws/aws-sdk-go-v2 v1.39.0 h1:xm5WV/2L4emMRmMjHFykqiA4M/ra0DJVSWUkDyBjbg4=
Expand Down Expand Up @@ -88,8 +88,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 h1:cLN4IBkmkYZNnk7EAJ0BHIethd+J6LqxFNw5mSiI2bM=
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
Expand Down Expand Up @@ -122,14 +120,14 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/otlptranslator v0.0.2 h1:+1CdeLVrRQ6Psmhnobldo0kTp96Rj80DRXRd5OSnMEQ=
github.com/prometheus/otlptranslator v0.0.2/go.mod h1:P8AwMgdD7XEr6QRUJ2QWLpiAZTgTE2UYgjlu3svompI=
github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos=
github.com/prometheus/otlptranslator v1.0.0/go.mod h1:vRYWnXvI6aWGpsdY/mOT/cbeVRBlPWtBNDb7kGR3uKM=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/puzpuzpuz/xsync/v4 v4.1.0 h1:x9eHRl4QhZFIPJ17yl4KKW9xLyVWbb3/Yq4SXpjF71U=
github.com/puzpuzpuz/xsync/v4 v4.1.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/puzpuzpuz/xsync/v4 v4.2.0 h1:dlxm77dZj2c3rxq0/XNvvUKISAmovoXF4a4qM6Wvkr0=
github.com/puzpuzpuz/xsync/v4 v4.2.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand All @@ -154,8 +152,8 @@ github.com/xh3b4sd/logger v0.11.1 h1:aTK4ygh7aPv1jq54J8bx+zjH6A8RYdkKAgOZYw867C0
github.com/xh3b4sd/logger v0.11.1/go.mod h1:MC7Dp7RC3tZ182KlvSulGcRQVX/D2l+WlCSGLF1mvO8=
github.com/xh3b4sd/tracer v1.0.0 h1:mr9uYCx/Ry2w1wdJz0V0Kq71/KeF+hUQjbZQJCxm3Zw=
github.com/xh3b4sd/tracer v1.0.0/go.mod h1:nfZeNH5RRfqE6ctQroIfY75b2NRlJHl2g+HP7ddvHrM=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/prometheus v0.60.0 h1:cGtQxGvZbnrWdC2GyjZi0PDKVSLWP/Jocix3QWfXtbo=
Expand All @@ -170,8 +168,8 @@ go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJr
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -180,8 +178,8 @@ golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
1 change: 1 addition & 0 deletions pkg/cache/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (c *Cache) Create(rel release.Slice) error {
"docker", x.Docker.String(),
"github", x.Github.String(),
"deploy", x.Deploy.String(),
"preview", x.Deploy.Preview.String(),
"provider", x.Provider.String(),
)

Expand Down
28 changes: 28 additions & 0 deletions pkg/cache/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ type Object struct {
kin kind
}

// Domain returns the hash based testing domain for preview deployments, or an
// empty string for any other main release and non-testing environment.
func (o Object) Domain(env string) string {
// Note that we filter the domain name creation by preview deployments,
// because at the time of writing we do not have any convenient way to tell
// whether this release artifact is exposed to the internet via DNS. Right now
// we only know that for certain in case of preview deployments, because their
// sole purpose is to be exposed to the internet.

if !bool(o.Release.Deploy.Preview) {
return ""
}

return fmt.Sprintf("%s.%s.%s.splits.org",
o.Release.Labels.Hash.Lower(),

// Note that this is a dirty hack to make preview deployments work today for
// existing services that already work using certain incosnistencies between
// repository and domain names. E.g. we have "splits-lite" in Github, but
// use just "lite.testing.splits.org". A better way of doing this would be
// to allow for some kind of domain configuration in the release definition,
// so that we can remove this magical string replacement below.
strings.TrimPrefix(o.Release.Docker.String(), "splits-"),

env,
)
}

func (o Object) Name() string {
if o.kin == Infrastructure {
return o.Release.Github.String()
Expand Down
20 changes: 20 additions & 0 deletions pkg/cache/previews.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cache

// Previews returns all cached service release artifacts that are defined as
// preview deployments.
func (c *Cache) Previews(doc string) []Object {
{
c.mut.Lock()
defer c.mut.Unlock()
}

var lis []Object

for _, x := range c.ser {
if bool(x.Release.Deploy.Preview) && x.Release.Docker.String() == doc {
lis = append(lis, x)
}
}

return lis
}
2 changes: 2 additions & 0 deletions pkg/cache/services.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cache

// Services returns all cached service release artifacts, including those of any
// preview deployments.
func (c *Cache) Services() []Object {
{
c.mut.Lock()
Expand Down
1 change: 1 addition & 0 deletions pkg/cache/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ func (c *Cache) Update(obj Object) {

if obj.kin == Service {
c.ser[obj.ind].Artifact = c.ser[obj.ind].Artifact.Merge(obj.Artifact)
c.ser[obj.ind].Release.Deploy.Preview = obj.Release.Deploy.Preview
}
Comment on lines 13 to 16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly, but this enables us to reuse some information in one place, which we already fetched from the Github API in another place. E.g. the preview worker handler resets the preview flag of the release artifact of any main release that defines preview releases for its entire repository. I don't know how to make this better at this point in time.

}
70 changes: 70 additions & 0 deletions pkg/hash/hash.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package hash

import (
"crypto/sha256"
"encoding/hex"

"golang.org/x/text/cases"
"golang.org/x/text/language"
)

type Hash struct {
// dsh is the dashed prefix version of Upp.
//
// -1D0FD508
//
dsh []byte
// low is the lower case version of Upp.
//
// 1d0fd508
//
low []byte
// upp is the upper case version of this hash.
//
// 1D0FD508
//
upp []byte
}

func New(str string) Hash {
var hsh string
{
hsh = newHsh(str)
}

var low string
var upp string
{
low = cases.Lower(language.English).String(hsh)
upp = cases.Upper(language.English).String(hsh)
}

return Hash{
dsh: []byte("-" + upp),
low: []byte(low),
upp: []byte(upp),
}
}
Comment on lines +42 to +47
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are hashing branch names for identifying preview deployments inside all of AWS. We also have to create the preview deployment domain using some kind of deterministic identifier based on the preview branch. Turned out we cannot just use branch names in preview domains because branch names have a far wider character set than domain names allow for. E.g. the domain feature/branch.lite.splits.org is invalid.


func (h Hash) Dashed() string {
return string(h.dsh)
}

func (h Hash) Empty() bool {
return h.dsh == nil && h.low == nil && h.upp == nil
}

func (h Hash) Lower() string {
return string(h.low)
}

func (h Hash) Upper() string {
return string(h.upp)
}

func newHsh(str string) string {
sum := sha256.Sum256([]byte(str))
enc := hex.EncodeToString(sum[:])

return enc[:8]
}
6 changes: 6 additions & 0 deletions pkg/operator/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ func (o *Operator) Chain() [][]handler.Ensure {
// reconciliation loops.
{o.release},

// Inject any potential preview deployments into our internal list of
// release definitions so that we can render and expose any additional
// development services during testing. Note that this worker handler is
// only active within the testing environment.
{o.preview},
Comment on lines +18 to +22
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we register the new conditional worker handler.


// Run the next steps in parallel in order to find the current and
// desired state of the release artifacts that we are tasked to
// managed.
Expand Down
6 changes: 6 additions & 0 deletions pkg/operator/cloudformation/active.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cloudformation

// Active defines this worker handler to always be executed.
func (c *CloudFormation) Active() bool {
return true
}
Comment on lines +3 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are marking almost all worker handlers in Kayron as always active. The alternative would be to wrap every worker handler in a proxy worker handler, but I thought this approach here is more explicit.

12 changes: 9 additions & 3 deletions pkg/operator/cloudformation/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@ func (c *CloudFormation) temPar(rel []cache.Object) []types.Parameter {
}

// Inject all desired artifact versions into the parameters that we are just
// about to deploy. Injecting those parameters after all user inputs have been
// applied above guarantees that only the release versions as defined in the
// release source repository will ever be applied.
// about to deploy, but only for main release definitions, not for preview
// deployments. Injecting the template parameters after all user inputs have
// been applied above guarantees that only the release versions as defined in
// the release source repository will ever be applied.

for _, x := range rel {
if bool(x.Release.Deploy.Preview) {
continue
}

par = append(par, types.Parameter{
ParameterKey: aws.String(x.Parameter()),
ParameterValue: aws.String(x.Version()),
})
}

return par
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/operator/container/active.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package container

// Active defines this worker handler to always be executed.
func (c *Container) Active() bool {
return true
}
7 changes: 4 additions & 3 deletions pkg/operator/container/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ func (c *Container) cache(ima []image) {
for _, x := range c.cac.Services() {
var tag string
{
tag = curTag(ima, x.Release.Docker.String())
tag = curTag(ima, x.Release.Labels.Hash.Upper(), x.Release.Docker.String())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point we have potentially many ECS Services using the same service tag. So we have to differentiate via the preview tags, which contain the branch based preview hashes.

}

c.log.Log(
"level", "debug",
"message", "caching current state",
"docker", x.Release.Docker.String(),
"preview", x.Release.Deploy.Preview.String(),
"current", musStr(tag),
)

Expand All @@ -32,9 +33,9 @@ func (c *Container) cache(ima []image) {
}
}

func curTag(ima []image, ser string) string {
func curTag(ima []image, hsh string, doc string) string {
for _, x := range ima {
if x.ser == ser {
if x.pre == hsh && x.ser == doc {
return x.tag
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/container/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
)

type image struct {
// pre is the "preview" resource tag attached to any given ECS service, if
// any, e.g. 1D0FD508.
pre string
// ser is the "service" resource tag attached to any given ECS service, e.g.
// alloy or specta.
ser string
Expand Down Expand Up @@ -57,6 +60,7 @@ func (c *Container) image(tas []task) ([]image, error) {
// only responsible for their own execution index within the image slice.

ima[i] = image{
pre: t.pre,
ser: t.ser,
tag: tag,
}
Expand Down
Loading