diff --git a/internal/juju/applications.go b/internal/juju/applications.go index d06ea2d1..0e6f55e4 100644 --- a/internal/juju/applications.go +++ b/internal/juju/applications.go @@ -915,12 +915,12 @@ func (c applicationsClient) ReadApplication(input *ReadApplicationInput) (*ReadA appInfo := apps[0].Result - // We are currently retrieving the full status, which might be more information than necessary. - // The main focus is on the application status, particularly including the storage status. - // It might be more efficient to directly query for the application status and its associated storage status. - // TODO: Investigate if there's a way to optimize this by only fetching the required information. + // Fetch data only about the application being read. This helps to limit + // the data on storage to the specific application too. Storage is not + // provided by application, rather storage data buries a unit name deep + // in the structure. status, err := clientAPIClient.Status(&apiclient.StatusArgs{ - Patterns: []string{}, + Patterns: []string{input.AppName}, IncludeStorage: true, }) if err != nil { diff --git a/internal/provider/resource_application_test.go b/internal/provider/resource_application_test.go index 279e17d2..a931dbb6 100644 --- a/internal/provider/resource_application_test.go +++ b/internal/provider/resource_application_test.go @@ -43,6 +43,7 @@ func TestAcc_ResourceApplication(t *testing.T) { resource.TestCheckResourceAttr("juju_application.this", "charm.0.name", "jameinel-ubuntu-lite"), resource.TestCheckResourceAttr("juju_application.this", "trust", "true"), resource.TestCheckResourceAttr("juju_application.this", "expose.#", "1"), + resource.TestCheckNoResourceAttr("juju_application.this", "storage"), ), }, {