{{/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}

{{/*
  Add warnings to the warnings template
*/}}
{{ $warnings := (fromJson (include "warnings" .)).result }}
{{- if $warnings }}
---
{{ range $warning := $warnings }}
{{ $warning }}
{{- end }}

---
{{- end }}

{{-
/*
Any rpk command that's given to the user in in this file must be defined in _example-commands.tpl and tested in a test.
*/
-}}

{{- $anySASL := (include "sasl-enabled" . | fromJson).bool }}
{{- $rpk := deepCopy . }}

{{- $_ := set $rpk "rpk" (
  printf "kubectl -n %s exec -ti %s-0 -c redpanda -- rpk"
    .Release.Namespace
    (include "redpanda.fullname" .))
}}

Congratulations on installing {{ .Chart.Name }}!

The pods will rollout in a few seconds. To check the status:

  kubectl -n {{ .Release.Namespace }} rollout status statefulset {{ template "redpanda.fullname" . }} --watch

{{- if and (toJson (dict "bool" .Values.external.enabled)) (eq .Values.external.type "LoadBalancer") }}

If you are using the load balancer service with a cloud provider, the services will likely have automatically-generated addresses. In this scenario the advertised listeners must be updated in order for external access to work. Run the following command once Redpanda is deployed:

  {{ printf "helm upgrade %s redpanda/redpanda -n %s --set $(kubectl get svc -n %s -o jsonpath='{\"external.addresses={\"}{ range .items[*]}{.status.loadBalancer.ingress[0].ip }{.status.loadBalancer.ingress[0].hostname}{\",\"}{ end }{\"}\\n\"}')" (include "redpanda.name" .) .Release.Namespace .Release.Namespace }}
{{- end }}

Try some sample commands:

{{- if and $anySASL }}
{{- $_ := set $rpk "dummySasl" true }}

Create a user:

  {{ include "rpk-acl-user-create" $rpk }}

Give the user permissions:

    {{ include "rpk-acl-create" $rpk }}
{{- end }}

Get the api status:

  {{ include "rpk-cluster-info" $rpk }}

Create a topic

  {{ include "rpk-topic-create" $rpk }}

Describe the topic:

  {{ include "rpk-topic-describe" $rpk }}

Delete the topic:

  {{ include "rpk-topic-delete" $rpk }}
