-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Explicit version for module template (#1699)
chore: Sync main to feature branch (#1718) chore: Refactor NewCachedDescriptorProvider (#1695) docs: Update KLM Local Test Setup Guide (#1680) chore: Configure different requeue intervals for Manifest reconciliation (#1690) feat: Drop multiple ways to reference modules in Kyma CR (#1672) chore: Bump k8s deps (#1703) fix: Manifest CR should update by moduletemplate generation changes (#1702) feat: Add Version to Kyma.Spec.Modules (#1694) chore: Refactor NewCachedDescriptorProvider (#1695) chore: Update branch to main (#1753) feat: Module catalog improvements implementation (#1748) feat: Remove kyma.spec.modules[].version from api (#1837) --------- Co-authored-by: Christoph Schwägerl <[email protected]> Co-authored-by: Nesma Badr <[email protected]> Co-authored-by: Benjamin Lindner <[email protected]> Co-authored-by: Tomasz Smelcerz <[email protected]>
- Loading branch information
1 parent
1f2e30d
commit e374157
Showing
45 changed files
with
1,729 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package shared | ||
|
||
import "strings" | ||
|
||
type Channel string | ||
|
||
const ( | ||
// NoneChannel when this value is defined for the ModuleTemplate, it means that the ModuleTemplate is not assigned to any channel. | ||
NoneChannel Channel = "none" | ||
) | ||
|
||
func (c Channel) Equals(value string) bool { | ||
return string(c) == strings.ToLower(value) | ||
} |
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,105 @@ | ||
package v1beta2 | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/kyma-project/lifecycle-manager/api/shared" | ||
apimetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func Test_GetVersion(t *testing.T) { | ||
const testVersion = "1.0.1" | ||
const otherVersion = "0.0.1" | ||
tests := []struct { | ||
name string | ||
m *ModuleTemplate | ||
expectedVersion string | ||
expectedErr string | ||
}{ | ||
{ | ||
name: "Test GetVersion() by annotation (legacy)", | ||
m: &ModuleTemplate{ | ||
ObjectMeta: apimetav1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
shared.ModuleVersionAnnotation: testVersion, | ||
}, | ||
}, | ||
}, | ||
expectedVersion: testVersion, | ||
}, | ||
{ | ||
name: "Test GetVersion() by explicit version in Spec", | ||
m: &ModuleTemplate{ | ||
Spec: ModuleTemplateSpec{ | ||
Version: testVersion, | ||
}, | ||
}, | ||
expectedVersion: testVersion, | ||
}, | ||
{ | ||
name: "Test GetVersion() with both version in Spec and annotation", | ||
m: &ModuleTemplate{ | ||
ObjectMeta: apimetav1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
shared.ModuleVersionAnnotation: otherVersion, | ||
}, | ||
}, | ||
Spec: ModuleTemplateSpec{ | ||
Version: testVersion, | ||
}, | ||
}, | ||
expectedVersion: testVersion, | ||
}, | ||
{ | ||
name: "Test GetVersion without any version info", | ||
m: &ModuleTemplate{ | ||
ObjectMeta: apimetav1.ObjectMeta{ | ||
Annotations: map[string]string{}, | ||
}, | ||
Spec: ModuleTemplateSpec{}, | ||
}, | ||
expectedErr: ErrInvalidVersion.Error(), | ||
}, | ||
{ | ||
name: "Test GetVersion with invalid version", | ||
m: &ModuleTemplate{ | ||
Spec: ModuleTemplateSpec{ | ||
Version: "invalid", | ||
}, | ||
}, | ||
expectedErr: "Invalid Semantic Version", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
tt := tt | ||
actualVersion, err := tt.m.GetVersion() | ||
if err != nil { | ||
if actualVersion != nil { | ||
t.Errorf("GetVersion(): Returned version should be nil when error is not nil") | ||
} | ||
if tt.expectedErr == "" { | ||
t.Errorf("GetVersion(): Unexpected error: %v", err) | ||
} | ||
if !strings.Contains(err.Error(), tt.expectedErr) { | ||
t.Errorf("GetVersion(): Actual error = %v, expected error: %v", err, tt.expectedErr) | ||
} | ||
return | ||
} | ||
|
||
if actualVersion == nil { | ||
t.Errorf("GetVersion(): Returned version should not be nil when error is nil") | ||
} | ||
|
||
if tt.expectedVersion == "" { | ||
t.Errorf("GetVersion(): Expected version is empty but non-nil version is returned") | ||
} | ||
|
||
if actualVersion.String() != tt.expectedVersion { | ||
t.Errorf("GetVersion(): actual version = %v, expected version: %v", actualVersion.String(), tt.expectedVersion) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.