sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/deploy-image/v1alpha1/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 v1alpha1
    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 = "deploy-image." + golang.DefaultNameQualifier
    28  
    29  var (
    30  	pluginVersion            = plugin.Version{Number: 1, Stage: stage.Alpha}
    31  	supportedProjectVersions = []config.Version{cfgv3.Version}
    32  	pluginKey                = plugin.KeyFor(Plugin{})
    33  )
    34  
    35  var _ plugin.CreateAPI = Plugin{}
    36  
    37  // Plugin implements the plugin.Full interface
    38  type Plugin struct {
    39  	createAPISubcommand
    40  }
    41  
    42  // Name returns the name of the plugin
    43  func (Plugin) Name() string { return pluginName }
    44  
    45  // Version returns the version of the plugin
    46  func (Plugin) Version() plugin.Version { return pluginVersion }
    47  
    48  // SupportedProjectVersions returns an array with all project versions supported by the plugin
    49  func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
    50  
    51  // GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
    52  func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
    53  
    54  type PluginConfig struct {
    55  	Resources []ResourceData `json:"resources,omitempty"`
    56  }
    57  
    58  type ResourceData struct {
    59  	Group   string  `json:"group,omitempty"`
    60  	Domain  string  `json:"domain,omitempty"`
    61  	Version string  `json:"version"`
    62  	Kind    string  `json:"kind"`
    63  	Options options `json:"options,omitempty"`
    64  }
    65  
    66  type options struct {
    67  	Image            string `json:"image,omitempty"`
    68  	ContainerCommand string `json:"containerCommand,omitempty"`
    69  	ContainerPort    string `json:"containerPort,omitempty"`
    70  	RunAsUser        string `json:"runAsUser,omitempty"`
    71  }
    72  
    73  func (p Plugin) DeprecationWarning() string {
    74  	return ""
    75  }