|
| 1 | +/* |
| 2 | +Copyright 2017 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 main |
| 18 | + |
| 19 | +import ( |
| 20 | + "flag" |
| 21 | + "fmt" |
| 22 | + "os" |
| 23 | + |
| 24 | + "github.com/kubernetes-csi/drivers/pkg/cfs" |
| 25 | + "github.com/spf13/cobra" |
| 26 | +) |
| 27 | + |
| 28 | +var ( |
| 29 | + endpoint string |
| 30 | + nodeID string |
| 31 | +) |
| 32 | + |
| 33 | +func init() { |
| 34 | + flag.Set("logtostderr", "true") |
| 35 | +} |
| 36 | + |
| 37 | +func main() { |
| 38 | + |
| 39 | + flag.CommandLine.Parse([]string{}) |
| 40 | + |
| 41 | + cmd := &cobra.Command{ |
| 42 | + Use: "CFS", |
| 43 | + Short: "CSI based CFS driver", |
| 44 | + Run: func(cmd *cobra.Command, args []string) { |
| 45 | + handle() |
| 46 | + }, |
| 47 | + } |
| 48 | + |
| 49 | + cmd.Flags().AddGoFlagSet(flag.CommandLine) |
| 50 | + |
| 51 | + cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "node id") |
| 52 | + cmd.MarkPersistentFlagRequired("nodeid") |
| 53 | + |
| 54 | + cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "", "CSI endpoint") |
| 55 | + cmd.MarkPersistentFlagRequired("endpoint") |
| 56 | + |
| 57 | + if err := cmd.Execute(); err != nil { |
| 58 | + fmt.Fprintf(os.Stderr, "%s", err.Error()) |
| 59 | + os.Exit(1) |
| 60 | + } |
| 61 | + |
| 62 | + os.Exit(0) |
| 63 | +} |
| 64 | + |
| 65 | +func handle() { |
| 66 | + d := cfs.NewDriver(nodeID, endpoint) |
| 67 | + d.Run() |
| 68 | +} |
0 commit comments