modulepackage
0.8.0
Repository: https://github.com/virtual-kubelet/node-cli.git
Documentation: pkg.go.dev
# README
Virtual-Kubelet CLI
This project provides a library for rapid prototyping of a virtual-kubelet node. It is not intended for production use and may have breaking changes, but takes as much as made sense from the old command line code from github.com/virtual-kubelet/virtual-kubelet.
Usage
package main
import (
"context"
"errors"
"github.com/sirupsen/logrus"
cli "github.com/virtual-kubelet/node-cli"
logruscli "github.com/virtual-kubelet/node-cli/logrus"
"github.com/virtual-kubelet/node-cli/provider"
"github.com/virtual-kubelet/virtual-kubelet/log"
logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus"
)
func main() {
ctx := cli.ContextWithCancelOnSignal(context.Background())
logger := logrus.StandardLogger()
log.L = logruslogger.FromLogrus(logrus.NewEntry(logger))
logConfig := &logruscli.Config{LogLevel: "info"}
node, err := cli.New(ctx,
cli.WithProvider("demo", func(cfg provider.InitConfig) (provider.Provider, error) {
return nil, errors.New("your implementation goes here")
}),
// Adds flags and parsing for using logrus as the configured logger
cli.WithPersistentFlags(logConfig.FlagSet()),
cli.WithPersistentPreRunCallback(func() error {
return logruscli.Configure(logConfig, logger)
}),
)
if err != nil {
panic(err)
}
// Args can be specified here, or os.Args[1:] will be used.
if err := node.Run(ctx); err != nil {
panic(err)
}
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package provider has the interfaces used by the the cli implementing a node.
# Functions
ContextWithCancelOnSignal returns a context which will be cancelled when receiving one of the passed in signals.
New creates a new command.
WithBaseOpts sets the base options used.
WithCLIBaseName sets the name of the command.
WithCLIVersion sets the version details for the `version` subcommand.
WithKubernetesNodeVersion sets the version of kubernetes this should report as to the Kubernetes API server.
WithPersistentFlagsAllows you to attach custom, persitent flags to the command.
WithPersistentPreRunCallback adds a callback which is called after flags are processed but before running the command or any sub-command.
WithProvider registers a provider which the cli can be initialized with.
# Type aliases
Option sets an option on the command.