本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/templates.LongDesc函数的典型用法代码示例。如果您正苦于以下问题:Golang LongDesc函数的具体用法?Golang LongDesc怎么用?Golang LongDesc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LongDesc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewCommandTop
func NewCommandTop(name, fullName string, f *clientcmd.Factory, out, errOut io.Writer) *cobra.Command {
// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: name,
Short: "Show usage statistics of resources on the server",
Long: topLong,
Run: cmdutil.DefaultSubCommandRun(errOut),
}
cmds.AddCommand(NewCmdTopImages(f, fullName, TopImagesRecommendedName, out))
cmds.AddCommand(NewCmdTopImageStreams(f, fullName, TopImageStreamsRecommendedName, out))
cmdTopNode := kcmd.NewCmdTopNode(f.Factory, out)
cmdTopNode.Long = templates.LongDesc(cmdTopNode.Long)
cmdTopNode.Example = templates.Examples(cmdTopNode.Example)
cmdTopPod := kcmd.NewCmdTopPod(f.Factory, out)
cmdTopPod.Long = templates.LongDesc(cmdTopPod.Long)
cmdTopPod.Example = templates.Examples(cmdTopPod.Example)
cmds.AddCommand(cmdTopNode)
cmds.AddCommand(cmdTopPod)
return cmds
}
示例2:
// NewAppRecommendedCommandName is the recommended command name.
const NewAppRecommendedCommandName = "new-app"
type usage interface {
UsageError(baseName string) string
}
var (
newAppLong = templates.LongDesc(`
Create a new application by specifying source code, templates, and/or images
This command will try to build up the components of an application using images, templates,
or code that has a public repository. It will lookup the images on the local Docker installation
(if available), a Docker registry, an integrated image stream, or stored templates.
If you specify a source code URL, it will set up a build that takes your source code and converts
it into an image that can run inside of a pod. Local source must be in a git repository that has a
remote repository that the server can see. The images will be deployed via a deployment
configuration, and a service will be connected to the first public port of the app. You may either specify
components using the various existing flags or let %[2]s autodetect what kind of components
you have provided.
If you provide source code, a new build will be automatically triggered.
You can use '%[1]s status' to check the progress.`)
newAppExample = templates.Examples(`
# List all local templates and image streams that can be used to create an app
%[1]s %[2]s --list
# Create an application based on the source code in the current git repository (with a public remote)
# and a Docker image
%[1]s %[2]s . --docker-image=repo/langimage
示例3:
"github.com/spf13/cobra"
kapi "k8s.io/kubernetes/pkg/api"
kcmd "k8s.io/kubernetes/pkg/kubectl/cmd"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"github.com/openshift/origin/pkg/cmd/templates"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
var (
exposeLong = templates.LongDesc(`
Expose containers internally as services or externally via routes
There is also the ability to expose a deployment configuration, replication controller, service, or pod
as a new service on a specified port. If no labels are specified, the new object will re-use the
labels from the object it exposes.`)
exposeExample = templates.Examples(`
# Create a route based on service nginx. The new route will re-use nginx's labels
%[1]s expose service nginx
# Create a route and specify your own label and route name
%[1]s expose service nginx -l name=myroute --name=fromdowntown
# Create a route and specify a hostname
%[1]s expose service nginx --hostname=www.example.com
# Expose a deployment configuration as a service and use the specified port
%[1]s expose dc ruby-hello-world --port=8080
示例4:
const (
// RsyncRecommendedName is the recommended name for the rsync command
RsyncRecommendedName = "rsync"
noRsyncUnixWarning = "WARNING: rsync command not found in path. Please use your package manager to install it.\n"
noRsyncWindowsWarning = "WARNING: rsync command not found in path. Download cwRsync for Windows and add it to your PATH.\n"
)
var (
rsyncLong = templates.LongDesc(`
Copy local files to or from a pod container
This command will copy local files to or from a remote container.
It only copies the changed files using the rsync command from your OS.
To ensure optimum performance, install rsync locally. In UNIX systems,
use your package manager. In Windows, install cwRsync from
https://www.itefix.net/cwrsync.
If no container is specified, the first container of the pod is used
for the copy.`)
rsyncExample = templates.Examples(`
# Synchronize a local directory with a pod directory
%[1]s ./local/dir/ POD:/remote/dir
# Synchronize a pod directory with a local directory
%[1]s POD:/remote/dir/ ./local/dir`)
)
// copyStrategy
示例5:
observeLong = templates.LongDesc(`
Observe changes to resources and take action on them
This command assists in building scripted reactions to changes that occur in
Kubernetes or OpenShift resources. This is frequently referred to as a
'controller' in Kubernetes and acts to ensure particular conditions are
maintained. On startup, observe will list all of the resources of a
particular type and execute the provided script on each one. Observe watches
the server for changes, and will reexecute the script for each update.
Observe works best for problems of the form "for every resource X, make sure
Y is true". Some examples of ways observe can be used include:
* Ensure every namespace has a quota or limit range object
* Ensure every service is registered in DNS by making calls to a DNS API
* Send an email alert whenever a node reports 'NotReady'
* Watch for the 'FailedScheduling' event and write an IRC message
* Dynamically provision persistent volumes when a new PVC is created
* Delete pods that have reached successful completion after a period of time.
The simplest pattern is maintaining an invariant on an object - for instance,
"every namespace should have an annotation that indicates its owner". If the
object is deleted no reaction is necessary. A variation on that pattern is
creating another object: "every namespace should have a quota object based
on the resources allowed for an owner".
$ cat set_owner.sh
#!/bin/sh
if [[ "$(%[1]s get namespace "$1" --template='{{ .metadata.annotations.owner }}')" == "" ]]; then
%[1]s annotate namespace "$1" owner=bob
fi
$ %[1]s observe namespaces -- ./set_owner.sh
The set_owner.sh script is invoked with a single argument (the namespace name)
for each namespace. This simple script ensures that any user without the
"owner" annotation gets one set, but preserves any existing value.
The next common of controller pattern is provisioning - making changes in an
external system to match the state of a Kubernetes resource. These scripts need
to account for deletions that may take place while the observe command is not
running. You can provide the list of known objects via the --names command,
which should return a newline-delimited list of names or namespace/name pairs.
Your command will be invoked whenever observe checks the latest state on the
server - any resources returned by --names that are not found on the server
will be passed to your --delete command.
For example, you may wish to ensure that every node that is added to Kubernetes
is added to your cluster inventory along with its IP:
$ cat add_to_inventory.sh
#!/bin/sh
echo "$1 $2" >> inventory
sort -u inventory -o inventory
$ cat remove_from_inventory.sh
#!/bin/sh
grep -vE "^$1 " inventory > /tmp/newinventory
mv -f /tmp/newinventory inventory
$ cat known_nodes.sh
#!/bin/sh
touch inventory
cut -f 1-1 -d ' ' inventory
$ %[1]s observe nodes -a '{ .status.addresses[0].address }' \
--names ./known_nodes.sh \
--delete ./remove_from_inventory.sh \
-- ./add_to_inventory.sh
If you stop the observe command and then delete a node, when you launch observe
again the contents of inventory will be compared to the list of nodes from the
server, and any node in the inventory file that no longer exists will trigger
a call to remove_from_inventory.sh with the name of the node.
Important: when handling deletes, the previous state of the object may not be
available and only the name/namespace of the object will be passed to your
--delete command as arguments (all custom arguments are omitted).
More complicated interactions build on the two examples above - your inventory
script could make a call to allocate storage on your infrastructure as a
service, or register node names in DNS, or set complex firewalls. The more
complex your integration, the more important it is to record enough data in the
remote system that you can identify when resources on either side are deleted.
Experimental: This command is under active development and may change without notice.`)
示例6:
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
configcmd "github.com/openshift/origin/pkg/config/cmd"
"github.com/openshift/origin/pkg/generate/app"
appcmd "github.com/openshift/origin/pkg/generate/app/cmd"
"github.com/openshift/origin/pkg/generate/appjson"
)
const AppJSONV1GeneratorName = "app-json/v1"
var (
appJSONLong = templates.LongDesc(`
Import app.json files as OpenShift objects
app.json defines the pattern of a simple, stateless web application that can be horizontally scaled.
This command will transform a provided app.json object into its OpenShift equivalent.
During transformation fields in the app.json syntax that are not relevant when running on top of
a containerized platform will be ignored and a warning printed.
The command will create objects unless you pass the -o yaml or --as-template flags to generate a
configuration file for later use.
Experimental: This command is under active development and may change without notice.`)
appJSONExample = templates.Examples(`
# Import a directory containing an app.json file
$ %[1]s app.json -f .
# Turn an app.json file into a template
$ %[1]s app.json -f ./app.json -o yaml --as-template`)
)
type AppJSONOptions struct {
示例7: DefaultsFromName
func (o *MasterOptions) DefaultsFromName(basename string) {
if cmdutil.GetProductName(basename) == cmdutil.ProductAtomicEnterprise {
o.DisabledFeatures = configapi.AtomicDisabledFeatures
}
}
var masterLong = templates.LongDesc(`
Start a master server
This command helps you launch a master server. Running
%[1]s start master
will start a master listening on all interfaces, launch an etcd server to store
persistent data, and launch the Kubernetes system components. The server will run in the
foreground until you terminate the process.
Note: starting the master without passing the --master address will attempt to find the IP
address that will be visible inside running Docker containers. This is not always successful,
so if you have problems tell the master what public address it should use via --master=<ip>.
You may also pass --etcd=<address> to connect to an external etcd server.
You may also pass --kubeconfig=<path> to connect to an external Kubernetes cluster.`)
// NewCommandStartMaster provides a CLI handler for 'start master' command
func NewCommandStartMaster(basename string, out, errout io.Writer) (*cobra.Command, *MasterOptions) {
options := &MasterOptions{Output: out}
options.DefaultsFromName(basename)
cmd := &cobra.Command{
示例8:
"github.com/openshift/origin/pkg/cmd/templates"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
var (
probeLong = templates.LongDesc(`
Set or remove a liveness or readiness probe from a pod or pod template
Each container in a pod may define one or more probes that are used for general health
checking. A liveness probe is checked periodically to ensure the container is still healthy:
if the probe fails, the container is restarted. Readiness probes set or clear the ready
flag for each container, which controls whether the container's ports are included in the list
of endpoints for a service and whether a deployment can proceed. A readiness check should
indicate when your container is ready to accept incoming traffic or begin handling work.
Setting both liveness and readiness probes for each container is highly recommended.
The three probe types are:
1. Open a TCP socket on the pod IP
2. Perform an HTTP GET against a URL on a container that must return 200 OK
3. Run a command in the container that must return exit code 0
Containers that take a variable amount of time to start should set generous
initial-delay-seconds values, otherwise as your application evolves you may suddenly begin
to fail.`)
probeExample = templates.Examples(`
# Clear both readiness and liveness probes off all containers
%[1]s probe dc/registry --remove --readiness --liveness
# Set an exec action as a liveness probe to run 'echo ok'
示例9:
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
ocmd "github.com/openshift/origin/pkg/cmd/cli/cmd"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
"github.com/openshift/origin/pkg/router/controller"
f5plugin "github.com/openshift/origin/pkg/router/f5"
)
var (
f5Long = templates.LongDesc(`
Start an F5 route synchronizer
This command launches a process that will synchronize an F5 to the route configuration of your master.
You may restrict the set of routes exposed to a single project (with --namespace), projects your client has
access to with a set of labels (--project-labels), namespaces matching a label (--namespace-labels), or all
namespaces (no argument). You can limit the routes to those matching a --labels or --fields selector. Note
that you must have a cluster-wide administrative role to view all namespaces.`)
)
// F5RouterOptions represent the complete structure needed to start an F5 router
// sync process.
type F5RouterOptions struct {
Config *clientcmd.Config
F5Router
RouterSelection
}
示例10:
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/term"
"github.com/openshift/origin/pkg/cmd/cli/config"
"github.com/openshift/origin/pkg/cmd/flagtypes"
"github.com/openshift/origin/pkg/cmd/templates"
osclientcmd "github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
var (
loginLong = templates.LongDesc(`
Log in to your server and save login for subsequent use
First-time users of the client should run this command to connect to a server,
establish an authenticated session, and save connection to the configuration file. The
default configuration will be saved to your home directory under
".kube/config".
The information required to login -- like username and password, a session token, or
the server details -- can be provided through flags. If not provided, the command will
prompt for user input as needed.`)
loginExample = templates.Examples(`
# Log in interactively
%[1]s login
# Log in to the given server with the given certificate authority file
%[1]s login localhost:8443 --certificate-authority=/path/to/cert.crt
# Log in to the given server with the given credentials (will not prompt interactively)
%[1]s login localhost:8443 --username=myuser --password=mypass`)
示例11:
"github.com/openshift/origin/pkg/router/controller"
templateplugin "github.com/openshift/origin/pkg/router/template"
"github.com/openshift/origin/pkg/util/proc"
)
// defaultReloadInterval is how often to do reloads in seconds.
const defaultReloadInterval = 5
var routerLong = templates.LongDesc(`
Start a router
This command launches a router connected to your cluster master. The router listens for routes and endpoints
created by users and keeps a local router configuration up to date with those changes.
You may customize the router by providing your own --template and --reload scripts.
The router must have a default certificate in pem format. You may provide it via --default-cert otherwise
one is automatically created.
You may restrict the set of routes exposed to a single project (with --namespace), projects your client has
access to with a set of labels (--project-labels), namespaces matching a label (--namespace-labels), or all
namespaces (no argument). You can limit the routes to those matching a --labels or --fields selector. Note
that you must have a cluster-wide administrative role to view all namespaces.`)
type TemplateRouterOptions struct {
Config *clientcmd.Config
TemplateRouter
RouterStats
RouterSelection
}
示例12: NewCommandStartAllInOne
NodeConfigFile string
PrintIP bool
ServiceNetworkCIDR string
Output io.Writer
}
var allInOneLong = templates.LongDesc(`
Start an all-in-one server
This command helps you launch an all-in-one server, which allows you to run all of the
components of an enterprise Kubernetes system on a server with Docker. Running:
%[1]s start
will start listening on all interfaces, launch an etcd server to store persistent
data, and launch the Kubernetes system components. The server will run in the foreground until
you terminate the process. This command delegates to "%[1]s start master" and
"%[1]s start node".
Note: starting OpenShift without passing the --master address will attempt to find the IP
address that will be visible inside running Docker containers. This is not always successful,
so if you have problems tell OpenShift what public address it will be via --master=<ip>.
You may also pass --etcd=<address> to connect to an external etcd server.
You may also pass --kubeconfig=<path> to connect to an external Kubernetes cluster.`)
// NewCommandStartAllInOne provides a CLI handler for 'start' command
func NewCommandStartAllInOne(basename string, out, errout io.Writer) (*cobra.Command, *AllInOneOptions) {
options := &AllInOneOptions{Output: out, MasterOptions: &MasterOptions{Output: out}}
options.MasterOptions.DefaultsFromName(basename)
示例13: NewCmdTopImages
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
deployapi "github.com/openshift/origin/pkg/deploy/api"
imageapi "github.com/openshift/origin/pkg/image/api"
imagegraph "github.com/openshift/origin/pkg/image/graph/nodes"
)
const (
TopImagesRecommendedName = "images"
maxImageIDLength = 20
)
var (
topImagesLong = templates.LongDesc(`
Show usage statistics for Images
This command analyzes all the Images managed by the platform and presents current
usage statistics.`)
topImagesExample = templates.Examples(`
# Show usage statistics for Images
%[1]s %[2]s`)
)
// NewCmdTopImages implements the OpenShift cli top images command.
func NewCmdTopImages(f *clientcmd.Factory, parentName, name string, out io.Writer) *cobra.Command {
opts := &TopImagesOptions{}
cmd := &cobra.Command{
Use: name,
Short: "Show usage statistics for Images",
Long: topImagesLong,
示例14:
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api/meta"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/runtime"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/client"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
const PolicyBindingRecommendedName = "policybinding"
var (
policyBindingLong = templates.LongDesc(`Create a policy binding that references the policy in the targeted namespace.`)
policyBindingExample = templates.Examples(`
# Create a policy binding in namespace "foo" that references the policy in namespace "bar"
%[1]s bar -n foo`)
)
type CreatePolicyBindingOptions struct {
BindingNamespace string
PolicyNamespace string
BindingClient client.PolicyBindingsNamespacer
Mapper meta.RESTMapper
OutputFormat string
Out io.Writer
示例15: NewCommandAdmin
"github.com/openshift/origin/pkg/cmd/admin/prune"
"github.com/openshift/origin/pkg/cmd/admin/registry"
"github.com/openshift/origin/pkg/cmd/admin/router"
"github.com/openshift/origin/pkg/cmd/admin/top"
"github.com/openshift/origin/pkg/cmd/cli/cmd"
"github.com/openshift/origin/pkg/cmd/experimental/buildchain"
exipfailover "github.com/openshift/origin/pkg/cmd/experimental/ipfailover"
"github.com/openshift/origin/pkg/cmd/server/admin"
"github.com/openshift/origin/pkg/cmd/templates"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
var adminLong = templates.LongDesc(`
Administrative Commands
Commands for managing a cluster are exposed here. Many administrative
actions involve interaction with the command-line client as well.`)
func NewCommandAdmin(name, fullName string, in io.Reader, out io.Writer, errout io.Writer) *cobra.Command {
// Main command
cmds := &cobra.Command{
Use: name,
Short: "Tools for managing a cluster",
Long: fmt.Sprintf(adminLong),
Run: kcmdutil.DefaultSubCommandRun(out),
}
f := clientcmd.New(cmds.PersistentFlags())
groups := templates.CommandGroups{