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: 4 additions & 0 deletions pkg/apis/ela/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (
// which Configuration it is created.
ConfigurationLabelKey = GroupName + "/configuration"

// ConfigurationGenerationAnnotationKey is the annotation key attached to a Revision indicating the
// generation of the Configuration that created this revision
ConfigurationGenerationAnnotationKey = GroupName + "/configurationGeneration"

// RouteLabelKey is the label key attached to a Configuration indicating by
// which Route it is configured as traffic target.
RouteLabelKey = GroupName + "/route"
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ func (c *Controller) syncHandler(key string) error {
}
rev.ObjectMeta.Labels[ela.ConfigurationLabelKey] = config.Name

if rev.ObjectMeta.Annotations == nil {
rev.ObjectMeta.Annotations = make(map[string]string)
}
rev.ObjectMeta.Annotations[ela.ConfigurationGenerationAnnotationKey] = fmt.Sprintf("%v", config.Spec.Generation)

// Delete revisions when the parent Configuration is deleted.
rev.OwnerReferences = append(rev.OwnerReferences, *controllerRef)

Expand Down
7 changes: 6 additions & 1 deletion pkg/controller/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package configuration
Congfiguration.
*/
import (
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -211,7 +212,11 @@ func TestCreateConfigurationsCreatesRevision(t *testing.T) {
}

if rev.Labels[ela.ConfigurationLabelKey] != config.Name {
t.Errorf("rev does not have label <%s:%s>", ela.ConfigurationLabelKey, config.Name)
t.Errorf("rev does not have configuration label <%s:%s>", ela.ConfigurationLabelKey, config.Name)
}

if rev.Annotations[ela.ConfigurationGenerationAnnotationKey] != fmt.Sprintf("%v", config.Spec.Generation) {
t.Errorf("rev does not have generation annotation <%s:%s>", ela.ConfigurationGenerationAnnotationKey, config.Name)
}

for k, v := range config.Spec.RevisionTemplate.ObjectMeta.Labels {
Expand Down