Skip to content

Commit

Permalink
cmd/contour: add InCluster and KubeConfig to config file
Browse files Browse the repository at this point in the history
To keep the linters happy, expose a few serveContext values via -c
configfile.

Signed-off-by: Dave Cheney <dave@cheney.net>
  • Loading branch information
davecheney committed Jul 19, 2019
1 parent 5e6249a commit bfb0441
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func registerServe(app *kingpin.Application) (*kingpin.CmdClause, *serveContext)
// however, as -c is a cli flag, we don't know its valye til cli flags
// have been parsed. To correct this ordering we assign a post parse
// action to -c, then parse cli flags twice (see main.main). On the second
// parse our action will return early, resulting in the precendence order
// parse our action will return early, resulting in the precedence order
// we want.
var (
configFile string
Expand All @@ -77,8 +77,8 @@ func registerServe(app *kingpin.Application) (*kingpin.CmdClause, *serveContext)
}
serve.Flag("config-path", "path to base configuration").Short('c').Action(parseConfig).ExistingFileVar(&configFile)

serve.Flag("incluster", "use in cluster configuration.").BoolVar(&ctx.inCluster)
serve.Flag("kubeconfig", "path to kubeconfig (if not in running inside a cluster)").Default(filepath.Join(os.Getenv("HOME"), ".kube", "config")).StringVar(&ctx.kubeconfig)
serve.Flag("incluster", "use in cluster configuration.").BoolVar(&ctx.InCluster)
serve.Flag("kubeconfig", "path to kubeconfig (if not in running inside a cluster)").Default(filepath.Join(os.Getenv("HOME"), ".kube", "config")).StringVar(&ctx.Kubeconfig)

serve.Flag("xds-address", "xDS gRPC API address").Default("127.0.0.1").StringVar(&ctx.xdsAddr)
serve.Flag("xds-port", "xDS gRPC API port").Default("8001").IntVar(&ctx.xdsPort)
Expand Down Expand Up @@ -113,8 +113,8 @@ func registerServe(app *kingpin.Application) (*kingpin.CmdClause, *serveContext)

type serveContext struct {
// contour's kubernetes client parameters
inCluster bool
kubeconfig string
InCluster bool `json:"incluster"`
Kubeconfig string `json:"kubeconfig"`

// contour's xds service parameters
xdsAddr string
Expand Down Expand Up @@ -201,7 +201,7 @@ func (ctx *serveContext) ingressRouteRootNamespaces() []string {
func doServe(log logrus.FieldLogger, ctx *serveContext) error {

// step 1. establish k8s client connection
client, contourClient := newClient(ctx.kubeconfig, ctx.inCluster)
client, contourClient := newClient(ctx.Kubeconfig, ctx.InCluster)

// step 2. create informers
// note: 0 means resync timers are disabled
Expand Down

0 comments on commit bfb0441

Please sign in to comment.