Skip to content

Commit 2521204

Browse files
committed
rework & simplify documentation
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent 640871f commit 2521204

48 files changed

Lines changed: 761 additions & 611 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli/pkg/kubectl/bind-apiservice/cmd/cmd.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ var (
3535
# bind to a remote API service. Use kubectl bind to create the APIServiceExportRequest interactively.
3636
%[1]s apiservice --remote-kubeconfig file -f apiservice-export-request.yaml
3737
38-
# bind to a remote API service via a request manifest from a https URL.
39-
%[1]s apiservice --remote-kubeconfig file https://some-url.com/apiservice-export-requests.yaml
40-
41-
# bind to a API service directly without any remote agent or service provider.
42-
%[1]s apiservice --remote-kubeconfig file -n remote-namespace resources.group/v1
38+
# bind to a remote API using template name
39+
%[1]s apiservice --name my-api --template-name database-service
4340
`
4441
)
4542

cli/pkg/kubectl/bind-apiservice/plugin/bind.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ func (b *BindAPIServiceOptions) bindTemplate(ctx context.Context) (*bindTemplate
324324
return nil, err
325325
}
326326
if created {
327-
fmt.Fprintf(b.Options.IOStreams.ErrOut, "Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
327+
fmt.Fprintf(b.Options.IOStreams.ErrOut, "🔒 Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
328328
} else {
329-
fmt.Fprintf(b.Options.IOStreams.ErrOut, "Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
329+
fmt.Fprintf(b.Options.IOStreams.ErrOut, "🔒 Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
330330
}
331331
return &bindTemplateResult{
332332
response: bindResponse,

cli/pkg/kubectl/bind-apiservice/plugin/binder.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ func NewBinder(config *rest.Config, opts *BinderOptions) *Binder {
6666
// https://github.com/kube-bind/kube-bind/issues/360
6767

6868
func (b *Binder) BindFromFile(ctx context.Context) ([]*kubebindv1alpha2.APIServiceBinding, error) {
69+
// Generate the kubectl command that would be equivalent
70+
remoteFlags := ""
71+
if b.opts.RemoteKubeconfigFile != "" {
72+
remoteFlags = fmt.Sprintf("--remote-kubeconfig %s", b.opts.RemoteKubeconfigFile)
73+
} else if b.opts.RemoteKubeconfigNamespace != "" && b.opts.RemoteKubeconfigName != "" {
74+
remoteFlags = fmt.Sprintf("--remote-kubeconfig-namespace %s --remote-kubeconfig-name %s", b.opts.RemoteKubeconfigNamespace, b.opts.RemoteKubeconfigName)
75+
}
76+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "🚀 Executing: kubectl bind apiservice %s -f -\n", remoteFlags)
77+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "✨ Use \"-o yaml\" and \"--dry-run\" to get the APIServiceExportRequest.\n")
78+
fmt.Fprintf(b.opts.IOStreams.ErrOut, " and pass it to \"kubectl bind apiservice\" directly. Great for automation.\n")
79+
6980
// Ensure client side namespace exists
7081
err := b.ensureClientSideNamespaceExists(ctx)
7182
if err != nil {
@@ -99,9 +110,9 @@ func (b *Binder) BindFromFile(ctx context.Context) ([]*kubebindv1alpha2.APIServi
99110
}
100111

101112
if created {
102-
fmt.Fprintf(b.opts.IOStreams.ErrOut, "Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
113+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "🔒 Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
103114
} else {
104-
fmt.Fprintf(b.opts.IOStreams.ErrOut, "Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
115+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "🔒 Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
105116
}
106117

107118
if b.opts.DryRun {
@@ -184,9 +195,9 @@ func (b *Binder) BindFromResponse(ctx context.Context, response *kubebindv1alpha
184195
}
185196

186197
if created {
187-
fmt.Fprintf(b.opts.IOStreams.ErrOut, "Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
198+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "🔒 Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
188199
} else {
189-
fmt.Fprintf(b.opts.IOStreams.ErrOut, "Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
200+
fmt.Fprintf(b.opts.IOStreams.ErrOut, "🔒 Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
190201
}
191202

192203
if b.opts.DryRun {

cli/pkg/kubectl/bind-apiservice/plugin/konnector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (b *BindAPIServiceOptions) deployKonnector(ctx context.Context, config *res
6868
}
6969

7070
if b.KonnectorImageOverride != "" {
71-
fmt.Fprintf(b.Options.ErrOut, "Deploying konnector %s to namespace kube-bind with custom image %q.\n", bindVersion, b.KonnectorImageOverride)
71+
fmt.Fprintf(b.Options.ErrOut, "🚀 Deploying konnector %s to namespace kube-bind with custom image %q.\n", bindVersion, b.KonnectorImageOverride)
7272
if err := konnector.Bootstrap(ctx, discoveryClient, dynamicClient, b.KonnectorImageOverride); err != nil {
7373
return err
7474
}
@@ -103,7 +103,7 @@ func (b *BindAPIServiceOptions) deployKonnector(ctx context.Context, config *res
103103
}
104104
}
105105
} else {
106-
fmt.Fprintf(b.Options.ErrOut, "Deploying konnector %s to namespace kube-bind.\n", bindVersion)
106+
fmt.Fprintf(b.Options.ErrOut, "🚀 Deploying konnector %s to namespace kube-bind.\n", bindVersion)
107107
if err := konnector.Bootstrap(ctx, discoveryClient, dynamicClient, konnectorImage); err != nil {
108108
return err
109109
}

cli/pkg/kubectl/bind-apiservice/plugin/secret.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func (b *BindAPIServiceOptions) ensureKubeconfigSecretWithLogging(ctx context.Co
7676

7777
if b.remoteKubeconfigFile != "" {
7878
if created {
79-
fmt.Fprintf(b.Options.ErrOut, "Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
79+
fmt.Fprintf(b.Options.ErrOut, "🔒 Created secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
8080
} else {
81-
fmt.Fprintf(b.Options.ErrOut, "Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
81+
fmt.Fprintf(b.Options.ErrOut, "🔒 Updated secret %s/%s for host %s, namespace %s\n", "kube-bind", secret.Name, remoteHost, remoteNamespace)
8282
}
8383
}
8484

cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co
106106
return nil, err
107107
}
108108

109-
fmt.Fprintf(b.Options.IOStreams.ErrOut, "Created APIServiceBinding %s for %d resources\n", bindingName, len(request.Spec.Resources))
109+
fmt.Fprintf(b.Options.IOStreams.ErrOut, "Created APIServiceBinding %s for %d resources\n", bindingName, len(request.Spec.Resources))
110110
return []*kubebindv1alpha2.APIServiceBinding{created}, nil
111111
}

cli/pkg/kubectl/bind-collections/cmd/cmd.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ var (
3232
# List collections from currently authenticated server
3333
%[1]s collections
3434
35-
# List collections from specific server
36-
%[1]s collections https://mangodb.com
37-
3835
# List collections using --server flag to override current server
3936
%[1]s collections --server https://mangodb.com
4037
41-
# List collections with JSON output
38+
# List collections with JSON/YAML output
4239
%[1]s collections -o json
40+
%[1]s collections -o yaml
4341
`
4442
)
4543

cli/pkg/kubectl/bind-login/plugin/login.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ func (o *LoginOptions) Run(ctx context.Context, authURLCh chan<- string) error {
209209
}
210210

211211
if token.Cluster != "" {
212-
fmt.Fprintf(o.Streams.ErrOut, "Successfully authenticated to %s (cluster: %s)\n", serverHost.Host, token.Cluster)
213-
fmt.Fprintf(o.Streams.ErrOut, " Server key: %s\n", fmt.Sprintf("%s@%s", serverURL, token.Cluster))
212+
fmt.Fprintf(o.Streams.ErrOut, "🔑 Successfully authenticated to %s (cluster: %s)\n", serverHost.Host, token.Cluster)
213+
fmt.Fprintf(o.Streams.ErrOut, " Server key: %s\n", fmt.Sprintf("%s@%s", serverURL, token.Cluster))
214214
} else {
215-
fmt.Fprintf(o.Streams.ErrOut, "Successfully authenticated to %s\n", serverHost.Host)
215+
fmt.Fprintf(o.Streams.ErrOut, "🔑 Successfully authenticated to %s\n", serverHost.Host)
216216
}
217217

218218
if o.ShowToken {

cli/pkg/kubectl/bind-templates/cmd/cmd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ var (
3333
%[1]s templates
3434
3535
# List templates from specific server
36-
%[1]s templates https://mangodb.com
36+
%[1]s templates
3737
3838
# List templates using --server flag to override current server
3939
%[1]s templates --server https://mangodb.com
4040
41-
# List templates with JSON output
41+
# List templates with JSON/YAML output
4242
%[1]s templates -o json
43+
%[1]s templates -o yaml
4344
`
4445
)
4546

cli/pkg/kubectl/bind/cmd/cmd.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121
"strings"
2222

23-
"github.com/fatih/color"
2423
"github.com/spf13/cobra"
2524
"k8s.io/cli-runtime/pkg/genericclioptions"
2625
logsv1 "k8s.io/component-base/logs/api/v1"
@@ -34,23 +33,19 @@ import (
3433

3534
var (
3635
BindExampleUses = `
37-
# Open kube-bind UI for current server context
38-
%[1]s bind
36+
# %[1]s bind login --server https://my-kube-bind-server.com
3937
40-
# Open kube-bind UI for specific server
41-
%[1]s bind https://mangodb.com
38+
# Open kube-bind UI for current server context
39+
%[1]s bind
4240
4341
# List available templates (CLI mode)
44-
%[1]s bind --dry-run
42+
%[1]s bind templates
4543
4644
# Bind specific template (CLI mode)
47-
%[1]s bind --template my-app
48-
49-
# Bind template with server override
50-
%[1]s bind https://mangodb.com --template my-app
45+
%[1]s bind apiservice --name my-api --template-name database-service
5146
5247
# View template details without binding
53-
%[1]s bind --template my-app --dry-run
48+
%[1]s bind apiservice --name my-api --template-name database-service --dry-run
5449
`
5550
)
5651

@@ -64,9 +59,8 @@ func New(streams genericclioptions.IOStreams) (*cobra.Command, error) {
6459
a web UI or command-line interface.
6560
6661
By default, 'kubectl bind' opens the kube-bind web UI in your browser.
67-
Use the --template flag to bind specific templates via CLI.
6862
69-
For more information, see: https://kube-bind.io
63+
For more information, see: https://docs.kube-bind.io
7064
`),
7165
Example: fmt.Sprintf(BindExampleUses, "kubectl"),
7266
SilenceUsage: true,
@@ -89,9 +83,6 @@ func New(streams genericclioptions.IOStreams) (*cobra.Command, error) {
8983
return err
9084
}
9185

92-
yellow := color.New(color.BgRed, color.FgBlack).SprintFunc()
93-
fmt.Fprintf(streams.ErrOut, "%s\n\n", yellow("DISCLAIMER: This is a prototype. It will change in incompatible ways at any time."))
94-
9586
if err := opts.Complete(args); err != nil {
9687
return err
9788
}

0 commit comments

Comments
 (0)