Rename sync cmd to reconcile
This commit is contained in:
@@ -71,7 +71,7 @@ var rootCmd = &cobra.Command{
|
||||
--health-check-timeout=2m
|
||||
|
||||
# Trigger a git sync of the Kustomization's source and apply changes
|
||||
tk sync kustomization webapp-dev --with-source
|
||||
tk reconcile kustomization webapp-dev --with-source
|
||||
|
||||
# Suspend a Kustomization reconciliation
|
||||
tk suspend kustomization webapp-dev
|
||||
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var syncCmd = &cobra.Command{
|
||||
Use: "sync",
|
||||
Short: "Synchronize sources and resources",
|
||||
Long: "The sync sub-commands trigger a reconciliation of sources and resources.",
|
||||
var reconcileCmd = &cobra.Command{
|
||||
Use: "reconcile",
|
||||
Short: "Reconcile sources and resources",
|
||||
Long: "The reconcile sub-commands trigger a reconciliation of sources and resources.",
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(syncCmd)
|
||||
rootCmd.AddCommand(reconcileCmd)
|
||||
}
|
||||
@@ -27,19 +27,19 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
)
|
||||
|
||||
var syncKsCmd = &cobra.Command{
|
||||
var reconcileKsCmd = &cobra.Command{
|
||||
Use: "kustomization [name]",
|
||||
Aliases: []string{"ks"},
|
||||
Short: "Synchronize a Kustomization resource",
|
||||
Short: "Reconcile a Kustomization resource",
|
||||
Long: `
|
||||
The sync kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.`,
|
||||
The reconcile kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.`,
|
||||
Example: ` # Trigger a Kustomization apply outside of the reconciliation interval
|
||||
sync kustomization podinfo
|
||||
tk reconcile kustomization podinfo
|
||||
|
||||
# Trigger a sync of the Kustomization's source and apply changes
|
||||
sync kustomization podinfo --with-source
|
||||
tk reconcile kustomization podinfo --with-source
|
||||
`,
|
||||
RunE: syncKsCmdRun,
|
||||
RunE: reconcileKsCmdRun,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -47,12 +47,12 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
syncKsCmd.Flags().BoolVar(&syncKsWithSource, "with-source", false, "synchronize kustomization source")
|
||||
reconcileKsCmd.Flags().BoolVar(&syncKsWithSource, "with-source", false, "reconcile kustomization source")
|
||||
|
||||
syncCmd.AddCommand(syncKsCmd)
|
||||
reconcileCmd.AddCommand(reconcileKsCmd)
|
||||
}
|
||||
|
||||
func syncKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
if len(args) < 1 {
|
||||
return fmt.Errorf("kustomization name is required")
|
||||
}
|
||||
@@ -86,10 +86,10 @@ func syncKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
logger.Actionf("annotating kustomization %s in %s namespace", name, namespace)
|
||||
if kustomization.Annotations == nil {
|
||||
kustomization.Annotations = map[string]string{
|
||||
kustomizev1.SyncAtAnnotation: time.Now().String(),
|
||||
kustomizev1.ReconcileAtAnnotation: time.Now().String(),
|
||||
}
|
||||
} else {
|
||||
kustomization.Annotations[kustomizev1.SyncAtAnnotation] = time.Now().String()
|
||||
kustomization.Annotations[kustomizev1.ReconcileAtAnnotation] = time.Now().String()
|
||||
}
|
||||
if err := kubeClient.Update(ctx, &kustomization); err != nil {
|
||||
return err
|
||||
@@ -97,13 +97,13 @@ func syncKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
logger.Successf("kustomization annotated")
|
||||
}
|
||||
|
||||
logger.Waitingf("waiting for kustomization sync")
|
||||
logger.Waitingf("waiting for kustomization reconciliation")
|
||||
if err := wait.PollImmediate(pollInterval, timeout,
|
||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Successf("kustomization sync completed")
|
||||
logger.Successf("kustomization reconciliation completed")
|
||||
|
||||
err = kubeClient.Get(ctx, namespacedName, &kustomization)
|
||||
if err != nil {
|
||||
@@ -111,7 +111,7 @@ func syncKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if kustomization.Status.LastAppliedRevision != "" {
|
||||
logger.Successf("applied revision %s", kustomization.Status.LastAppliedRevision)
|
||||
logger.Successf("reconciled revision %s", kustomization.Status.LastAppliedRevision)
|
||||
} else {
|
||||
return fmt.Errorf("kustomization sync failed")
|
||||
}
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var syncSourceCmd = &cobra.Command{
|
||||
var reconcileSourceCmd = &cobra.Command{
|
||||
Use: "source",
|
||||
Short: "Synchronize sources",
|
||||
Long: "The sync source sub-commands trigger a reconciliation of sources.",
|
||||
Short: "Reconcile sources",
|
||||
Long: "The reconcile source sub-commands trigger a reconciliation of sources.",
|
||||
}
|
||||
|
||||
func init() {
|
||||
syncCmd.AddCommand(syncSourceCmd)
|
||||
reconcileCmd.AddCommand(reconcileSourceCmd)
|
||||
}
|
||||
@@ -26,18 +26,18 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var syncSourceGitCmd = &cobra.Command{
|
||||
var reconcileSourceGitCmd = &cobra.Command{
|
||||
Use: "git [name]",
|
||||
Short: "Synchronize a GitRepository source",
|
||||
Long: `The sync source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
|
||||
Short: "Reconcile a GitRepository source",
|
||||
Long: `The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
|
||||
Example: ` # Trigger a git pull for an existing source
|
||||
sync source git podinfo
|
||||
tk reconcile source git podinfo
|
||||
`,
|
||||
RunE: syncSourceGitCmdRun,
|
||||
}
|
||||
|
||||
func init() {
|
||||
syncSourceCmd.AddCommand(syncSourceGitCmd)
|
||||
reconcileSourceCmd.AddCommand(reconcileSourceGitCmd)
|
||||
}
|
||||
|
||||
func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||
@@ -68,23 +68,23 @@ func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if gitRepository.Annotations == nil {
|
||||
gitRepository.Annotations = map[string]string{
|
||||
sourcev1.SyncAtAnnotation: time.Now().String(),
|
||||
sourcev1.ReconcileAtAnnotation: time.Now().String(),
|
||||
}
|
||||
} else {
|
||||
gitRepository.Annotations[sourcev1.SyncAtAnnotation] = time.Now().String()
|
||||
gitRepository.Annotations[sourcev1.ReconcileAtAnnotation] = time.Now().String()
|
||||
}
|
||||
if err := kubeClient.Update(ctx, &gitRepository); err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Successf("source annotated")
|
||||
|
||||
logger.Waitingf("waiting for git sync")
|
||||
logger.Waitingf("waiting for reconciliation")
|
||||
if err := wait.PollImmediate(pollInterval, timeout,
|
||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Successf("git sync completed")
|
||||
logger.Successf("git reconciliation completed")
|
||||
|
||||
err = kubeClient.Get(ctx, namespacedName, &gitRepository)
|
||||
if err != nil {
|
||||
@@ -94,7 +94,7 @@ func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||
if gitRepository.Status.Artifact != nil {
|
||||
logger.Successf("fetched revision %s", gitRepository.Status.Artifact.Revision)
|
||||
} else {
|
||||
return fmt.Errorf("git sync failed, artifact not found")
|
||||
return fmt.Errorf("git reconciliation failed, artifact not found")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user