sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/v2/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  //go:deprecated This package has been deprecated
    18  package v2
    19  
    20  import (
    21  	"sigs.k8s.io/kubebuilder/v3/pkg/config"
    22  	cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
    23  	cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
    24  	"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
    25  	"sigs.k8s.io/kubebuilder/v3/pkg/plugins"
    26  )
    27  
    28  const pluginName = "go." + plugins.DefaultNameQualifier
    29  
    30  var (
    31  	pluginVersion            = plugin.Version{Number: 2}
    32  	supportedProjectVersions = []config.Version{cfgv2.Version, cfgv3.Version}
    33  )
    34  
    35  var _ plugin.Full = Plugin{}
    36  
    37  // Plugin implements the plugin.Full interface
    38  type Plugin struct {
    39  	initSubcommand
    40  	createAPISubcommand
    41  	createWebhookSubcommand
    42  	editSubcommand
    43  }
    44  
    45  // Name returns the name of the plugin
    46  func (Plugin) Name() string { return pluginName }
    47  
    48  // Version returns the version of the plugin
    49  func (Plugin) Version() plugin.Version { return pluginVersion }
    50  
    51  // SupportedProjectVersions returns an array with all project versions supported by the plugin
    52  func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
    53  
    54  // GetInitSubcommand will return the subcommand which is responsible for initializing and common scaffolding
    55  func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
    56  
    57  // GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
    58  func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
    59  
    60  // GetCreateWebhookSubcommand will return the subcommand which is responsible for scaffolding webhooks
    61  func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
    62  	return &p.createWebhookSubcommand
    63  }
    64  
    65  // GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project
    66  func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }
    67  
    68  func (p Plugin) DeprecationWarning() string {
    69  	return "This version is deprecated and is no longer scaffolded by default since `28 Apr 2021`." +
    70  		"The `go/v2` plugin cannot scaffold projects in which CRDs and/or Webhooks have a `v1` API version." +
    71  		"Be aware that v1beta1 API for CRDs and Webhooks was deprecated on Kubernetes 1.16 and are" +
    72  		"removed as of the Kubernetes 1.22 release. Therefore, since this plugin cannot produce projects that" +
    73  		"work on Kubernetes versions >= 1.22, it is recommended to upgrade your project " +
    74  		"to the latest versions available."
    75  }