forked from keptn/lifecycle-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lifecycle-operator): propagate metadata from deployment annotati…
…ons (keptn#2832) Signed-off-by: Florian Bacher <[email protected]> Signed-off-by: check-spelling-bot <[email protected]> Co-authored-by: Moritz Wiesinger <[email protected]>
- Loading branch information
Showing
38 changed files
with
353 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package context | ||
|
||
import "context" | ||
|
||
type keptnAppContextKeyType string | ||
|
||
var keptnAppContextKey = keptnAppContextKeyType("keptnAppContextMeta") | ||
|
||
func WithAppMetadata(ctx context.Context, appContextMeta ...map[string]string) context.Context { | ||
mergedMap := map[string]string{} | ||
for _, meta := range appContextMeta { | ||
for key, value := range meta { | ||
mergedMap[key] = value | ||
} | ||
} | ||
return context.WithValue(ctx, keptnAppContextKey, mergedMap) | ||
} | ||
|
||
func GetAppMetadataFromContext(ctx context.Context) (map[string]string, bool) { | ||
value := ctx.Value(keptnAppContextKey) | ||
|
||
appContextMeta, ok := value.(map[string]string) | ||
if ok { | ||
return appContextMeta, true | ||
} | ||
return map[string]string{}, false | ||
} |
25 changes: 25 additions & 0 deletions
25
lifecycle-operator/controllers/common/context/context_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package context | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestContextWithAppMetadata(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
metadata := map[string]string{ | ||
"foo": "bar", | ||
} | ||
|
||
ctx = WithAppMetadata(ctx, metadata) | ||
|
||
require.NotNil(t, ctx) | ||
|
||
metadata, ok := GetAppMetadataFromContext(ctx) | ||
|
||
require.True(t, ok) | ||
require.Equal(t, "bar", metadata["foo"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.