Skip to content

Commit

Permalink
Merge pull request #795 from CircleCI-Public/remove-source
Browse files Browse the repository at this point in the history
[EXT-637] Only retrieve source with details flag
  • Loading branch information
am-bui authored Oct 11, 2022
2 parents 37e2fc3 + 5b23495 commit cbf9fec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
15 changes: 11 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ query namespaceOrbs ($namespace: String, $after: String!) {
// ListNamespaceOrbs queries the API to find all orbs belonging to the given
// namespace.
// Returns a collection of Orb objects containing their relevant data.
func ListNamespaceOrbs(cl *graphql.Client, namespace string, isPrivate bool) (*OrbsForListing, error) {
func ListNamespaceOrbs(cl *graphql.Client, namespace string, isPrivate, showDetails bool) (*OrbsForListing, error) {
l := log.New(os.Stderr, "", 0)

query := `
Expand All @@ -1685,9 +1685,15 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
edges {
cursor
node {
versions {
source
version
versions `

if showDetails {
query += `(count: 1){ source,`
} else {
query += `{`
}

query += ` version
}
name
statistics {
Expand All @@ -1705,6 +1711,7 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
}
}
`

var orbs OrbsForListing
var result NamespaceOrbResponse
currentCursor := ""
Expand Down
6 changes: 3 additions & 3 deletions cmd/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var _ = Describe("Namespace integration tests", func() {
}`

expectedListOrbsRequest := `{
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions {\n\t\t\t\t\t\tsource\n\t\t\t\t\t\tversion\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions { version\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"variables": {
"after": "",
"namespace": "foo-ns",
Expand Down Expand Up @@ -236,7 +236,7 @@ var _ = Describe("Namespace integration tests", func() {
}`

expectedListOrbsRequest := `{
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions {\n\t\t\t\t\t\tsource\n\t\t\t\t\t\tversion\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions { version\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"variables": {
"after": "",
"namespace": "foo-ns",
Expand Down Expand Up @@ -310,7 +310,7 @@ var _ = Describe("Namespace integration tests", func() {
}`

expectedListOrbsRequest := `{
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions {\n\t\t\t\t\t\tsource\n\t\t\t\t\t\tversion\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"query": "\nquery namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType) {\n\tregistryNamespace(name: $namespace) {\n\t\tname\n id\n\t\torbs(first: 20, after: $after, view: $view) {\n\t\t\tedges {\n\t\t\t\tcursor\n\t\t\t\tnode {\n\t\t\t\t\tversions { version\n\t\t\t\t\t}\n\t\t\t\t\tname\n\t statistics {\n\t\t last30DaysBuildCount,\n\t\t last30DaysProjectCount,\n\t\t last30DaysOrganizationCount\n\t }\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\thasNextPage\n\t\t\t}\n\t\t}\n\t}\n}\n",
"variables": {
"after": "",
"namespace": "foo-ns",
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func listOrbs(opts orbOptions) error {
func listNamespaceOrbs(opts orbOptions) error {
namespace := opts.args[0]

orbs, err := api.ListNamespaceOrbs(opts.cl, namespace, opts.private)
orbs, err := api.ListNamespaceOrbs(opts.cl, namespace, opts.private, opts.listDetails)
if err != nil {
return errors.Wrapf(err, "Failed to list orbs in namespace `%s`", namespace)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func deleteNamespace(nsOpts namespaceOptions) error {

// Currently, private orbs will not be included in the list of orbs to be deleted.
// This can be changed once we have 'listBothPublicAndPrivateOrbs' functionality.
orbs, err := api.ListNamespaceOrbs(nsOpts.cl, namespaceArg, false)
orbs, err := api.ListNamespaceOrbs(nsOpts.cl, namespaceArg, false, false)
if err != nil {
return fmt.Errorf("unable to list orbs: %s", err.Error())
}
Expand Down
14 changes: 5 additions & 9 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,7 @@ Search, filter, and view sources for all Orbs online at https://circleci.com/dev
tmpBytes := golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_details/pretty_json_output.json"))
expectedOutput := string(tmpBytes)
completeOutput := string(session.Wait().Out.Contents())

Expect(completeOutput).Should(MatchJSON(expectedOutput))
Expect(tempSettings.TestServer.ReceivedRequests()).Should(HaveLen(1))
})
Expand All @@ -2313,9 +2314,7 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
edges {
cursor
node {
versions {
source
version
versions (count: 1){ source, version
}
name
statistics {
Expand Down Expand Up @@ -2390,6 +2389,7 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
"orb", "list", "circleci",
"--skip-update-check",
"--host", tempSettings.TestServer.URL(),
"--details",
"--json",
)
})
Expand Down Expand Up @@ -2429,9 +2429,7 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
edges {
cursor
node {
versions {
source
version
versions { version
}
name
statistics {
Expand Down Expand Up @@ -2491,9 +2489,7 @@ query namespaceOrbs ($namespace: String, $after: String!, $view: OrbListViewType
edges {
cursor
node {
versions {
source
version
versions { version
}
name
statistics {
Expand Down

0 comments on commit cbf9fec

Please sign in to comment.