mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-23 22:46:53 +00:00
@@ -64,12 +64,12 @@ func (app *AppFile) BuildOAM(ns string, io cmdutil.IOStreams, tm template.Manage
|
||||
}
|
||||
|
||||
// RenderOAM renders Appfile into AppConfig, Components.
|
||||
func (app *AppFile) RenderOAM(ns string, io cmdutil.IOStreams, tm template.Manager, slience bool) (
|
||||
func (app *AppFile) RenderOAM(ns string, io cmdutil.IOStreams, tm template.Manager, silence bool) (
|
||||
[]*v1alpha2.Component, *v1alpha2.ApplicationConfiguration, []oam.Object, error) {
|
||||
return app.buildOAM(ns, io, false, tm, slience)
|
||||
return app.buildOAM(ns, io, false, tm, silence)
|
||||
}
|
||||
|
||||
func (app *AppFile) buildOAM(ns string, io cmdutil.IOStreams, buildImage bool, tm template.Manager, slience bool) (
|
||||
func (app *AppFile) buildOAM(ns string, io cmdutil.IOStreams, buildImage bool, tm template.Manager, silence bool) (
|
||||
[]*v1alpha2.Component, *v1alpha2.ApplicationConfiguration, []oam.Object, error) {
|
||||
|
||||
appConfig := &v1alpha2.ApplicationConfiguration{
|
||||
@@ -99,7 +99,7 @@ func (app *AppFile) buildOAM(ns string, io cmdutil.IOStreams, buildImage bool, t
|
||||
}
|
||||
}
|
||||
}
|
||||
if !slience {
|
||||
if !silence {
|
||||
io.Infof("\nRendering configs for service (%s)...\n", sname)
|
||||
}
|
||||
acComp, comp, err := svc.RenderService(tm, sname, ns, app.configGetter)
|
||||
|
||||
@@ -221,8 +221,8 @@ func (app *Application) GetTraitsByType(componentName, traitType string) (map[st
|
||||
}
|
||||
|
||||
// TODO(wonderflow) add scope support here
|
||||
func (app *Application) OAM(env *types.EnvMeta, io cmdutil.IOStreams, slience bool) ([]*v1alpha2.Component, *v1alpha2.ApplicationConfiguration, []oam.Object, error) {
|
||||
comps, appConfig, scopes, err := app.RenderOAM(env.Namespace, io, app.tm, slience)
|
||||
func (app *Application) OAM(env *types.EnvMeta, io cmdutil.IOStreams, silence bool) ([]*v1alpha2.Component, *v1alpha2.ApplicationConfiguration, []oam.Object, error) {
|
||||
comps, appConfig, scopes, err := app.RenderOAM(env.Namespace, io, app.tm, silence)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
+8
-2
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/crossplane/oam-kubernetes-runtime/apis/core/v1alpha2"
|
||||
|
||||
gocmp "github.com/google/go-cmp/cmp"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -70,13 +72,13 @@ func printComponentList(ctx context.Context, c client.Client, appName string, en
|
||||
}
|
||||
|
||||
func mergeStagingComponents(deployed []apis.ComponentMeta, env *types.EnvMeta, ioStreams cmdutil.IOStreams) []apis.ComponentMeta {
|
||||
apps, err := application.List(env.Name)
|
||||
localApps, err := application.List(env.Name)
|
||||
if err != nil {
|
||||
ioStreams.Error("list application err", err)
|
||||
return deployed
|
||||
}
|
||||
var all []apis.ComponentMeta
|
||||
for _, app := range apps {
|
||||
for _, app := range localApps {
|
||||
comps, appConfig, _, err := app.OAM(env, ioStreams, true)
|
||||
if err != nil {
|
||||
ioStreams.Errorf("convert app %s err %v\n", app.Name, err)
|
||||
@@ -113,7 +115,11 @@ func mergeStagingComponents(deployed []apis.ComponentMeta, env *types.EnvMeta, i
|
||||
v.Traits[j] = t
|
||||
}
|
||||
aspec.Components[i] = v
|
||||
if compMeta.AppConfig.Spec.Components[i].Traits == nil && len(v.Traits) == 0 {
|
||||
compMeta.AppConfig.Spec.Components[i].Traits = make([]v1alpha2.ComponentTrait, 0)
|
||||
}
|
||||
}
|
||||
|
||||
if !gocmp.Equal(compMeta.Component.Spec, *cspec) || !gocmp.Equal(compMeta.AppConfig.Spec, *aspec) {
|
||||
compMeta.Status = types.StatusStaging
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/crossplane/oam-kubernetes-runtime/pkg/oam"
|
||||
|
||||
"github.com/oam-dev/kubevela/api/v1alpha1"
|
||||
|
||||
"github.com/crossplane/oam-kubernetes-runtime/apis/core/v1alpha2"
|
||||
@@ -134,7 +136,7 @@ var _ = Describe("Route Trait Integration Test", func() {
|
||||
"kind": "Route",
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": map[string]interface{}{
|
||||
"trait.oam.dev/type": "route",
|
||||
oam.TraitTypeLabel: "route",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user