@@ -189,9 +189,60 @@ 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 , err = in .appendUnsyncedResources (service .ID , componentList , resources )
194+
192195 return componentList , serviceErrorList , nil
193196}
194197
198+ func (in * Applier ) appendUnsyncedResources (serviceId string , components []client.ComponentAttributes , resources []unstructured.Unstructured ) ([]client.ComponentAttributes , error ) {
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+ hooks , err := in .store .GetHookComponents (serviceId )
208+ if err != nil {
209+ return nil , err
210+ }
211+
212+ // Create a map of hooks for an easy lookup.
213+ keyToHookComponent := make (map [smcommon.Key ]smcommon.HookComponent )
214+ for _ , hook := range hooks {
215+ keyToHookComponent [hook .StoreKey ().Key ()] = hook
216+ }
217+
218+ for _ , resource := range resources {
219+ key := smcommon .NewStoreKeyFromUnstructured (resource ).Key ()
220+
221+ if ! keys .Has (key ) {
222+ // If a resource has any delete policy, check if it was already deleted.
223+ // If it was deleted, then do not include it in the result.
224+ deletePolicies := smcommon .ParseHookDeletePolicy (resource )
225+ hook , ok := keyToHookComponent [key ]
226+ if len (deletePolicies ) > 0 && ok && hook .HasDesiredState (deletePolicies ) {
227+ continue
228+ }
229+
230+ gvk := resource .GroupVersionKind ()
231+ result = append (result , client.ComponentAttributes {
232+ Group : gvk .Group ,
233+ Version : gvk .Version ,
234+ Kind : gvk .Kind ,
235+ Name : resource .GetName (),
236+ Namespace : resource .GetNamespace (),
237+ Synced : false ,
238+ State : lo .ToPtr (client .ComponentStatePending ),
239+ })
240+ }
241+ }
242+
243+ return result , nil
244+ }
245+
195246func (in * Applier ) Destroy (ctx context.Context , serviceID string ) ([]client.ComponentAttributes , error ) {
196247 deleted := 0
197248 deleteFilterFunc , err := in .getDeleteFilterFunc (serviceID )
0 commit comments