Skip to content

Commit

Permalink
feature: add an annotation for the addon (#6256)
Browse files Browse the repository at this point in the history
Signed-off-by: suwanliang_yewu <suwanliang_yewu@cmss.chinamobile.com>
  • Loading branch information
suwliang3 committed Aug 22, 2023
1 parent c315e81 commit 88a85ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/addon/addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,13 +1135,16 @@ func TestPackageAddon(t *testing.T) {
}

func TestGenerateAnnotation(t *testing.T) {
meta := Meta{SystemRequirements: &SystemRequirements{
VelaVersion: ">1.4.0",
KubernetesVersion: ">1.20.0",
}}
meta := Meta{
Name: "test-addon",
SystemRequirements: &SystemRequirements{
VelaVersion: ">1.4.0",
KubernetesVersion: ">1.20.0",
}}
res := generateAnnotation(&meta)
assert.Equal(t, res[velaSystemRequirement], ">1.4.0")
assert.Equal(t, res[kubernetesSystemRequirement], ">1.20.0")
assert.Equal(t, res[addonSystemRequirement], meta.Name)

meta = Meta{}
meta.SystemRequirements = &SystemRequirements{KubernetesVersion: ">=1.20.1"}
Expand Down
1 change: 1 addition & 0 deletions pkg/addon/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func generateAnnotation(meta *Meta) map[string]string {
res[kubernetesSystemRequirement] = meta.SystemRequirements.KubernetesVersion
}
}
res[addonSystemRequirement] = meta.Name
return res
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/addon/versioned_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
velaSystemRequirement = `system.vela`
// kubernetesSystemRequirement is the kubernetes requirement annotation key
kubernetesSystemRequirement = `system.kubernetes`
// addonSystemRequirement is the annotation key to identity an addon from helm chart structure
addonSystemRequirement = `addon.name`
)

// VersionedRegistry is the interface of support version registry
Expand Down

0 comments on commit 88a85ea

Please sign in to comment.