Skip to content

Commit 0b5ee9d

Browse files
committed
send unsynced resources with status updates
1 parent 077fab2 commit 0b5ee9d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

pkg/streamline/applier/applier.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,40 @@ func (in *Applier) Apply(ctx context.Context,
189189
componentList[idx].Children = lo.ToSlicePtr(children)
190190
}
191191

192+
// Append unsynced resources to the component list so all of them will be visible in the UI.
193+
componentList = in.appendUnsyncedResources(componentList, resources)
194+
192195
return componentList, serviceErrorList, nil
193196
}
194197

198+
func (in *Applier) appendUnsyncedResources(components []client.ComponentAttributes, resources []unstructured.Unstructured) []client.ComponentAttributes {
199+
result := make([]client.ComponentAttributes, 0)
200+
keys := containers.NewSet[smcommon.Key]()
201+
202+
for _, component := range components {
203+
result = append(result, component)
204+
keys.Add(smcommon.NewStoreKeyFromComponentAttributes(component).Key())
205+
}
206+
207+
for _, resource := range resources {
208+
if !keys.Has(smcommon.NewStoreKeyFromUnstructured(resource).Key()) {
209+
gvk := resource.GroupVersionKind()
210+
result = append(result, client.ComponentAttributes{
211+
Group: gvk.Group,
212+
Version: gvk.Version,
213+
Kind: gvk.Kind,
214+
Name: resource.GetName(),
215+
Namespace: resource.GetNamespace(),
216+
// TODO: Set following fields based on resource/phase processing status.
217+
Synced: false,
218+
State: nil,
219+
})
220+
}
221+
}
222+
223+
return result
224+
}
225+
195226
func (in *Applier) Destroy(ctx context.Context, serviceID string) ([]client.ComponentAttributes, error) {
196227
deleted := 0
197228
deleteFilterFunc, err := in.getDeleteFilterFunc(serviceID)

pkg/streamline/common/key.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package common
33
import (
44
"fmt"
55

6+
"github.com/pluralsh/console/go/client"
67
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
78
"k8s.io/apimachinery/pkg/runtime/schema"
89
)
@@ -54,3 +55,11 @@ func (in StoreKey) ReplaceGroup(group string) StoreKey {
5455
func NewStoreKeyFromUnstructured(u unstructured.Unstructured) StoreKey {
5556
return StoreKey{GVK: u.GroupVersionKind(), Namespace: u.GetNamespace(), Name: u.GetName()}
5657
}
58+
59+
func NewStoreKeyFromComponentAttributes(a client.ComponentAttributes) StoreKey {
60+
return StoreKey{
61+
GVK: schema.GroupVersionKind{Group: a.Group, Version: a.Version, Kind: a.Kind},
62+
Namespace: a.Namespace,
63+
Name: a.Name,
64+
}
65+
}

pkg/streamline/status_synchronizer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func (in *StatusSynchronizer) UpdateServiceComponents(serviceId string, componen
5656
return nil
5757
}
5858

59+
// TODO: Sync statuses of components that were not processed yet.
60+
5961
if err = in.client.UpdateComponents(serviceId, "", nil, components, nil, nil); err != nil {
6062
return err
6163
}

0 commit comments

Comments
 (0)