Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ require (
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.14.2
github.com/tidwall/sjson v1.2.5
github.com/vincent-petithory/dataurl v1.0.0
github.com/vmware/govmomi v0.45.1
Expand Down Expand Up @@ -179,7 +180,6 @@ require (
github.com/sigstore/rekor v1.3.10 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/tidwall/gjson v1.14.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/timonwong/loggercheck v0.10.1 // indirect
Expand Down
29 changes: 29 additions & 0 deletions test/extended-priv/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package extended

import (
"encoding/json"
"fmt"

o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
Expand All @@ -27,6 +28,24 @@ func NewConfigMapList(oc *exutil.CLI, namespace string) *ConfigMapList {
return &ConfigMapList{ResourceList: *NewNamespacedResourceList(oc, "ConfigMap", namespace)}
}

// GetDataValue returns the value of a specific key in the .data field
func (cm *ConfigMap) GetDataValue(key string) (string, error) {
// We cant use the "resource.Get" method, because exutil.client will trim the output, removing spaces and newlines that could be important in a configuration.
dataMap, err := cm.GetDataMap()

if err != nil {
return "", err
}

data, ok := dataMap[key]
if !ok {
return "", fmt.Errorf("Key %s does not exist in the .data in Configmap -n %s %s",
key, cm.GetNamespace(), cm.GetName())
}

return data, nil
}

// GetDataMap returns the valus in the .data field as a map[string][string]
func (cm *ConfigMap) GetDataMap() (map[string]string, error) {
data := map[string]string{}
Expand All @@ -42,6 +61,16 @@ func (cm *ConfigMap) GetDataMap() (map[string]string, error) {
return data, nil
}

// GetDataValueOrFail returns the value of a specific key in the .data field and fails the test if any error happens
func (cm *ConfigMap) GetDataValueOrFail(key string) string {
value, err := cm.GetDataValue(key)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(),
"Could get the value for key %s in configmap -n %s %s",
key, cm.GetNamespace(), cm.GetName())

return value
}

// GetAll returns a []ConfigMap list with all existing pinnedimageset sorted by creation timestamp
func (cml *ConfigMapList) GetAll() ([]ConfigMap, error) {
cml.ResourceList.SortByTimestamp()
Expand Down
29 changes: 28 additions & 1 deletion test/extended-priv/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package extended
import "time"

const (
// Ignition default version
IgnitionDefaultVersion = "3.5.0"

// MachineConfigNamespace mco namespace
MachineConfigNamespace = "openshift-machine-config-operator"
// MachineConfigDaemon mcd container name
Expand All @@ -27,7 +30,17 @@ const (

// LayeringBaseImageReleaseInfo is the name of the layering base image in release info
LayeringBaseImageReleaseInfo = "rhel-coreos"
GenericMCTemplate = "generic-machine-config-template.yml"
// GenericMCTemplate is the name of a MachineConfig template that can be fully configured by parameters
GenericMCTemplate = "generic-machine-config-template.yml"

// AWSPlatform value used to identify aws infrastructure
AWSPlatform = "aws"
// GCPPlatform value used to identify gcp infrastructure
GCPPlatform = "gcp"
// AzurePlatform value used to identify azure infrastructure
AzurePlatform = "azure"
// VspherePlatform value used to identify Vsphere infrastructure
VspherePlatform = "vsphere"

// ExpirationDockerfileLabel Expiration label in Dockerfile
ExpirationDockerfileLabel = `LABEL maintainer="mco-qe-team" quay.expires-after=24h`
Expand All @@ -48,4 +61,18 @@ const (

// DefaultExpectTimeout is the default timeout for expect operations
DefaultExpectTimeout = 10 * time.Second

// MachineAPINamespace is the MachineAPI namespace
MachineAPINamespace = "openshift-machine-api"

// We use full name to get machineset/machine xref: https://access.redhat.com/solutions/7040368
// MachineSetFullName is the machineset fully qualified name
MachineSetFullName = "machineset.machine.openshift.io"
// MachineFullName is the machine fully qualified name
MachineFullName = "machine.machine.openshift.io"

// MachineSetResource is the resource name for machinesets
MachineSetResource = "machinesets"
// ControlPlaneMachineSetResource is the resource name for controlplanemachinesets
ControlPlaneMachineSetResource = "controlplanemachinesets"
)
Loading