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

kubernetes-sigs / kubebuilder / 21719734236

05 Feb 2026 04:30PM UTC coverage: 66.464% (-7.4%) from 73.91%
21719734236

Pull #5352

github

camilamacedo86
(chore) Add delete interface and implementation for all options

Add delete functionality to remove APIs and webhooks from projects.
Users can now clean up scaffolded resources.

Generated-by: Cursor/Claude
Pull Request #5352: WIP ✨ Added Delete API and implemented a unified interface across all commands and plugin options

402 of 1627 new or added lines in 24 files covered. (24.71%)

1 existing line in 1 file now uncovered.

7111 of 10699 relevant lines covered (66.46%)

37.75 hits per line

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

18.75
/pkg/plugins/optional/autoupdate/v1alpha/plugin.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
        "errors"
21
        "fmt"
22

23
        "sigs.k8s.io/kubebuilder/v4/pkg/config"
24
        cfgv3 "sigs.k8s.io/kubebuilder/v4/pkg/config/v3"
25
        "sigs.k8s.io/kubebuilder/v4/pkg/model/stage"
26
        "sigs.k8s.io/kubebuilder/v4/pkg/plugin"
27
        "sigs.k8s.io/kubebuilder/v4/pkg/plugins"
28
)
29

30
//nolint:lll
31
const metaDataDescription = `This plugin scaffolds a GitHub Action that helps you keep your project aligned with the latest Kubebuilder improvements. With a tiny amount of setup, you'll receive **automatic issue notifications** whenever a new Kubebuilder release is available. Each issue includes a **compare link** so you can open a Pull Request with one click and review the changes safely.
32

33
Under the hood, the workflow runs 'kubebuilder alpha update' using a **3-way merge strategy** to refresh your scaffold while preserving your code. It creates and pushes an update branch, then opens a GitHub **Issue** containing the PR URL you can use to review and merge.
34

35
### How to set it up
36

37
1) **Add the plugin**: Use the Kubebuilder CLI to scaffold the automation into your repo.
38
2) **Review the workflow**: The file '.github/workflows/auto_update.yml' runs on a schedule to check for updates.
39
3) **Permissions required** (via the built-in 'GITHUB_TOKEN'):
40
   - **contents: write** — needed to create and push the update branch.
41
   - **issues: write** — needed to create the tracking Issue with the PR link.
42
   - **models: read** (optional) — only required if using --use-gh-models flag for AI-generated summaries.
43
4) **Protect your branches**: Enable **branch protection rules** so automated changes **cannot** be pushed directly. All updates must go through a Pull Request for review.
44

45
### Optional: GitHub Models AI Summary
46

47
By default, the workflow does NOT use GitHub Models. To enable AI-generated summaries in GitHub issues:
48
  - Ensure your repository/organization has permissions to use GitHub Models.
49
  - Re-run: kubebuilder edit --plugins="autoupdate/v1-alpha" --use-gh-models
50

51
Without this flag, the workflow will still work but won't include AI summaries (avoiding 403 Forbidden errors).`
52

53
const pluginName = "autoupdate." + plugins.DefaultNameQualifier
54

55
var (
56
        pluginVersion            = plugin.Version{Number: 1, Stage: stage.Alpha}
57
        supportedProjectVersions = []config.Version{cfgv3.Version}
58
)
59

60
// Plugin implements the plugin.Full interface
61
type Plugin struct {
62
        editSubcommand
63
        initSubcommand
64
}
65

66
var (
67
        _ plugin.Init             = Plugin{}
68
        _ plugin.HasDeleteSupport = Plugin{}
69
)
70

71
// PluginConfig defines the structure that will be used to track the data
72
type PluginConfig struct {
73
        UseGHModels bool `json:"useGHModels,omitempty"`
74
}
75

76
// Name returns the name of the plugin
77
func (Plugin) Name() string { return pluginName }
12✔
78

79
// Version returns the version of the Helm plugin
80
func (Plugin) Version() plugin.Version { return pluginVersion }
18✔
81

82
// SupportedProjectVersions returns an array with all project versions supported by the plugin
83
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
1✔
84

85
// GetEditSubcommand will return the subcommand which is responsible for adding and/or edit a autoupdate
86
func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }
×
87

88
// GetInitSubcommand will return the subcommand which is responsible for init autoupdate plugin
89
func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
×
90

91
// SupportsDelete returns true indicating this plugin supports deletion via Edit --delete
NEW
92
func (Plugin) SupportsDelete() bool { return true }
×
93

94
// DeprecationWarning define the deprecation message or return empty when plugin is not deprecated
95
func (p Plugin) DeprecationWarning() string {
1✔
96
        return ""
1✔
97
}
1✔
98

99
// insertPluginMetaToConfig will insert the metadata to the plugin configuration
100
func insertPluginMetaToConfig(target config.Config, cfg PluginConfig) error {
×
101
        key := plugin.GetPluginKeyForConfig(target.GetPluginChain(), Plugin{})
×
102
        canonicalKey := plugin.KeyFor(Plugin{})
×
103

×
104
        if err := target.DecodePluginConfig(key, &cfg); err != nil {
×
105
                switch {
×
106
                case errors.As(err, &config.UnsupportedFieldError{}):
×
107
                        return nil
×
108
                case errors.As(err, &config.PluginKeyNotFoundError{}):
×
109
                        if key != canonicalKey {
×
110
                                if err2 := target.DecodePluginConfig(canonicalKey, &cfg); err2 != nil {
×
111
                                        if errors.As(err2, &config.UnsupportedFieldError{}) {
×
112
                                                return nil
×
113
                                        }
×
114
                                        if !errors.As(err2, &config.PluginKeyNotFoundError{}) {
×
115
                                                return fmt.Errorf("error decoding plugin configuration: %w", err2)
×
116
                                        }
×
117
                                }
118
                        }
119
                default:
×
120
                        return fmt.Errorf("error decoding plugin configuration: %w", err)
×
121
                }
122
        }
123

124
        if err := target.EncodePluginConfig(key, cfg); err != nil {
×
125
                return fmt.Errorf("error encoding plugin configuration: %w", err)
×
126
        }
×
127

128
        return nil
×
129
}
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