From dae1642c5d03911e98cb4af4ca3cf1d126e6accc Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 2 May 2024 13:13:30 +0200 Subject: [PATCH] Add ToLibraryList() for ClusterStatusResponse (#906) ## Changes There are a few issues with the response types for libraries APIs today. Recently, a breaking change was made in the return type of the ClusterStatuses() API, changing from ClusterLibraryStatus to ClusterStatusResponse. To unblock the release, I've implemented ToLibraryList() on this new type. As a follow-up, I will unify the ClusterLibraryStatuses and ClusterStatusResponse structs into a single type and clean up any duplication that is introduced by this PR. ## Tests Using `replace` in the Terraform provider's `go.mod`, I made sure that the TF provider's code still compiles after renaming `ClusterLibraryStatus` to `ClusterStatusResponse`. - [ ] `make test` passing - [ ] `make fmt` applied - [ ] relevant integration tests applied --- service/compute/library_utilities.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/service/compute/library_utilities.go b/service/compute/library_utilities.go index d43eecb6f..c4ef084f2 100644 --- a/service/compute/library_utilities.go +++ b/service/compute/library_utilities.go @@ -60,6 +60,16 @@ func (cls ClusterLibraryStatuses) ToLibraryList() InstallLibraries { return cll } +// ToLibraryList convert to envity for convenient comparison +func (cls ClusterStatusResponse) ToLibraryList() InstallLibraries { + cll := InstallLibraries{ClusterId: cls.ClusterId} + for _, lib := range cls.LibraryStatuses { + cll.Libraries = append(cll.Libraries, *lib.Library) + } + cll.Sort() + return cll +} + func (w *Wait) IsNotInScope(lib *Library) bool { // if we don't know concrete libraries if len(w.Libraries) == 0 {