Skip to content

Commit f1cbbdb

Browse files
authored
Rework & simplify documentation (#366)
* rework & simplify documentation Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent a50df39 commit f1cbbdb

49 files changed

Lines changed: 782 additions & 622 deletions

Some content is hidden

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

Makefile

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,33 +409,42 @@ build-web:
409409
PLATFORMS ?= linux/$(ARCH)
410410
.PHONY: image-local
411411
image-local:
412-
@echo "Building multi-arch images locally with tag $(REV) for platforms: $(PLATFORMS)"
412+
@echo "Building images locally with tag $(REV) for platforms: $(PLATFORMS)"
413413
@command -v docker >/dev/null 2>&1 || { echo "docker not found. Please install Docker"; exit 1; }
414414
@docker buildx version >/dev/null 2>&1 || { echo "docker buildx not found. Please enable buildx in Docker"; exit 1; }
415415

416416
@# Create buildx builder if it doesn't exist
417417
@docker buildx create --name kube-bind-builder --use 2>/dev/null || docker buildx use kube-bind-builder 2>/dev/null || true
418418
@docker buildx inspect --bootstrap >/dev/null 2>&1
419419

420-
@echo "Building konnector multi-arch image locally..."
420+
@# Check if building for multiple platforms
421+
@if [[ "$(PLATFORMS)" == *","* ]]; then \
422+
echo "Multi-platform build detected. Images will be pushed to registry instead of loaded locally."; \
423+
LOAD_FLAG="--push"; \
424+
else \
425+
echo "Single platform build. Images will be loaded to local Docker daemon."; \
426+
LOAD_FLAG="--load"; \
427+
fi && \
428+
\
429+
echo "Building konnector image..." && \
421430
docker buildx build \
422431
--platform $(PLATFORMS) \
423432
--build-arg LDFLAGS="$(LDFLAGS)" \
424433
-t $(IMAGE_REPO)/konnector:$(REV) \
425434
-f Dockerfile.konnector \
426-
--load .
427-
428-
@echo "Building backend multi-arch image locally..."
435+
$$LOAD_FLAG . && \
436+
\
437+
echo "Building backend image..." && \
429438
docker buildx build \
430439
--platform $(PLATFORMS) \
431440
--build-arg LDFLAGS="$(LDFLAGS)" \
432441
-t $(IMAGE_REPO)/backend:$(REV) \
433442
-f Dockerfile \
434-
--load .
435-
436-
@echo "Successfully built multi-arch local images:"
437-
@echo " $(IMAGE_REPO)/konnector:$(REV) ($(PLATFORMS))"
438-
@echo " $(IMAGE_REPO)/backend:$(REV) ($(PLATFORMS))"
443+
$$LOAD_FLAG . && \
444+
\
445+
echo "Successfully built images:" && \
446+
echo " $(IMAGE_REPO)/konnector:$(REV) ($(PLATFORMS))" && \
447+
echo " $(IMAGE_REPO)/backend:$(REV) ($(PLATFORMS))"
439448

440449
# Kind cluster configuration
441450
KIND_CLUSTER ?= kube-bind

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

0 commit comments

Comments
 (0)