Skip to content

Commit

Permalink
cleaned up command output
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Feb 1, 2024
1 parent 0872b39 commit 64c335f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion efs/hello-world/app.yaml
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion efs/hello-world/hack/environments/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: kubefox.xigxog.io/v1alpha1
kind: Environment
metadata:
Expand All @@ -7,8 +8,8 @@ spec:
type: Stable
data:
vars:
subPath: prod
who: Universe
subPath: prod
---
apiVersion: kubefox.xigxog.io/v1alpha1
kind: VirtualEnvironment
Expand Down
1 change: 1 addition & 0 deletions efs/hello-world/hack/environments/qa.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: kubefox.xigxog.io/v1alpha1
kind: Environment
metadata:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 8 additions & 2 deletions internal/repo/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
11 changes: 11 additions & 0 deletions internal/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 64c335f

Please sign in to comment.