From 6bd27d27ecfc2b9777ecc6f272b243f3deaff720 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 May 2021 21:35:23 +0200 Subject: [PATCH] outpost: use shorter API Calls Signed-off-by: Jens Langhammer --- outpost/pkg/ak/api.go | 2 +- outpost/pkg/ak/api_update.go | 2 +- outpost/pkg/ldap/api.go | 2 +- outpost/pkg/ldap/instance_search.go | 4 ++-- outpost/pkg/proxy/api_bundle.go | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/outpost/pkg/ak/api.go b/outpost/pkg/ak/api.go index e63b50bc0..f39d880f0 100644 --- a/outpost/pkg/ak/api.go +++ b/outpost/pkg/ak/api.go @@ -55,7 +55,7 @@ func NewAPIController(akURL url.URL, token string) *APIController { // Because we don't know the outpost UUID, we simply do a list and pick the first // The service account this token belongs to should only have access to a single outpost - outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesListExecute(apiClient.OutpostsApi.OutpostsInstancesList(context.Background())) + outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute() if err != nil { log.WithError(err).Error("Failed to fetch configuration") diff --git a/outpost/pkg/ak/api_update.go b/outpost/pkg/ak/api_update.go index 6584094fb..d2fea76ab 100644 --- a/outpost/pkg/ak/api_update.go +++ b/outpost/pkg/ak/api_update.go @@ -7,7 +7,7 @@ import ( ) func (a *APIController) Update() ([]api.ProxyOutpostConfig, error) { - providers, _, err := a.Client.OutpostsApi.OutpostsProxyListExecute(a.Client.OutpostsApi.OutpostsProxyList(context.Background())) + providers, _, err := a.Client.OutpostsApi.OutpostsProxyList(context.Background()).Execute() if err != nil { a.logger.WithError(err).Error("Failed to fetch providers") return nil, err diff --git a/outpost/pkg/ldap/api.go b/outpost/pkg/ldap/api.go index 06a01fc4e..33ef3f307 100644 --- a/outpost/pkg/ldap/api.go +++ b/outpost/pkg/ldap/api.go @@ -13,7 +13,7 @@ import ( ) func (ls *LDAPServer) Refresh() error { - outposts, _, err := ls.ac.Client.OutpostsApi.OutpostsLdapListExecute(ls.ac.Client.OutpostsApi.OutpostsLdapList(context.Background())) + outposts, _, err := ls.ac.Client.OutpostsApi.OutpostsLdapList(context.Background()).Execute() if err != nil { return err } diff --git a/outpost/pkg/ldap/instance_search.go b/outpost/pkg/ldap/instance_search.go index 150432718..f5a4462c7 100644 --- a/outpost/pkg/ldap/instance_search.go +++ b/outpost/pkg/ldap/instance_search.go @@ -43,7 +43,7 @@ func (pi *ProviderInstance) Search(bindDN string, searchReq ldap.SearchRequest, default: return ldap.ServerSearchResult{ResultCode: ldap.LDAPResultOperationsError}, fmt.Errorf("Search Error: unhandled filter type: %s [%s]", filterEntity, searchReq.Filter) case GroupObjectClass: - groups, _, err := pi.s.ac.Client.CoreApi.CoreGroupsListExecute(pi.s.ac.Client.CoreApi.CoreGroupsList(context.Background())) + groups, _, err := pi.s.ac.Client.CoreApi.CoreGroupsList(context.Background()).Execute() if err != nil { return ldap.ServerSearchResult{ResultCode: ldap.LDAPResultOperationsError}, fmt.Errorf("API Error: %s", err) } @@ -69,7 +69,7 @@ func (pi *ProviderInstance) Search(bindDN string, searchReq ldap.SearchRequest, entries = append(entries, &ldap.Entry{DN: dn, Attributes: attrs}) } case UserObjectClass, "": - users, _, err := pi.s.ac.Client.CoreApi.CoreUsersListExecute(pi.s.ac.Client.CoreApi.CoreUsersList(context.Background())) + users, _, err := pi.s.ac.Client.CoreApi.CoreUsersList(context.Background()).Execute() if err != nil { return ldap.ServerSearchResult{ResultCode: ldap.LDAPResultOperationsError}, fmt.Errorf("API Error: %s", err) } diff --git a/outpost/pkg/proxy/api_bundle.go b/outpost/pkg/proxy/api_bundle.go index c63044dc8..c23e9bfe0 100644 --- a/outpost/pkg/proxy/api_bundle.go +++ b/outpost/pkg/proxy/api_bundle.go @@ -86,12 +86,12 @@ func (pb *providerBundle) prepareOpts(provider api.ProxyOutpostConfig) *options. if provider.Certificate.Get() != nil { pb.log.WithField("provider", provider.Name).Debug("Enabling TLS") - cert, _, err := pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewCertificateRetrieveExecute(pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewCertificateRetrieve(context.Background(), *provider.Certificate.Get())) + cert, _, err := pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewCertificateRetrieve(context.Background(), *provider.Certificate.Get()).Execute() if err != nil { pb.log.WithField("provider", provider.Name).WithError(err).Warning("Failed to fetch certificate") return providerOpts } - key, _, err := pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewPrivateKeyRetrieveExecute(pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewPrivateKeyRetrieve(context.Background(), *provider.Certificate.Get())) + key, _, err := pb.s.ak.Client.CryptoApi.CryptoCertificatekeypairsViewPrivateKeyRetrieve(context.Background(), *provider.Certificate.Get()).Execute() if err != nil { pb.log.WithField("provider", provider.Name).WithError(err).Warning("Failed to fetch private key") return providerOpts