From f698600fd38e65f5ea22c3ab9ed62c10bdddb50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20K=C3=A4ldstr=C3=B6m?= Date: Wed, 29 Jul 2020 15:06:59 +0300 Subject: [PATCH] Make sure the repository/organization pointed to by the refs in ResourceClient exists, in order to fail fast, and access the object directly. --- client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 0d54b10f..c2984cbe 100644 --- a/client.go +++ b/client.go @@ -39,19 +39,23 @@ type Client interface { // ResourceClient allows access to resource-specific clients type ResourceClient interface { - // Organization gets the OrganizationClient for the specific top-level organization, or user account. + // Organization gets the OrganizationClient for a specific top-level organization. + // It is ensured that the organization the reference points to exists, as it's looked up + // and returned as the second argument. // // ErrNotTopLevelOrganization will be returned at usage time if the organization is not top-level. // ErrNotFound is returned if the organization does not exist. - Organization(o OrganizationRef) (OrganizationClient, error) + Organization(ctx context.Context, o OrganizationRef) (OrganizationClient, *Organization, error) // Organizations returns the OrganizationsClient handling sets of organizations. Organizations() OrganizationsClient // Repository gets the RepositoryClient for the specified RepositoryRef. + // It is ensured that the repository the reference points to exists, as it's looked up + // and returned as the second argument. // // ErrNotFound is returned if the repository does not exist. - Repository(r RepositoryRef) (RepositoryClient, error) + Repository(ctx context.Context, r RepositoryRef) (RepositoryClient, *Repository, error) // Repositories returns the RepositoriesClient handling sets of organizations. Repositories() RepositoriesClient