From 64c335f083e859122bef908726f1252974084585 Mon Sep 17 00:00:00 2001 From: John Long Date: Thu, 1 Feb 2024 12:26:34 -0500 Subject: [PATCH] cleaned up command output --- cmd/deploy.go | 2 ++ cmd/publish.go | 6 ++++-- cmd/release.go | 2 ++ efs/hello-world/app.yaml | 2 +- efs/hello-world/hack/environments/prod.yaml | 3 ++- efs/hello-world/hack/environments/qa.yaml | 1 + go.mod | 2 +- go.sum | 4 ++-- internal/repo/deploy.go | 10 ++++++++-- internal/repo/release.go | 11 +++++++++++ 10 files changed, 34 insertions(+), 9 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 37ad7b0..4f981c6 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -57,7 +57,9 @@ func runDeploy(cmd *cobra.Command, args []string) error { d := repo.New(cfg).Deploy(false) // Makes output less cluttered. + d.Annotations = nil d.ManagedFields = nil + log.Marshal(d) return nil diff --git a/cmd/publish.go b/cmd/publish.go index bb2cffc..9c2f1ff 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -49,10 +49,12 @@ func runPublish(cmd *cobra.Command, args []string) error { checkCommonDeployFlags() } - r := repo.New(cfg) - d := r.Publish() + d := repo.New(cfg).Publish() + // Makes output less cluttered. + d.Annotations = nil d.ManagedFields = nil + log.Marshal(d) return nil diff --git a/cmd/release.go b/cmd/release.go index 53e49c9..fd1e800 100644 --- a/cmd/release.go +++ b/cmd/release.go @@ -60,6 +60,8 @@ func release(cmd *cobra.Command, args []string) { env := repo.New(cfg).Release(appDepId) // Makes output less cluttered. + env.Annotations = nil env.ManagedFields = nil + log.Marshal(env) } diff --git a/efs/hello-world/app.yaml b/efs/hello-world/app.yaml index 230c04e..c4f8f9f 100644 --- a/efs/hello-world/app.yaml +++ b/efs/hello-world/app.yaml @@ -1,3 +1,3 @@ name: hello-world title: Hello World -description: A simple app demonstrating the use of KubeFox. +description: A simple App demonstrating the use of KubeFox. diff --git a/efs/hello-world/hack/environments/prod.yaml b/efs/hello-world/hack/environments/prod.yaml index affd774..c87587b 100644 --- a/efs/hello-world/hack/environments/prod.yaml +++ b/efs/hello-world/hack/environments/prod.yaml @@ -1,3 +1,4 @@ +--- apiVersion: kubefox.xigxog.io/v1alpha1 kind: Environment metadata: @@ -7,8 +8,8 @@ spec: type: Stable data: vars: - subPath: prod who: Universe + subPath: prod --- apiVersion: kubefox.xigxog.io/v1alpha1 kind: VirtualEnvironment diff --git a/efs/hello-world/hack/environments/qa.yaml b/efs/hello-world/hack/environments/qa.yaml index 3c69ce1..3958370 100644 --- a/efs/hello-world/hack/environments/qa.yaml +++ b/efs/hello-world/hack/environments/qa.yaml @@ -1,3 +1,4 @@ +--- apiVersion: kubefox.xigxog.io/v1alpha1 kind: Environment metadata: diff --git a/go.mod b/go.mod index 6ee8192..7c99524 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/xigxog/kubefox v0.4.0-alpha.0.20240131193148-d4e9ca5702dc + github.com/xigxog/kubefox v0.4.0-alpha.0.20240201172225-6ca281a7189a gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.29.1 k8s.io/apimachinery v0.29.1 diff --git a/go.sum b/go.sum index 24f64c0..c11191e 100644 --- a/go.sum +++ b/go.sum @@ -234,8 +234,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xigxog/kubefox v0.4.0-alpha.0.20240131193148-d4e9ca5702dc h1:HZ1G0Q3DpNMQ8nK8AfIUTcgwafP1R/xlEQ1jnpX6h/c= -github.com/xigxog/kubefox v0.4.0-alpha.0.20240131193148-d4e9ca5702dc/go.mod h1:yAM9kmrDh2o+ynzpKsLavRwYrS36L5MYBmUxXjYrjIw= +github.com/xigxog/kubefox v0.4.0-alpha.0.20240201172225-6ca281a7189a h1:T1EeEsFCQeFUCjV66ffiDKl7lcBqyKngtYXutaQq+/Y= +github.com/xigxog/kubefox v0.4.0-alpha.0.20240201172225-6ca281a7189a/go.mod h1:yAM9kmrDh2o+ynzpKsLavRwYrS36L5MYBmUxXjYrjIw= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/internal/repo/deploy.go b/internal/repo/deploy.go index fa33268..80d0dff 100644 --- a/internal/repo/deploy.go +++ b/internal/repo/deploy.go @@ -23,6 +23,7 @@ import ( foxutils "github.com/xigxog/fox/internal/utils" "github.com/xigxog/kubefox/api" "github.com/xigxog/kubefox/api/kubernetes/v1alpha1" + "github.com/xigxog/kubefox/k8s" "github.com/xigxog/kubefox/utils" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -50,8 +51,6 @@ func (r *repo) Deploy(skipImageCheck bool) *v1alpha1.AppDeployment { } } - log.Info("n: %s, ad: %s, v: %s, appName: %s", name, r.cfg.Flags.AppDeployment, r.cfg.Flags.Version, r.app.Name) - p, appDep := r.prepareDeployment(skipImageCheck) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) @@ -72,6 +71,11 @@ func (r *repo) Deploy(skipImageCheck bool) *v1alpha1.AppDeployment { r.waitForReady(p, &appDep.Spec) + // Get updated status. + if err := r.k8s.Get(ctx, k8s.Key(appDep.Namespace, appDep.Name), appDep); err != nil { + log.Fatal("Error getting updated AppDeployment: %v", err) + } + return appDep } @@ -271,6 +275,8 @@ func (r *repo) extractCompDef(compName string, comp *api.ComponentDefinition) er func (r *repo) waitForReady(p *v1alpha1.Platform, spec *v1alpha1.AppDeploymentSpec) { if r.cfg.Flags.WaitTime <= 0 || r.cfg.Flags.DryRun { + // Add small delay to allow resource status updates. + time.Sleep(time.Second) return } diff --git a/internal/repo/release.go b/internal/repo/release.go index 49f029f..791c8cc 100644 --- a/internal/repo/release.go +++ b/internal/repo/release.go @@ -21,6 +21,7 @@ import ( "github.com/xigxog/kubefox/api/kubernetes/v1alpha1" "github.com/xigxog/kubefox/core" "github.com/xigxog/kubefox/k8s" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -84,6 +85,16 @@ func (r *repo) Release(appDepId string) *v1alpha1.VirtualEnvironment { r.waitForReady(platform, &appDep.Spec) + // Get updated status. + if err := r.k8s.Get(ctx, k8s.Key(ve.Namespace, ve.Name), ve); err != nil { + log.Fatal("Error getting updated VirtualEnvironment: %v", err) + } + + ve.TypeMeta = metav1.TypeMeta{ + Kind: "VirtualEnvironment", + APIVersion: v1alpha1.GroupVersion.Identifier(), + } + return ve }