本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/templates.Examples函数的典型用法代码示例。如果您正苦于以下问题:Golang Examples函数的具体用法?Golang Examples怎么用?Golang Examples使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Examples函数的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:
Prune OpenShift Groups referencing missing records on from an external provider.
In order to prune OpenShift Group records using those from an external provider, determine which Groups you wish
to prune. For instance, all or some groups may be selected from the current Groups stored in OpenShift that have
been synced previously. Any combination of a literal whitelist, a whitelist file and a blacklist file is supported.
The path to a sync configuration file that was used for syncing the groups in question is required in order to
describe how data is requested from the external record store. Default behavior is to indicate all OpenShift groups
for which the external record does not exist, to run the pruning process and commit the results, use the --confirm
flag.`)
pruneExamples = templates.Examples(`
# Prune all orphaned groups
%[1]s --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Prune all orphaned groups except the ones from the blacklist file
%[1]s --blacklist=/path/to/blacklist.txt --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Prune all orphaned groups from a list of specific groups specified in a whitelist file
%[1]s --whitelist=/path/to/whitelist.txt --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Prune all orphaned groups from a list of specific groups specified in a whitelist
%[1]s groups/group_name groups/other_name --sync-config=/path/to/ldap-sync-config.yaml --confirm`)
)
type PruneOptions struct {
// Config is the LDAP sync config read from file
Config *api.LDAPSyncConfig
// Whitelist are the names of OpenShift group or LDAP group UIDs to use for syncing
Whitelist []string
// Blacklist are the names of OpenShift group or LDAP group UIDs to exclude
示例3: NewCmdBuildLogs
"github.com/openshift/origin/pkg/build/api"
buildutil "github.com/openshift/origin/pkg/build/util"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
var (
buildLogsLong = templates.LongDesc(`
Retrieve logs for a build
This command displays the log for the provided build. If the pod that ran the build has been deleted logs
will no longer be available. If the build has not yet completed, the build logs will be streamed until the
build completes or fails.`)
buildLogsExample = templates.Examples(`
# Stream logs from container
%[1]s build-logs 566bed879d2d`)
)
// NewCmdBuildLogs implements the OpenShift cli build-logs command
func NewCmdBuildLogs(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
opts := api.BuildLogOptions{}
cmd := &cobra.Command{
Use: "build-logs BUILD",
Short: "Show logs from a build",
Long: buildLogsLong,
Example: fmt.Sprintf(buildLogsExample, fullName),
Deprecated: fmt.Sprintf("use \"oc %v build/<build-name>\" instead.", LogsRecommendedCommandName),
Run: func(cmd *cobra.Command, args []string) {
err := RunBuildLogs(fullName, f, out, cmd, opts, args)
示例4:
"github.com/openshift/origin/pkg/client"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
var DeploymentConfigRecommendedName = "deploymentconfig"
var (
deploymentConfigLong = templates.LongDesc(`
Create a deployment config that uses a given image.
Deployment configs define the template for a pod and manages deploying new images or configuration changes.`)
deploymentConfigExample = templates.Examples(`
# Create an nginx deployment config named my-nginx
%[1]s my-nginx --image=nginx`)
)
type CreateDeploymentConfigOptions struct {
DC *deployapi.DeploymentConfig
Client client.DeploymentConfigsNamespacer
DryRun bool
Mapper meta.RESTMapper
OutputFormat string
Out io.Writer
Printer ObjectPrinter
}
示例5: NewCmdStartBuild
and override the current build source settings. When using --from-repo, the --commit flag can be
used to control which branch, tag, or commit is sent to the server. If you pass --from-file, the
file is placed in the root of an empty directory with the same filename. Note that builds
triggered from binary input will not preserve the source on the server, so rebuilds triggered by
base image changes will use the source specified on the build config.`)
startBuildExample = templates.Examples(`
# Starts build from build config "hello-world"
%[1]s start-build hello-world
# Starts build from a previous build "hello-world-1"
%[1]s start-build --from-build=hello-world-1
# Use the contents of a directory as build input
%[1]s start-build hello-world --from-dir=src/
# Send the contents of a Git repository to the server from tag 'v2'
%[1]s start-build hello-world --from-repo=../hello-world --commit=v2
# Start a new build for build config "hello-world" and watch the logs until the build
# completes or fails.
%[1]s start-build hello-world --follow
# Start a new build for build config "hello-world" and wait until the build completes. It
# exits with a non-zero return code if the build fails.
%[1]s start-build hello-world --wait`)
)
// NewCmdStartBuild implements the OpenShift cli start-build command
func NewCmdStartBuild(fullName string, f *clientcmd.Factory, in io.Reader, out, errout io.Writer) *cobra.Command {
o := &StartBuildOptions{}
示例6:
)
// LinkSecretRecommendedName `oc secrets link`
const LinkSecretRecommendedName = "link"
var (
linkSecretLong = templates.LongDesc(`
Link secrets to a service account
Linking a secret enables a service account to automatically use that secret for some forms of authentication.`)
linkSecretExample = templates.Examples(`
# Add an image pull secret to a service account to automatically use it for pulling pod images:
%[1]s serviceaccount-name pull-secret --for=pull
# Add an image pull secret to a service account to automatically use it for both pulling and pushing build images:
%[1]s builder builder-image-secret --for=pull,mount
# If the cluster's serviceAccountConfig is operating with limitSecretReferences: True, secrets must be added to the pod's service account whitelist in order to be available to the pod:
%[1]s pod-sa pod-secret`)
)
type LinkSecretOptions struct {
SecretOptions
ForMount bool
ForPull bool
typeFlags []string
}
示例7:
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'
%[1]s probe dc/registry --liveness -- echo ok
# Set a readiness probe to try to open a TCP socket on 3306
%[1]s probe rc/mysql --readiness --open-tcp=3306
# Set an HTTP readiness probe for port 8080 and path /healthz over HTTP on the pod IP
%[1]s probe dc/webapp --readiness --get-url=http://:8080/healthz
# Set an HTTP readiness probe over HTTPS on 127.0.0.1 for a hostNetwork pod
%[1]s probe dc/router --readiness --get-url=https://127.0.0.1:1936/stats
# Set only the initial-delay-seconds field on all deployments
%[1]s probe dc --all --readiness --initial-delay-seconds=30`)
)
type ProbeOptions struct {
Out io.Writer
Err io.Writer
Filenames []string
示例8:
When using the Docker command line to push images, you can authenticate to a given registry by running
'docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL'.
That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' commands to
authenticate to the registry.
When creating applications, you may have a Docker registry that requires authentication. In order for the
nodes to pull images on your behalf, they have to have the credentials. You can provide this information
by creating a dockercfg secret and attaching it to your service account.`)
createDockercfgExample = templates.Examples(`
# Create a new .dockercfg secret:
%[1]s SECRET --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
# Create a new .dockercfg secret from an existing file:
%[2]s SECRET path/to/.dockercfg
# Create a new .docker/config.json secret from an existing file:
%[2]s SECRET .dockerconfigjson=path/to/.docker/config.json
# To add new secret to 'imagePullSecrets' for the node, or 'secrets' for builds, use:
%[3]s SERVICE_ACCOUNT`)
)
type CreateDockerConfigOptions struct {
SecretName string
RegistryLocation string
Username string
Password string
EmailAddress string
SecretsInterface client.SecretsInterface
示例9:
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
# Create a Ruby application based on the provided [image]~[source code] combination
%[1]s %[2]s centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
# Use the public Docker Hub MySQL image to create an app. Generated artifacts will be labeled with db=mysql
%[1]s %[2]s mysql MYSQL_USER=user MYSQL_PASSWORD=pass MYSQL_DATABASE=testdb -l db=mysql
# Use a MySQL image in a private registry to create an app and override application artifacts' names
%[1]s %[2]s --docker-image=myregistry.com/mycompany/mysql --name=private
# Create an application from a remote repository using its beta4 branch
%[1]s %[2]s https://github.com/openshift/ruby-hello-world#beta4
# Create an application based on a stored template, explicitly setting a parameter value
%[1]s %[2]s --template=ruby-helloworld-sample --param=MYSQL_USER=admin
# Create an application from a remote repository and specify a context directory
%[1]s %[2]s https://github.com/youruser/yourgitrepo --context-dir=src/build
# Create an application based on a template file, explicitly setting a parameter value
%[1]s %[2]s --file=./example/myapp/template.json --param=MYSQL_USER=admin
# Search all templates, image streams, and Docker images for the ones that match "ruby"
%[1]s %[2]s --search ruby
# Search for "ruby", but only in stored templates (--template, --image-stream and --docker-image
# can be used to filter search results)
%[1]s %[2]s --search --template=ruby
# Search for "ruby" in stored templates and print the output as an YAML
%[1]s %[2]s --search --template=ruby --output=yaml`)
示例10:
// BuildChainRecommendedCommandName is the recommended command name
const BuildChainRecommendedCommandName = "build-chain"
var (
buildChainLong = templates.LongDesc(`
Output the inputs and dependencies of your builds
Supported formats for the generated graph are dot and a human-readable output.
Tag and namespace are optional and if they are not specified, 'latest' and the
default namespace will be used respectively.`)
buildChainExample = templates.Examples(`
# Build the dependency tree for the 'latest' tag in <image-stream>
%[1]s <image-stream>
# Build the dependency tree for 'v2' tag in dot format and visualize it via the dot utility
%[1]s <image-stream>:v2 -o dot | dot -T svg -o deps.svg
# Build the dependency tree across all namespaces for the specified image stream tag found in 'test' namespace
%[1]s <image-stream> -n test --all`)
)
// BuildChainOptions contains all the options needed for build-chain
type BuildChainOptions struct {
name string
defaultNamespace string
namespaces sets.String
allNamespaces bool
triggerOnly bool
reverse bool
示例11: NewCmdJoinProjectsNetwork
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
sdnapi "github.com/openshift/origin/pkg/sdn/api"
)
const JoinProjectsNetworkCommandName = "join-projects"
var (
joinProjectsNetworkLong = templates.LongDesc(`
Join project network
Allows projects to join existing project network when using the %[1]s network plugin.`)
joinProjectsNetworkExample = templates.Examples(`
# Allow project p2 to use project p1 network
%[1]s --to=<p1> <p2>
# Allow all projects with label name=top-secret to use project p1 network
%[1]s --to=<p1> --selector='name=top-secret'`)
)
type JoinOptions struct {
Options *ProjectOptions
joinProjectName string
}
func NewCmdJoinProjectsNetwork(commandName, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
opts := &ProjectOptions{}
joinOp := &JoinOptions{Options: opts}
cmd := &cobra.Command{
示例12:
In order to sync OpenShift Group records with those from an external provider, determine which Groups you wish
to sync and where their records live. For instance, all or some groups may be selected from the current Groups
stored in OpenShift that have been synced previously, or similarly all or some groups may be selected from those
stored on an LDAP server. The path to a sync configuration file is required in order to describe how data is
requested from the external record store and migrated to OpenShift records. Default behavior is to do a dry-run
without changing OpenShift records. Passing '--confirm' will sync all groups from the LDAP server returned by the
LDAP query templates.`)
syncExamples = templates.Examples(`
# Sync all groups from an LDAP server
%[1]s --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Sync all groups except the ones from the blacklist file from an LDAP server
%[1]s --blacklist=/path/to/blacklist.txt --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Sync specific groups specified in a whitelist file with an LDAP server
%[1]s --whitelist=/path/to/whitelist.txt --sync-config=/path/to/sync-config.yaml --confirm
# Sync all OpenShift Groups that have been synced previously with an LDAP server
%[1]s --type=openshift --sync-config=/path/to/ldap-sync-config.yaml --confirm
# Sync specific OpenShift Groups if they have been synced previously with an LDAP server
%[1]s groups/group1 groups/group2 groups/group3 --sync-config=/path/to/sync-config.yaml --confirm`)
)
// GroupSyncSource determines the source of the groups to be synced
type GroupSyncSource string
const (
// GroupSyncSourceLDAP determines that the groups to be synced are determined from an LDAP record
GroupSyncSourceLDAP GroupSyncSource = "ldap"
示例13:
The --adjust flag allows you to alter the weight of an individual service relative to
itself or to the primary backend. Specifying a percentage will adjust the backend
relative to either the primary or the first alternate (if you specify the primary).
If there are other backends their weights will be kept proportional to the changed.
Not all routers may support multiple or weighted backends.`)
backendsExample = templates.Examples(`
# Print the backends on the route 'web'
%[1]s route-backends web
# Set two backend services on route 'web' with 2/3rds of traffic going to 'a'
%[1]s route-backends web a=2 b=1
# Increase the traffic percentage going to b by 10%% relative to a
%[1]s route-backends web --adjust b=+10%%
# Set traffic percentage going to b to 10%% of the traffic going to a
%[1]s route-backends web --adjust b=10%%
# Set weight of b to 10
%[1]s route-backends web --adjust b=10
# Set the weight to all backends to zero
%[1]s route-backends web --zero`)
)
type BackendsOptions struct {
Out io.Writer
Err io.Writer
Filenames []string
示例14: NewCmdReconcileClusterRoleBindings
Update cluster role bindings to match the recommended bootstrap policy
This command will inspect the cluster role bindings against the recommended bootstrap policy.
Any cluster role binding that does not match will be replaced by the recommended bootstrap role binding.
This command will not remove any additional cluster role bindings.
You can see which recommended cluster role bindings have changed by choosing an output type.`)
reconcileBindingsExample = templates.Examples(`
# Display the names of cluster role bindings that would be modified
%[1]s -o name
# Display the cluster role bindings that would be modified, removing any extra subjects
%[1]s --additive-only=false
# Update cluster role bindings that don't match the current defaults
%[1]s --confirm
# Update cluster role bindings that don't match the current defaults, avoid adding roles to the system:authenticated group
%[1]s --confirm --exclude-groups=system:authenticated
# Update cluster role bindings that don't match the current defaults, removing any extra subjects from the binding
%[1]s --confirm --additive-only=false`)
)
// NewCmdReconcileClusterRoleBindings implements the OpenShift cli reconcile-cluster-role-bindings command
func NewCmdReconcileClusterRoleBindings(name, fullName string, f *clientcmd.Factory, out, err io.Writer) *cobra.Command {
o := &ReconcileClusterRoleBindingsOptions{
Out: out,
Err: err,
Union: true,
示例15:
For descriptions on other volume types, see https://docs.openshift.com`)
volumeExample = templates.Examples(`
# List volumes defined on all deployment configs in the current project
%[1]s volume dc --all
# Add a new empty dir volume to deployment config (dc) 'registry' mounted under
# /var/lib/registry
%[1]s volume dc/registry --add --mount-path=/var/lib/registry
# Use an existing persistent volume claim (pvc) to overwrite an existing volume 'v1'
%[1]s volume dc/registry --add --name=v1 -t pvc --claim-name=pvc1 --overwrite
# Remove volume 'v1' from deployment config 'registry'
%[1]s volume dc/registry --remove --name=v1
# Create a new persistent volume claim that overwrites an existing volume 'v1'
%[1]s volume dc/registry --add --name=v1 -t pvc --claim-size=1G --overwrite
# Change the mount point for volume 'v1' to /data
%[1]s volume dc/registry --add --name=v1 -m /data --overwrite
# Modify the deployment config by removing volume mount "v1" from container "c1"
# (and by removing the volume "v1" if no other containers have volume mounts that reference it)
%[1]s volume dc/registry --remove --name=v1 --containers=c1
# Add new volume based on a more complex volume source (Git repo, AWS EBS, GCE PD,
# Ceph, Gluster, NFS, ISCSI, ...)
%[1]s volume dc/registry --add -m /repo --source=<json-string>`)
)