mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
Add --no-trunc flag to maintain original annotation length
Adds a `--no-trunc` flag to `podman kube generate` preventing the annotations from being trimmed at 63 characters. However, due to the fact the annotations will not be trimmed, any annotation that is longer than 63 characters means this YAML will no longer be Kubernetes compatible. However, these YAML files can still be used with `podman kube play` due to the addition of the new flag below. Adds a `--no-trunc` flag to `podman kube play` supporting YAML files with annotations that were not truncated to the Kubernetes maximum length of 63 characters. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
@@ -93,6 +93,7 @@ func GenerateKube(w http.ResponseWriter, r *http.Request) {
|
||||
Service bool `schema:"service"`
|
||||
Type string `schema:"type"`
|
||||
Replicas int32 `schema:"replicas"`
|
||||
NoTrunc bool `schema:"noTrunc"`
|
||||
}{
|
||||
// Defaults would go here.
|
||||
Replicas: 1,
|
||||
@@ -115,7 +116,12 @@ func GenerateKube(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
containerEngine := abi.ContainerEngine{Libpod: runtime}
|
||||
options := entities.GenerateKubeOptions{Service: query.Service, Type: generateType, Replicas: query.Replicas}
|
||||
options := entities.GenerateKubeOptions{
|
||||
Service: query.Service,
|
||||
Type: generateType,
|
||||
Replicas: query.Replicas,
|
||||
UseLongAnnotations: query.NoTrunc,
|
||||
}
|
||||
report, err := containerEngine.GenerateKube(r.Context(), query.Names, options)
|
||||
if err != nil {
|
||||
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("generating YAML: %w", err))
|
||||
|
||||
@@ -29,6 +29,7 @@ func KubePlay(w http.ResponseWriter, r *http.Request) {
|
||||
StaticMACs []string `schema:"staticMACs"`
|
||||
NoHosts bool `schema:"noHosts"`
|
||||
PublishPorts []string `schema:"publishPorts"`
|
||||
NoTrunc bool `schema:"noTrunc"`
|
||||
Wait bool `schema:"wait"`
|
||||
ServiceContainer bool `schema:"serviceContainer"`
|
||||
}{
|
||||
@@ -85,21 +86,22 @@ func KubePlay(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
containerEngine := abi.ContainerEngine{Libpod: runtime}
|
||||
options := entities.PlayKubeOptions{
|
||||
Annotations: query.Annotations,
|
||||
Authfile: authfile,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Networks: query.Network,
|
||||
NoHosts: query.NoHosts,
|
||||
Quiet: true,
|
||||
LogDriver: logDriver,
|
||||
LogOptions: query.LogOptions,
|
||||
StaticIPs: staticIPs,
|
||||
StaticMACs: staticMACs,
|
||||
IsRemote: true,
|
||||
PublishPorts: query.PublishPorts,
|
||||
Wait: query.Wait,
|
||||
ServiceContainer: query.ServiceContainer,
|
||||
Annotations: query.Annotations,
|
||||
Authfile: authfile,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Networks: query.Network,
|
||||
NoHosts: query.NoHosts,
|
||||
Quiet: true,
|
||||
LogDriver: logDriver,
|
||||
LogOptions: query.LogOptions,
|
||||
StaticIPs: staticIPs,
|
||||
StaticMACs: staticMACs,
|
||||
IsRemote: true,
|
||||
PublishPorts: query.PublishPorts,
|
||||
Wait: query.Wait,
|
||||
ServiceContainer: query.ServiceContainer,
|
||||
UseLongAnnotations: query.NoTrunc,
|
||||
}
|
||||
if _, found := r.URL.Query()["tlsVerify"]; found {
|
||||
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
|
||||
|
||||
Reference in New Issue
Block a user