|
|
@ -18,6 +18,10 @@ package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/fluxcd/pkg/apis/meta"
|
|
|
|
"github.com/fluxcd/pkg/apis/meta"
|
|
|
|
|
|
|
|
|
|
|
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
|
|
|
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
|
|
|
@ -50,8 +54,12 @@ func getKsCmdRun(cmd *cobra.Command, args []string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var listOpts []client.ListOption
|
|
|
|
|
|
|
|
if !allNamespaces {
|
|
|
|
|
|
|
|
listOpts = append(listOpts, client.InNamespace(namespace))
|
|
|
|
|
|
|
|
}
|
|
|
|
var list kustomizev1.KustomizationList
|
|
|
|
var list kustomizev1.KustomizationList
|
|
|
|
err = kubeClient.List(ctx, &list, client.InNamespace(namespace))
|
|
|
|
err = kubeClient.List(ctx, &list, listOpts...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,26 +69,35 @@ func getKsCmdRun(cmd *cobra.Command, args []string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, kustomization := range list.Items {
|
|
|
|
header := []string{"Name", "Revision", "Suspended", "Ready", "Message"}
|
|
|
|
if kustomization.Spec.Suspend {
|
|
|
|
if allNamespaces {
|
|
|
|
logger.Successf("%s is suspended", kustomization.GetName())
|
|
|
|
header = append([]string{"Namespace"}, header...)
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isInitialized := false
|
|
|
|
var rows [][]string
|
|
|
|
|
|
|
|
for _, kustomization := range list.Items {
|
|
|
|
|
|
|
|
row := []string{}
|
|
|
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
|
|
|
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
|
|
|
switch c.Status {
|
|
|
|
row = []string{
|
|
|
|
case corev1.ConditionTrue:
|
|
|
|
kustomization.GetName(),
|
|
|
|
logger.Successf("%s last applied revision %s", kustomization.GetName(), kustomization.Status.LastAppliedRevision)
|
|
|
|
kustomization.Status.LastAppliedRevision,
|
|
|
|
case corev1.ConditionUnknown:
|
|
|
|
strings.Title(strconv.FormatBool(kustomization.Spec.Suspend)),
|
|
|
|
logger.Successf("%s reconciling", kustomization.GetName())
|
|
|
|
string(c.Status),
|
|
|
|
default:
|
|
|
|
c.Message,
|
|
|
|
logger.Failuref("%s %s", kustomization.GetName(), c.Message)
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
row = []string{
|
|
|
|
|
|
|
|
kustomization.GetName(),
|
|
|
|
|
|
|
|
kustomization.Status.LastAppliedRevision,
|
|
|
|
|
|
|
|
strings.Title(strconv.FormatBool(kustomization.Spec.Suspend)),
|
|
|
|
|
|
|
|
string(corev1.ConditionFalse),
|
|
|
|
|
|
|
|
"waiting to be reconciled",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isInitialized = true
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !isInitialized {
|
|
|
|
if allNamespaces {
|
|
|
|
logger.Failuref("%s is not ready", kustomization.GetName())
|
|
|
|
row = append([]string{kustomization.Namespace}, row...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rows = append(rows, row)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
utils.printTable(os.Stdout, header, rows)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|