-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add org-slug and org-id flags to orb validate & process commands
- Loading branch information
Showing
5 changed files
with
161 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package collaborators | ||
|
||
type CollaborationResult struct { | ||
VcsTye string `json:"vcs_type"` | ||
OrgSlug string `json:"slug"` | ||
OrgName string `json:"name"` | ||
OrgId string `json:"id"` | ||
AvatarUrl string `json:"avatar_url"` | ||
} | ||
|
||
type CollaboratorsClient interface { | ||
GetOrgCollaborations() ([]CollaborationResult, error) | ||
} | ||
|
||
// GetOrgIdFromSlug - converts a slug into an orgID. | ||
func GetOrgIdFromSlug(slug string, collaborations []CollaborationResult) string { | ||
for _, v := range collaborations { | ||
if v.OrgSlug == slug { | ||
return v.OrgId | ||
} | ||
} | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package collaborators | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/CircleCI-Public/circleci-cli/api/rest" | ||
"github.com/CircleCI-Public/circleci-cli/settings" | ||
) | ||
|
||
var ( | ||
CollaborationsPath = "me/collaborations" | ||
) | ||
|
||
type collaboratorsRestClient struct { | ||
client *rest.Client | ||
} | ||
|
||
// NewCollaboratorsRestClient returns a new collaboratorsRestClient satisfying the api.CollaboratorsClient | ||
// interface via the REST API. | ||
func NewCollaboratorsRestClient(config settings.Config) (*collaboratorsRestClient, error) { | ||
client := &collaboratorsRestClient{ | ||
client: rest.NewFromConfig(config.Host, &config), | ||
} | ||
return client, nil | ||
} | ||
|
||
func (c *collaboratorsRestClient) GetOrgCollaborations() ([]CollaborationResult, error) { | ||
req, err := c.client.NewRequest("GET", &url.URL{Path: CollaborationsPath}, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp []CollaborationResult | ||
_, err = c.client.DoRequest(req, &resp) | ||
return resp, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters