mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-13 00:19:32 -05:00
versionsapi: fix cache invalidation
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
b9a1a9ae5e
commit
8b39d3d368
@ -102,7 +102,7 @@ func main() {
|
|||||||
log.Infof("Successfully added version %q", *flags.version)
|
log.Infof("Successfully added version %q", *flags.version)
|
||||||
|
|
||||||
log.Infof("Waiting for cache invalidation.")
|
log.Infof("Waiting for cache invalidation.")
|
||||||
if err := versionManager.invalidateCaches(ctx, ver); err != nil {
|
if err := versionManager.invalidateCaches(ctx, ver, *flags.latest); err != nil {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to invalidate caches")
|
log.With(zap.Error(err)).Fatalf("Failed to invalidate caches")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ func (m *versionManager) addLatest(ctx context.Context, ver version) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) invalidateCaches(ctx context.Context, ver version) error {
|
func (m *versionManager) invalidateCaches(ctx context.Context, ver version, latest bool) error {
|
||||||
invalidIn := &cloudfront.CreateInvalidationInput{
|
invalidIn := &cloudfront.CreateInvalidationInput{
|
||||||
DistributionId: aws.String(m.distributionID),
|
DistributionId: aws.String(m.distributionID),
|
||||||
InvalidationBatch: &cftypes.InvalidationBatch{
|
InvalidationBatch: &cftypes.InvalidationBatch{
|
||||||
@ -427,6 +427,11 @@ func (m *versionManager) invalidateCaches(ctx context.Context, ver version) erro
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if latest {
|
||||||
|
invalidIn.InvalidationBatch.Paths.Quantity = aws.Int32(3)
|
||||||
|
path := path.Join("ref", ver.Ref(), "stream", ver.Stream(), "versions/latest/image.json")
|
||||||
|
invalidIn.InvalidationBatch.Paths.Items = append(invalidIn.InvalidationBatch.Paths.Items, "/"+path)
|
||||||
|
}
|
||||||
invalidation, err := m.cloudfrontc.CreateInvalidation(ctx, invalidIn)
|
invalidation, err := m.cloudfrontc.CreateInvalidation(ctx, invalidIn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -163,12 +163,12 @@ func New() *Fetcher {
|
|||||||
|
|
||||||
// MinorVersionsOf fetches the list of minor versions for a given stream, major version and kind.
|
// MinorVersionsOf fetches the list of minor versions for a given stream, major version and kind.
|
||||||
func (f *Fetcher) MinorVersionsOf(ctx context.Context, ref, stream, major, kind string) (*List, error) {
|
func (f *Fetcher) MinorVersionsOf(ctx context.Context, ref, stream, major, kind string) (*List, error) {
|
||||||
return f.list(ctx, stream, "major", major, ref, kind)
|
return f.list(ctx, ref, stream, "major", major, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchVersionsOf fetches the list of patch versions for a given stream, minor version and kind.
|
// PatchVersionsOf fetches the list of patch versions for a given stream, minor version and kind.
|
||||||
func (f *Fetcher) PatchVersionsOf(ctx context.Context, ref, stream, minor, kind string) (*List, error) {
|
func (f *Fetcher) PatchVersionsOf(ctx context.Context, ref, stream, minor, kind string) (*List, error) {
|
||||||
return f.list(ctx, stream, "minor", minor, ref, kind)
|
return f.list(ctx, ref, stream, "minor", minor, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// list fetches the list of versions for a given stream, granularity, base and kind.
|
// list fetches the list of versions for a given stream, granularity, base and kind.
|
||||||
|
Loading…
Reference in New Issue
Block a user