sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugin/plugin.go (about) 1 /* 2 Copyright 2020 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 plugin 18 19 import ( 20 "sigs.k8s.io/kubebuilder/v3/pkg/config" 21 ) 22 23 // Plugin is an interface that defines the common base for all plugins. 24 type Plugin interface { 25 // Name returns a DNS1123 label string identifying the plugin uniquely. This name should be fully-qualified, 26 // i.e. have a short prefix describing the plugin type (like a language) followed by a domain. 27 // For example, Kubebuilder's main plugin would return "go.kubebuilder.io". 28 Name() string 29 // Version returns the plugin's version. 30 // 31 // NOTE: this version is different from config version. 32 Version() Version 33 // SupportedProjectVersions lists all project configuration versions this plugin supports. 34 // The returned slice cannot be empty. 35 SupportedProjectVersions() []config.Version 36 } 37 38 // Deprecated is an interface that defines the messages for plugins that are deprecated. 39 type Deprecated interface { 40 // DeprecationWarning returns a string indicating a plugin is deprecated. 41 DeprecationWarning() string 42 } 43 44 // Init is an interface for plugins that provide an `init` subcommand. 45 type Init interface { 46 Plugin 47 // GetInitSubcommand returns the underlying InitSubcommand interface. 48 GetInitSubcommand() InitSubcommand 49 } 50 51 // CreateAPI is an interface for plugins that provide a `create api` subcommand. 52 type CreateAPI interface { 53 Plugin 54 // GetCreateAPISubcommand returns the underlying CreateAPISubcommand interface. 55 GetCreateAPISubcommand() CreateAPISubcommand 56 } 57 58 // CreateWebhook is an interface for plugins that provide a `create webhook` subcommand. 59 type CreateWebhook interface { 60 Plugin 61 // GetCreateWebhookSubcommand returns the underlying CreateWebhookSubcommand interface. 62 GetCreateWebhookSubcommand() CreateWebhookSubcommand 63 } 64 65 // Edit is an interface for plugins that provide a `edit` subcommand. 66 type Edit interface { 67 Plugin 68 // GetEditSubcommand returns the underlying EditSubcommand interface. 69 GetEditSubcommand() EditSubcommand 70 } 71 72 // Full is an interface for plugins that provide `init`, `create api`, `create webhook` and `edit` subcommands. 73 type Full interface { 74 Init 75 CreateAPI 76 CreateWebhook 77 Edit 78 } 79 80 // Bundle allows to group plugins under a single key. 81 type Bundle interface { 82 Plugin 83 // Plugins returns a list of the bundled plugins. 84 // The returned list should be flattened, i.e., no plugin bundles should be part of this list. 85 Plugins() []Plugin 86 }