• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubevirt / hyperconverged-cluster-operator / 17315172645

29 Aug 2025 05:05AM UTC coverage: 72.24% (+0.02%) from 72.217%
17315172645

Pull #3735

github

web-flow
Bump AAQ to v1.3.1

Signed-off-by: HCO Bump Bot <noreply@github.com>
Pull Request #3735: [release-1.14] Bump AAQ to v1.3.1

6464 of 8948 relevant lines covered (72.24%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.14
/controllers/operands/quickStart.go
1
package operands
2

3
import (
4
        "errors"
5
        "os"
6
        filepath "path/filepath"
7
        "reflect"
8
        "strings"
9

10
        log "github.com/go-logr/logr"
11
        consolev1 "github.com/openshift/api/console/v1"
12
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
        "k8s.io/apimachinery/pkg/runtime"
14
        "sigs.k8s.io/controller-runtime/pkg/client"
15

16
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
17
        "github.com/kubevirt/hyperconverged-cluster-operator/controllers/common"
18
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
19
)
20

21
// ConsoleQuickStart resources are a short user guids
22
const (
23
        quickStartManifestLocationVarName = "QUICK_START_FILES_LOCATION"
24
        quickStartDefaultManifestLocation = "./quickStart"
25
)
26

27
var quickstartNames []string
28

29
func newQuickStartHandler(Client client.Client, Scheme *runtime.Scheme, required *consolev1.ConsoleQuickStart) Operand {
1✔
30
        h := &genericOperand{
1✔
31
                Client: Client,
1✔
32
                Scheme: Scheme,
1✔
33
                crType: "ConsoleQuickStart",
1✔
34
                hooks:  &qsHooks{required: required},
1✔
35
        }
1✔
36

1✔
37
        return h
1✔
38
}
1✔
39

40
type qsHooks struct {
41
        required *consolev1.ConsoleQuickStart
42
}
43

44
func (h qsHooks) getFullCr(_ *hcov1beta1.HyperConverged) (client.Object, error) {
1✔
45
        return h.required.DeepCopy(), nil
1✔
46
}
1✔
47

48
func (h qsHooks) getEmptyCr() client.Object {
1✔
49
        return &consolev1.ConsoleQuickStart{
1✔
50
                ObjectMeta: metav1.ObjectMeta{
1✔
51
                        Name: h.required.Name,
1✔
52
                },
1✔
53
        }
1✔
54
}
1✔
55

56
func (h qsHooks) updateCr(req *common.HcoRequest, Client client.Client, exists runtime.Object, _ runtime.Object) (bool, bool, error) {
1✔
57
        found, ok := exists.(*consolev1.ConsoleQuickStart)
1✔
58

1✔
59
        if !ok {
1✔
60
                return false, false, errors.New("can't convert to ConsoleQuickStart")
×
61
        }
×
62

63
        if !reflect.DeepEqual(h.required.Spec, found.Spec) ||
1✔
64
                !util.CompareLabels(h.required, found) {
2✔
65
                if req.HCOTriggered {
2✔
66
                        req.Logger.Info("Updating existing ConsoleQuickStart's Spec to new opinionated values", "name", h.required.Name)
1✔
67
                } else {
1✔
68
                        req.Logger.Info("Reconciling an externally updated ConsoleQuickStart's Spec to its opinionated values", "name", h.required.Name)
×
69
                }
×
70
                util.MergeLabels(&h.required.ObjectMeta, &found.ObjectMeta)
1✔
71
                h.required.Spec.DeepCopyInto(&found.Spec)
1✔
72
                err := Client.Update(req.Ctx, found)
1✔
73
                if err != nil {
1✔
74
                        return false, false, err
×
75
                }
×
76
                return true, !req.HCOTriggered, nil
1✔
77
        }
78

79
        return false, false, nil
×
80
}
81

82
func (qsHooks) justBeforeComplete(_ *common.HcoRequest) { /* no implementation */ }
1✔
83

84
func getQuickStartHandlers(logger log.Logger, Client client.Client, Scheme *runtime.Scheme, hc *hcov1beta1.HyperConverged) ([]Operand, error) {
1✔
85
        filesLocation := util.GetManifestDirPath(quickStartManifestLocationVarName, quickStartDefaultManifestLocation)
1✔
86

1✔
87
        err := util.ValidateManifestDir(filesLocation)
1✔
88
        if err != nil {
2✔
89
                return nil, errors.Unwrap(err) // if not wrapped, then it's not an error that stops processing, and it return nil
1✔
90
        }
1✔
91

92
        return createQuickstartHandlersFromFiles(logger, Client, Scheme, hc, filesLocation)
1✔
93
}
94

95
func createQuickstartHandlersFromFiles(logger log.Logger, Client client.Client, Scheme *runtime.Scheme, hc *hcov1beta1.HyperConverged, filesLocation string) ([]Operand, error) {
1✔
96
        var handlers []Operand
1✔
97
        quickstartNames = []string{}
1✔
98

1✔
99
        err := filepath.Walk(filesLocation, func(path string, info os.FileInfo, err error) error {
2✔
100
                if err != nil {
1✔
101
                        return err
×
102
                }
×
103

104
                qs, err := processQuickstartFile(path, info, logger, hc, Client, Scheme)
1✔
105
                if err != nil {
1✔
106
                        return err
×
107
                }
×
108

109
                if qs != nil {
2✔
110
                        handlers = append(handlers, qs)
1✔
111
                }
1✔
112

113
                return nil
1✔
114
        })
115

116
        return handlers, err
1✔
117
}
118

119
func processQuickstartFile(path string, info os.FileInfo, logger log.Logger, hc *hcov1beta1.HyperConverged, Client client.Client, Scheme *runtime.Scheme) (Operand, error) {
1✔
120
        if !info.IsDir() && strings.HasSuffix(info.Name(), ".yaml") {
2✔
121
                file, err := os.Open(path)
1✔
122
                if err != nil {
1✔
123
                        logger.Error(err, "Can't open the quickStart yaml file", "file name", path)
×
124
                        return nil, err
×
125
                }
×
126

127
                qs := &consolev1.ConsoleQuickStart{}
1✔
128
                err = util.UnmarshalYamlFileToObject(file, qs)
1✔
129
                if err != nil {
1✔
130
                        logger.Error(err, "Can't generate a ConsoleQuickStart object from yaml file", "file name", path)
×
131
                } else {
1✔
132
                        qs.Labels = getLabels(hc, util.AppComponentCompute)
1✔
133
                        quickstartNames = append(quickstartNames, qs.Name)
1✔
134
                        return newQuickStartHandler(Client, Scheme, qs), nil
1✔
135
                }
1✔
136
        }
137
        return nil, nil
1✔
138
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc