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

kubernetes-sigs / kubebuilder / 20693555814

04 Jan 2026 01:20PM UTC coverage: 67.516% (-3.8%) from 71.354%
20693555814

Pull #5352

github

camilamacedo86
Add delete api and delete webhook commands

Add delete functionality to remove APIs and webhooks from projects.
Users can now clean up scaffolded resources with proper validation.
Pull Request #5352: WIP ✨ Add delete api and delete webhook commands

315 of 960 new or added lines in 16 files covered. (32.81%)

19 existing lines in 3 files now uncovered.

6495 of 9620 relevant lines covered (67.52%)

27.24 hits per line

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

29.55
/pkg/plugins/optional/autoupdate/v1alpha/edit.go
1
/*
2
Copyright 2025 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 v1alpha
18

19
import (
20
        "fmt"
21
        log "log/slog"
22

23
        "github.com/spf13/pflag"
24

25
        "sigs.k8s.io/kubebuilder/v4/pkg/config"
26
        "sigs.k8s.io/kubebuilder/v4/pkg/machinery"
27
        "sigs.k8s.io/kubebuilder/v4/pkg/plugin"
28
        "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/autoupdate/v1alpha/scaffolds"
29
)
30

31
var _ plugin.EditSubcommand = &editSubcommand{}
32

33
type editSubcommand struct {
34
        config      config.Config
35
        useGHModels bool
36
}
37

38
func (p *editSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
×
UNCOV
39
        subcmdMeta.Description = metaDataDescription
×
UNCOV
40

×
41
        subcmdMeta.Examples = fmt.Sprintf(`  # Edit a common project with this plugin
×
42
  %[1]s edit --plugins=%[2]s
×
43

×
44
  # Edit a common project with GitHub Models enabled (requires repo permissions)
×
45
  %[1]s edit --plugins=%[2]s --use-gh-models
×
46
`, cliMeta.CommandName, plugin.KeyFor(Plugin{}))
×
47
}
×
48

49
func (p *editSubcommand) BindFlags(fs *pflag.FlagSet) {
×
50
        fs.BoolVar(&p.useGHModels, "use-gh-models", false,
×
UNCOV
51
                "enable GitHub Models AI summary in the scaffolded workflow (requires GitHub Models permissions)")
×
52
}
×
53

54
func (p *editSubcommand) InjectConfig(c config.Config) error {
2✔
55
        p.config = c
2✔
56
        return nil
2✔
57
}
2✔
58

59
func (p *editSubcommand) PreScaffold(machinery.Filesystem) error {
2✔
60
        if len(p.config.GetCliVersion()) == 0 {
3✔
61
                return fmt.Errorf(
1✔
62
                        "you must manually upgrade your project to a version that records the CLI version in PROJECT (`cliVersion`) " +
1✔
63
                                "to allow the `alpha update` command to work properly before using this plugin.\n" +
1✔
64
                                "More info: https://book.kubebuilder.io/migrations",
1✔
65
                )
1✔
66
        }
1✔
67
        return nil
1✔
68
}
69

UNCOV
70
func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error {
×
UNCOV
71
        if err := insertPluginMetaToConfig(p.config, PluginConfig{UseGHModels: p.useGHModels}); err != nil {
×
UNCOV
72
                return fmt.Errorf("error inserting project plugin meta to configuration: %w", err)
×
UNCOV
73
        }
×
74

75
        scaffolder := scaffolds.NewInitScaffolder(p.useGHModels)
×
76
        scaffolder.InjectFS(fs)
×
77
        if err := scaffolder.Scaffold(); err != nil {
×
78
                return fmt.Errorf("error scaffolding edit subcommand: %w", err)
×
79
        }
×
80

81
        return nil
×
82
}
83

84
func (p *editSubcommand) PostScaffold() error {
×
85
        // Inform users about GitHub Models if they didn't enable it
×
86
        if !p.useGHModels {
×
87
                log.Info("Consider enabling GitHub Models to get an AI summary to help with the update")
×
UNCOV
88
                log.Info("Use the --use-gh-models flag if your project/organization has permission to use GitHub Models")
×
89
        }
×
UNCOV
90
        return nil
×
91
}
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

© 2026 Coveralls, Inc