sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/declarative/v1/plugin.go (about)

     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  // Deprecated: The declarative plugin has been deprecated.
    18  // The Declarative plugin is an implementation derived from the kubebuilder-declarative-pattern project.
    19  // As the project maintainers possess the most comprehensive knowledge about its changes and Kubebuilder
    20  // allows the creation of custom plugins using its library, it has been decided that this plugin will be
    21  // better maintained within the kubebuilder-declarative-pattern project
    22  // itself, which falls under its domain of responsibility. This decision aims to improve the maintainability
    23  // of both the plugin and Kubebuilder, ultimately providing an enhanced user experience.
    24  // To follow up on this work, please refer to the Issue #293:
    25  // https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/issues/293.
    26  package v1
    27  
    28  import (
    29  	"sigs.k8s.io/kubebuilder/v3/pkg/config"
    30  	cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
    31  	cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
    32  	"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
    33  	"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
    34  	"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
    35  )
    36  
    37  const pluginName = "declarative." + golang.DefaultNameQualifier
    38  
    39  var (
    40  	pluginVersion            = plugin.Version{Number: 1}
    41  	supportedProjectVersions = []config.Version{cfgv2.Version, cfgv3.Version}
    42  	pluginKey                = plugin.KeyFor(Plugin{})
    43  )
    44  
    45  var _ plugin.CreateAPI = Plugin{}
    46  
    47  // Plugin implements the plugin.Full interface
    48  type Plugin struct {
    49  	initSubcommand
    50  	createAPISubcommand
    51  }
    52  
    53  // Name returns the name of the plugin
    54  func (Plugin) Name() string { return pluginName }
    55  
    56  // Version returns the version of the plugin
    57  func (Plugin) Version() plugin.Version { return pluginVersion }
    58  
    59  // SupportedProjectVersions returns an array with all project versions supported by the plugin
    60  func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
    61  
    62  // GetInitSubcommand will return the subcommand which is responsible for initializing and common scaffolding
    63  func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
    64  
    65  // GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
    66  func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
    67  
    68  type pluginConfig struct {
    69  	Resources []resource.GVK `json:"resources,omitempty"`
    70  }
    71  
    72  func (p Plugin) DeprecationWarning() string {
    73  	return "The declarative plugin has been deprecated. \n" +
    74  		"The Declarative plugin is an implementation derived from the kubebuilder-declarative-pattern project. " +
    75  		"As the project maintainers possess the most comprehensive knowledge about its changes and Kubebuilder " +
    76  		"allows the creation of custom plugins using its library, it has been decided that this plugin will be  " +
    77  		"better maintained within the kubebuilder-declarative-pattern project " +
    78  		"itself, which falls under its domain of responsibility. This decision aims to improve the maintainability " +
    79  		"of both the plugin and Kubebuilder, ultimately providing an enhanced user experience." +
    80  		"To follow up on this work, please refer to the Issue #293: " +
    81  		"https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/issues/293."
    82  }