...

Source file src/k8s.io/apiextensions-apiserver/pkg/cmd/server/server.go

Documentation: k8s.io/apiextensions-apiserver/pkg/cmd/server

     1  /*
     2  Copyright 2018 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 server
    18  
    19  import (
    20  	"io"
    21  
    22  	"github.com/spf13/cobra"
    23  
    24  	"k8s.io/apiextensions-apiserver/pkg/cmd/server/options"
    25  	genericapiserver "k8s.io/apiserver/pkg/server"
    26  )
    27  
    28  func NewServerCommand(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
    29  	o := options.NewCustomResourceDefinitionsServerOptions(out, errOut)
    30  
    31  	cmd := &cobra.Command{
    32  		Short: "Launch an API extensions API server",
    33  		Long:  "Launch an API extensions API server",
    34  		RunE: func(c *cobra.Command, args []string) error {
    35  			if err := o.Complete(); err != nil {
    36  				return err
    37  			}
    38  			if err := o.Validate(); err != nil {
    39  				return err
    40  			}
    41  			if err := Run(o, stopCh); err != nil {
    42  				return err
    43  			}
    44  			return nil
    45  		},
    46  	}
    47  
    48  	fs := cmd.Flags()
    49  	o.AddFlags(fs)
    50  	return cmd
    51  }
    52  
    53  func Run(o *options.CustomResourceDefinitionsServerOptions, stopCh <-chan struct{}) error {
    54  	config, err := o.Config()
    55  	if err != nil {
    56  		return err
    57  	}
    58  
    59  	server, err := config.Complete().New(genericapiserver.NewEmptyDelegate())
    60  	if err != nil {
    61  		return err
    62  	}
    63  	return server.GenericAPIServer.PrepareRun().Run(stopCh)
    64  }
    65  

View as plain text