Skip to content

Commit

Permalink
refactor(api): move consts
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Antoshin <[email protected]>
  • Loading branch information
danilrwx committed Nov 20, 2024
1 parent 3cd9e4b commit 349c714
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
5 changes: 0 additions & 5 deletions images/virtualization-artifact/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ const (
// ImporterProxyCertDir is where the configmap containing proxy certs will be mounted
ImporterProxyCertDir = "/proxycerts/"

// AppKubernetesManagedByLabel is the Kubernetes recommended managed-by label
AppKubernetesManagedByLabel = "app.kubernetes.io/managed-by"
// AppKubernetesComponentLabel is the Kubernetes recommended component label
AppKubernetesComponentLabel = "app.kubernetes.io/component"

// ImporterSource provides a constant to capture our env variable "IMPORTER_SOURCE"
ImporterSource = "IMPORTER_SOURCE"
// ImporterContentType provides a constant to capture our env variable "IMPORTER_CONTENTTYPE"
Expand Down
9 changes: 0 additions & 9 deletions images/virtualization-artifact/pkg/controller/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ const (
// LastPropagatedVMLabelsAnnotation is a marshalled map of previously applied virtual machine labels.
LastPropagatedVMLabelsAnnotation = AnnAPIGroup + "/last-propagated-vm-labels"

// SourceHTTP is the source type HTTP, if unspecified or invalid, it defaults to SourceHTTP
SourceHTTP = "http"
// SourceRegistry is the source type of Registry
SourceRegistry = "registry"
// SourceDVCR is the source type of dvcr
SourceDVCR = "dvcr"
// SourceBlockDevice is the source type of block device
SourceBlockDevice = "blockDevice"

// LabelsPrefix is a prefix for virtualization-controller labels.
LabelsPrefix = "virtualization.deckhouse.io"

Expand Down
20 changes: 15 additions & 5 deletions images/virtualization-artifact/pkg/controller/importer/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ package importer
import (
"github.com/deckhouse/virtualization-controller/pkg/common"
"github.com/deckhouse/virtualization-controller/pkg/common/datasource"
cc "github.com/deckhouse/virtualization-controller/pkg/controller/common"
"github.com/deckhouse/virtualization-controller/pkg/controller/supplements"
"github.com/deckhouse/virtualization-controller/pkg/dvcr"
virtv2alpha1 "github.com/deckhouse/virtualization/api/core/v1alpha2"
)

const (
// SourceHTTP is the source type HTTP, if unspecified or invalid, it defaults to SourceHTTP
SourceHTTP = "http"
// SourceRegistry is the source type of Registry
SourceRegistry = "registry"
// SourceDVCR is the source type of dvcr
SourceDVCR = "dvcr"
// SourceBlockDevice is the source type of block device
SourceBlockDevice = "blockDevice"
)

// Settings stores all possible settings for dvcr-importer binary.
// Fields from this struct are passed via environment variables.
type Settings struct {
Expand Down Expand Up @@ -69,7 +79,7 @@ func ApplyDVCRDestinationSettings(podEnvVars *Settings, dvcrSettings *dvcr.Setti

// ApplyHTTPSourceSettings updates importer Pod settings to use http source.
func ApplyHTTPSourceSettings(podEnvVars *Settings, http *virtv2alpha1.DataSourceHTTP, supGen *supplements.Generator) {
podEnvVars.Source = cc.SourceHTTP
podEnvVars.Source = SourceHTTP
podEnvVars.Endpoint = http.URL

if http.Checksum != nil {
Expand All @@ -91,7 +101,7 @@ func ApplyHTTPSourceSettings(podEnvVars *Settings, http *virtv2alpha1.DataSource

// ApplyRegistrySourceSettings updates importer Pod settings to use registry source.
func ApplyRegistrySourceSettings(podEnvVars *Settings, ctrImg *datasource.ContainerRegistry, supGen *supplements.Generator) {
podEnvVars.Source = cc.SourceRegistry
podEnvVars.Source = SourceRegistry
podEnvVars.Endpoint = common.DockerRegistrySchemePrefix + ctrImg.Image

// Optional auth secret from imagePullSecret.
Expand All @@ -115,11 +125,11 @@ func ApplyRegistrySourceSettings(podEnvVars *Settings, ctrImg *datasource.Contai
// ApplyDVCRSourceSettings updates importer Pod settings to use dvcr registry source.
// NOTE: no auth secret required, it will be taken from DVCR destination settings.
func ApplyDVCRSourceSettings(podEnvVars *Settings, dvcrImageName string) {
podEnvVars.Source = cc.SourceDVCR
podEnvVars.Source = SourceDVCR
podEnvVars.Endpoint = dvcrImageName
}

// ApplyBlockDeviceSourceSettings updates importer Pod settings to use BlockDevice as source.
func ApplyBlockDeviceSourceSettings(podEnvVars *Settings) {
podEnvVars.Source = cc.SourceBlockDevice
podEnvVars.Source = SourceBlockDevice
}

0 comments on commit 349c714

Please sign in to comment.