Skip to content

Commit

Permalink
Merge pull request #85 from 0xFelix/drop-labels
Browse files Browse the repository at this point in the history
cleanup: Drop labels from containerdisks
  • Loading branch information
kubevirt-bot authored Mar 25, 2024
2 parents 92fbb4b + 1f20fda commit c8f5fa6
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 144 deletions.
24 changes: 12 additions & 12 deletions artifacts/centos/centos.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const description = `<img src="https://upload.wikimedia.org/wikipedia/commons/th
Visit [centos.org](https://www.centos.org/) to learn more about the CentOS project.`

type centos struct {
Version string
Variant string
getter http.Getter
Arch string
AdditionalLabels map[string]string
Version string
Variant string
getter http.Getter
Arch string
EnvVariables map[string]string
}

func (c *centos) Metadata() *api.Metadata {
Expand All @@ -37,7 +37,7 @@ func (c *centos) Metadata() *api.Metadata {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: c.AdditionalLabels,
EnvVariables: c.EnvVariables,
}
}

Expand Down Expand Up @@ -147,12 +147,12 @@ func (c *centos) Tests() []api.ArtifactTest {
}

// New accepts CentOS 7 and 8 versions. Example patterns are 7-2111, 7-2009, 8.3, 8.4, ...
func New(release string, additionalLabels map[string]string) *centos {
func New(release string, envVariables map[string]string) *centos {
return &centos{
Version: release,
Variant: "GenericCloud",
Arch: "x86_64",
getter: &http.HTTPGetter{},
AdditionalLabels: additionalLabels,
Version: release,
Variant: "GenericCloud",
Arch: "x86_64",
getter: &http.HTTPGetter{},
EnvVariables: envVariables,
}
}
39 changes: 19 additions & 20 deletions artifacts/centos/centos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"kubevirt.io/api/instancetype"

"kubevirt.io/containerdisks/pkg/api"
"kubevirt.io/containerdisks/pkg/common"
"kubevirt.io/containerdisks/pkg/docs"
"kubevirt.io/containerdisks/testutil"
)

var _ = Describe("Centos", func() {
DescribeTable("Inspect should be able to parse checksum files",
func(release, mockFile string, details *api.ArtifactDetails, additionalLabels map[string]string, metadata *api.Metadata) {
c := New(release, additionalLabels)
func(release, mockFile string, details *api.ArtifactDetails, envVariables map[string]string, metadata *api.Metadata) {
c := New(release, envVariables)
c.getter = testutil.NewMockGetter(mockFile)
got, err := c.Inspect()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -31,7 +30,7 @@ var _ = Describe("Centos", func() {
AdditionalUniqueTags: []string{"8.4.2105-20210603.0", "8.4.2105"},
},
map[string]string{
"test-label": "test-value",
"TEST_ENV_VAR": "test-value",
},
&api.Metadata{
Name: "centos",
Expand All @@ -40,8 +39,8 @@ var _ = Describe("Centos", func() {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: map[string]string{
"test-label": "test-value",
EnvVariables: map[string]string{
"TEST_ENV_VAR": "test-value",
},
},
),
Expand All @@ -53,7 +52,7 @@ var _ = Describe("Centos", func() {
AdditionalUniqueTags: []string{"8.3.2011-20201204.2", "8.3.2011"},
},
map[string]string{
"test-label": "test-value",
"TEST_ENV_VAR": "test-value",
},
&api.Metadata{
Name: "centos",
Expand All @@ -62,8 +61,8 @@ var _ = Describe("Centos", func() {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: map[string]string{
"test-label": "test-value",
EnvVariables: map[string]string{
"TEST_ENV_VAR": "test-value",
},
},
),
Expand All @@ -73,8 +72,8 @@ var _ = Describe("Centos", func() {
DownloadURL: "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2",
},
map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.7",
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.7",
},
&api.Metadata{
Name: "centos",
Expand All @@ -83,9 +82,9 @@ var _ = Describe("Centos", func() {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.7",
EnvVariables: map[string]string{
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.7",
},
},
),
Expand All @@ -95,8 +94,8 @@ var _ = Describe("Centos", func() {
DownloadURL: "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1809.qcow2",
},
map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.7",
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.7",
},
&api.Metadata{
Name: "centos",
Expand All @@ -105,9 +104,9 @@ var _ = Describe("Centos", func() {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.7",
EnvVariables: map[string]string{
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.7",
},
},
),
Expand Down
34 changes: 17 additions & 17 deletions artifacts/centosstream/centos-stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ const description = `<img src="https://upload.wikimedia.org/wikipedia/commons/th
Visit [centos.org](https://www.centos.org/) to learn more about the CentOS project.`

type centos struct {
Version string
Variant string
getter http.Getter
Arch string
ExampleUserData *docs.UserData
AdditionalLabels map[string]string
Version string
Variant string
getter http.Getter
Arch string
ExampleUserData *docs.UserData
EnvVariables map[string]string
}

func (c *centos) Metadata() *api.Metadata {
metadata := &api.Metadata{
Name: "centos-stream",
Version: c.Version,
Description: description,
AdditionalLabels: c.AdditionalLabels,
Name: "centos-stream",
Version: c.Version,
Description: description,
EnvVariables: c.EnvVariables,
}

if c.ExampleUserData != nil {
Expand Down Expand Up @@ -116,13 +116,13 @@ func (c *centos) Tests() []api.ArtifactTest {
}

// New accepts CentOS Stream 8 and 9 versions.
func New(release string, exampleUserData *docs.UserData, additionalLabels map[string]string) *centos {
func New(release string, exampleUserData *docs.UserData, envVariables map[string]string) *centos {
return &centos{
Version: release,
Arch: "x86_64",
Variant: "GenericCloud",
getter: &http.HTTPGetter{},
ExampleUserData: exampleUserData,
AdditionalLabels: additionalLabels,
Version: release,
Arch: "x86_64",
Variant: "GenericCloud",
getter: &http.HTTPGetter{},
ExampleUserData: exampleUserData,
EnvVariables: envVariables,
}
}
27 changes: 13 additions & 14 deletions artifacts/centosstream/centos-stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"kubevirt.io/api/instancetype"

"kubevirt.io/containerdisks/pkg/api"
"kubevirt.io/containerdisks/pkg/common"
"kubevirt.io/containerdisks/pkg/docs"
"kubevirt.io/containerdisks/testutil"
)

var _ = Describe("CentosStream", func() {
DescribeTable("Inspect should be able to parse checksum files",
func(release, mockFile string, details *api.ArtifactDetails,
exampleUserData *docs.UserData, additionalLabels map[string]string, metadata *api.Metadata) {
c := New(release, exampleUserData, additionalLabels)
exampleUserData *docs.UserData, envVariables map[string]string, metadata *api.Metadata) {
c := New(release, exampleUserData, envVariables)
c.getter = testutil.NewMockGetter(mockFile)
got, err := c.Inspect()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -34,8 +33,8 @@ var _ = Describe("CentosStream", func() {
Username: "centos",
},
map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.stream8",
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.stream8",
},
&api.Metadata{
Name: "centos-stream",
Expand All @@ -44,9 +43,9 @@ var _ = Describe("CentosStream", func() {
ExampleUserData: docs.UserData{
Username: "centos",
},
AdditionalLabels: map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.stream8",
EnvVariables: map[string]string{
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.stream8",
},
},
),
Expand All @@ -60,8 +59,8 @@ var _ = Describe("CentosStream", func() {
Username: "cloud-user",
},
map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.stream9",
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.stream9",
},
&api.Metadata{
Name: "centos-stream",
Expand All @@ -70,9 +69,9 @@ var _ = Describe("CentosStream", func() {
ExampleUserData: docs.UserData{
Username: "cloud-user",
},
AdditionalLabels: map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "centos.stream9",
EnvVariables: map[string]string{
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "centos.stream9",
},
},
),
Expand Down
30 changes: 15 additions & 15 deletions artifacts/fedora/fedora.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"

v1 "kubevirt.io/api/core/v1"
"kubevirt.io/api/instancetype"

"kubevirt.io/containerdisks/pkg/api"
"kubevirt.io/containerdisks/pkg/common"
"kubevirt.io/containerdisks/pkg/docs"
"kubevirt.io/containerdisks/pkg/http"
"kubevirt.io/containerdisks/pkg/tests"
Expand All @@ -28,11 +28,11 @@ type Release struct {
}

type fedora struct {
Version string
Arch string
Variant string
getter http.Getter
AdditionalLabels map[string]string
Version string
Arch string
Variant string
getter http.Getter
EnvVariables map[string]string
}

type fedoraGatherer struct {
Expand All @@ -57,7 +57,7 @@ func (f *fedora) Metadata() *api.Metadata {
ExampleUserData: docs.UserData{
Username: "fedora",
},
AdditionalLabels: f.AdditionalLabels,
EnvVariables: f.EnvVariables,
}
}

Expand Down Expand Up @@ -118,8 +118,8 @@ func (f *fedoraGatherer) Gather() ([]api.Artifact, error) {
New(
release.Version,
map[string]string{
instancetype.DefaultInstancetypeLabel: "u1.small",
instancetype.DefaultPreferenceLabel: "fedora",
common.DefaultInstancetypeEnv: "u1.small",
common.DefaultPreferenceEnv: "fedora",
},
),
)
Expand Down Expand Up @@ -158,13 +158,13 @@ func (f *fedoraGatherer) releaseMatches(release *Release) bool {
strings.HasSuffix(release.Link, "qcow2")
}

func New(release string, additionalLabels map[string]string) *fedora {
func New(release string, envVariables map[string]string) *fedora {
return &fedora{
Version: release,
Arch: "x86_64",
Variant: "Cloud",
getter: &http.HTTPGetter{},
AdditionalLabels: additionalLabels,
Version: release,
Arch: "x86_64",
Variant: "Cloud",
getter: &http.HTTPGetter{},
EnvVariables: envVariables,
}
}

Expand Down
Loading

0 comments on commit c8f5fa6

Please sign in to comment.