sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/v4/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  package v4
    18  
    19  import (
    20  	"sigs.k8s.io/kubebuilder/v3/pkg/config"
    21  	cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
    22  	"sigs.k8s.io/kubebuilder/v3/pkg/model/stage"
    23  	"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
    24  	"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
    25  )
    26  
    27  const pluginName = "base." + golang.DefaultNameQualifier
    28  
    29  var (
    30  	pluginVersion            = plugin.Version{Number: 4, Stage: stage.Stable}
    31  	supportedProjectVersions = []config.Version{cfgv3.Version}
    32  )
    33  
    34  var _ plugin.Full = Plugin{}
    35  
    36  // Plugin implements the plugin.Full interface
    37  type Plugin struct {
    38  	initSubcommand
    39  	createAPISubcommand
    40  	createWebhookSubcommand
    41  	editSubcommand
    42  }
    43  
    44  // Name returns the name of the plugin
    45  func (Plugin) Name() string { return pluginName }
    46  
    47  // Version returns the version of the plugin
    48  func (Plugin) Version() plugin.Version { return pluginVersion }
    49  
    50  // SupportedProjectVersions returns an array with all project versions supported by the plugin
    51  func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
    52  
    53  // GetInitSubcommand will return the subcommand which is responsible for initializing and common scaffolding
    54  func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
    55  
    56  // GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
    57  func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
    58  
    59  // GetCreateWebhookSubcommand will return the subcommand which is responsible for scaffolding webhooks
    60  func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
    61  	return &p.createWebhookSubcommand
    62  }
    63  
    64  // GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project
    65  func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }
    66  
    67  func (p Plugin) DeprecationWarning() string {
    68  	return ""
    69  }