-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scoped recommended labels to apply to Pod and Service, added unit-tes…
…ts and integration-tests for both Application and SKIPJob
- Loading branch information
1 parent
d8e615a
commit a4bba73
Showing
15 changed files
with
130 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package resourceutils | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestGetImageVersionNoTag(t *testing.T) { | ||
imageString := "image" | ||
expectedImageString := "latest" | ||
|
||
actualImageString := GetImageVersion(imageString) | ||
|
||
assert.Equal(t, expectedImageString, actualImageString) | ||
} | ||
|
||
func TestGetImageVersionLatestTag(t *testing.T) { | ||
imageString := "image:latest" | ||
expectedImageString := "latest" | ||
|
||
actualImageString := GetImageVersion(imageString) | ||
|
||
assert.Equal(t, expectedImageString, actualImageString) | ||
} | ||
|
||
func TestGetImageVersionVersionTag(t *testing.T) { | ||
versionImageString := "image:1.2.3" | ||
devImageString := "image:1.2.3-dev-123abc" | ||
expectedVersionImageString := "1.2.3" | ||
expectedDevImageString := "1.2.3-dev-123abc" | ||
|
||
actualVersionImageString := GetImageVersion(versionImageString) | ||
actualDevImageString := GetImageVersion(devImageString) | ||
|
||
assert.Equal(t, expectedVersionImageString, actualVersionImageString) | ||
assert.Equal(t, expectedDevImageString, actualDevImageString) | ||
|
||
} | ||
|
||
func TestGetImageVersionShaTag(t *testing.T) { | ||
imageString := "ghcr.io/org/repo@sha256:54d7ea8b48d0e7569766e0e10b9e38da778a5f65d764168dd7db76a37d6b8" | ||
expectedImageString := "54d7ea8b48d0e7569766e0e10b9e38da778a5f65d764168dd7db76a37d6b8" | ||
|
||
actualImageString := GetImageVersion(imageString) | ||
|
||
assert.Equal(t, expectedImageString, actualImageString) | ||
} |
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
13 changes: 13 additions & 0 deletions
13
tests/application/labels-imageversion/application-assert.yaml
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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app.kubernetes.io/version: "1234567890123456" | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app.kubernetes.io/version: "1234567890123456" |
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,7 @@ | ||
apiVersion: skiperator.kartverket.no/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: imageversionshalabel | ||
spec: | ||
image: image@sha256:1234567890123456 | ||
port: 8080 |
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,7 @@ | ||
apiVersion: skiperator.kartverket.no/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: imageversionlabellatest | ||
spec: | ||
image: image | ||
port: 8080 |
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,16 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: resource-label | ||
spec: | ||
skip: false | ||
concurrent: true | ||
skipDelete: false | ||
steps: | ||
- try: | ||
- create: | ||
file: application.yaml | ||
- apply: | ||
file: application-patch.yaml | ||
- assert: | ||
file: application-assert.yaml |
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