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

kubernetes-sigs / kubebuilder / 20694092930

04 Jan 2026 02:06PM UTC coverage: 67.164% (-4.2%) from 71.354%
20694092930

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

341 of 1049 new or added lines in 18 files covered. (32.51%)

1 existing line in 1 file now uncovered.

6521 of 9709 relevant lines covered (67.16%)

27.1 hits per line

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

28.21
/pkg/plugins/external/delete_api.go
1
/*
2
Copyright 2026 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
//nolint:dupl
18
package external
19

20
import (
21
        "github.com/spf13/pflag"
22

23
        "sigs.k8s.io/kubebuilder/v4/pkg/config"
24
        "sigs.k8s.io/kubebuilder/v4/pkg/machinery"
25
        "sigs.k8s.io/kubebuilder/v4/pkg/model/resource"
26
        "sigs.k8s.io/kubebuilder/v4/pkg/plugin"
27
        "sigs.k8s.io/kubebuilder/v4/pkg/plugin/external"
28
)
29

30
var _ plugin.DeleteAPISubcommand = &deleteAPISubcommand{}
31

32
type deleteAPISubcommand struct {
33
        Path        string
34
        Args        []string
35
        pluginChain []string
36
        config      config.Config
37
}
38

39
// InjectConfig injects the project configuration so external plugins can read the PROJECT file.
NEW
40
func (p *deleteAPISubcommand) InjectConfig(c config.Config) error {
×
NEW
41
        p.config = c
×
NEW
42

×
NEW
43
        if c == nil {
×
NEW
44
                return nil
×
NEW
45
        }
×
46

NEW
47
        if chain := c.GetPluginChain(); len(chain) > 0 {
×
NEW
48
                p.pluginChain = append([]string(nil), chain...)
×
NEW
49
        }
×
50

NEW
51
        return nil
×
52
}
53

NEW
54
func (p *deleteAPISubcommand) SetPluginChain(chain []string) {
×
NEW
55
        if len(chain) == 0 {
×
NEW
56
                p.pluginChain = nil
×
NEW
57
                return
×
NEW
58
        }
×
59

NEW
60
        p.pluginChain = append([]string(nil), chain...)
×
61
}
62

NEW
63
func (p *deleteAPISubcommand) InjectResource(*resource.Resource) error {
×
NEW
64
        // Do nothing since resource flags are passed to the external plugin directly.
×
NEW
65
        return nil
×
NEW
66
}
×
67

NEW
68
func (p *deleteAPISubcommand) UpdateMetadata(_ plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
×
NEW
69
        setExternalPluginMetadata("delete api", p.Path, subcmdMeta)
×
NEW
70
}
×
71

NEW
72
func (p *deleteAPISubcommand) BindFlags(fs *pflag.FlagSet) {
×
NEW
73
        bindExternalPluginFlags(fs, "delete api", p.Path, p.Args)
×
NEW
74
}
×
75

76
func (p *deleteAPISubcommand) Scaffold(fs machinery.Filesystem) error {
1✔
77
        req := external.PluginRequest{
1✔
78
                APIVersion:  defaultAPIVersion,
1✔
79
                Command:     "delete api",
1✔
80
                Args:        p.Args,
1✔
81
                PluginChain: p.pluginChain,
1✔
82
        }
1✔
83

1✔
84
        err := handlePluginResponse(fs, req, p.Path, p.config)
1✔
85
        if err != nil {
1✔
NEW
86
                return err
×
NEW
87
        }
×
88

89
        return nil
1✔
90
}
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