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

kubernetes-sigs / kubebuilder / 13777088765

10 Mar 2025 11:49PM CUT coverage: 74.078%. First build
13777088765

Pull #4600

github

web-flow
:seedling: Bump sigs.k8s.io/controller-runtime in /testdata/project-v4

Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.20.2 to 0.20.3.
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.20.2...v0.20.3)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4600: :seedling: Bump sigs.k8s.io/controller-runtime from 0.20.2 to 0.20.3 in /testdata/project-v4

2309 of 3117 relevant lines covered (74.08%)

14.19 hits per line

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

47.92
/pkg/plugins/golang/options.go
1
/*
2
Copyright 2022 The Kubernetes Authors.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package golang
18

19
import (
20
        "path"
21

22
        "sigs.k8s.io/kubebuilder/v4/pkg/config"
23
        "sigs.k8s.io/kubebuilder/v4/pkg/model/resource"
24
)
25

26
var (
27
        coreGroups = map[string]string{
28
                "admission":             "k8s.io",
29
                "admissionregistration": "k8s.io",
30
                "apps":                  "",
31
                "auditregistration":     "k8s.io",
32
                "apiextensions":         "k8s.io",
33
                "authentication":        "k8s.io",
34
                "authorization":         "k8s.io",
35
                "autoscaling":           "",
36
                "batch":                 "",
37
                "certificates":          "k8s.io",
38
                "coordination":          "k8s.io",
39
                "core":                  "",
40
                "events":                "k8s.io",
41
                "extensions":            "",
42
                "imagepolicy":           "k8s.io",
43
                "networking":            "k8s.io",
44
                "node":                  "k8s.io",
45
                "metrics":               "k8s.io",
46
                "policy":                "",
47
                "rbac.authorization":    "k8s.io",
48
                "scheduling":            "k8s.io",
49
                "setting":               "k8s.io",
50
                "storage":               "k8s.io",
51
        }
52
)
53

54
// Options contains the information required to build a new resource.Resource.
55
type Options struct {
56
        // Plural is the resource's kind plural form.
57
        Plural string
58

59
        // ExternalAPIPath allows to inform a path for APIs not defined in the project
60
        ExternalAPIPath string
61

62
        // ExternalAPIPath allows to inform the resource domain to build the Qualified Group
63
        // to generate the RBAC markers
64
        ExternalAPIDomain string
65

66
        // Namespaced is true if the resource should be namespaced.
67
        Namespaced bool
68

69
        // Flags that define which parts should be scaffolded
70
        DoAPI        bool
71
        DoController bool
72
        DoDefaulting bool
73
        DoValidation bool
74
        DoConversion bool
75

76
        // Spoke versions for conversion webhook
77
        Spoke []string
78
}
79

80
// UpdateResource updates the provided resource with the options
81
func (opts Options) UpdateResource(res *resource.Resource, c config.Config) {
14✔
82
        if opts.Plural != "" {
16✔
83
                res.Plural = opts.Plural
2✔
84
        }
2✔
85

86
        if opts.DoAPI {
14✔
87
                res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup())
×
88

×
89
                res.API = &resource.API{
×
90
                        CRDVersion: "v1",
×
91
                        Namespaced: opts.Namespaced,
×
92
                }
×
93

×
94
        }
×
95

96
        if opts.DoController {
16✔
97
                res.Controller = true
2✔
98
        }
2✔
99

100
        if opts.DoDefaulting || opts.DoValidation || opts.DoConversion {
14✔
101
                res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup())
×
102

×
103
                res.Webhooks.WebhookVersion = "v1"
×
104
                if opts.DoDefaulting {
×
105
                        res.Webhooks.Defaulting = true
×
106
                }
×
107
                if opts.DoValidation {
×
108
                        res.Webhooks.Validation = true
×
109
                }
×
110
                if opts.DoConversion {
×
111
                        res.Webhooks.Conversion = true
×
112
                        res.Webhooks.Spoke = opts.Spoke
×
113
                }
×
114
        }
115

116
        if len(opts.ExternalAPIPath) > 0 {
14✔
117
                res.External = true
×
118
        }
×
119

120
        // domain and path may need to be changed in case we are referring to a builtin core resource:
121
        //  - Check if we are scaffolding the resource now           => project resource
122
        //  - Check if we already scaffolded the resource            => project resource
123
        //  - Check if the resource group is a well-known core group => builtin core resource
124
        //  - In any other case, default to                          => project resource
125
        if !opts.DoAPI {
28✔
126
                var alreadyHasAPI bool
14✔
127
                loadedRes, err := c.GetResource(res.GVK)
14✔
128
                alreadyHasAPI = err == nil && loadedRes.HasAPI()
14✔
129
                if !alreadyHasAPI {
28✔
130
                        if res.External {
14✔
131
                                res.Path = opts.ExternalAPIPath
×
132
                                res.Domain = opts.ExternalAPIDomain
×
133
                        } else {
14✔
134
                                // Handle core types
14✔
135
                                if domain, found := coreGroups[res.Group]; found {
22✔
136
                                        res.Core = true
8✔
137
                                        res.Domain = domain
8✔
138
                                        res.Path = path.Join("k8s.io", "api", res.Group, res.Version)
8✔
139
                                }
8✔
140
                        }
141
                }
142
        }
143
}
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