Skip to content

Commit 9c87a3e

Browse files
authored
Merge pull request #1039 from CircleCI-Public/develop
Release
2 parents c2d98ee + 6b9befe commit 9c87a3e

File tree

7 files changed

+18
-267
lines changed

7 files changed

+18
-267
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ executors:
1818
resource_class: macos.m1.medium.gen1
1919
environment:
2020
CGO_ENABLED: 0
21-
HOMEBREW_NO_AUTO_UPDATE: 1
2221
TERM: xterm-256color
2322

2423
commands:

cmd/.circleci/update_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
last_update_check: 2023-12-11T13:24:04.24843+01:00
1+
last_update_check: 2024-01-11T10:44:52.12818Z

cmd/follow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func followProjectCommand(config *settings.Config) *cobra.Command {
5353
}
5454
followCommand := &cobra.Command{
5555
Use: "follow",
56-
Short: "Attempt to follow the project for the current git repository.",
56+
Short: "Attempt to follow the project for the current git repository.\nThis command is intended to be run from a git repository with a remote named 'origin' that is hosted on Github or Bitbucket only. NOTE: this command is deprecated and is not reliable on Github projects created after September 2023",
5757
RunE: func(cmd *cobra.Command, _ []string) error {
5858
err := followProject(opts)
5959

@@ -64,6 +64,7 @@ func followProjectCommand(config *settings.Config) *cobra.Command {
6464

6565
return err
6666
},
67+
Deprecated: "This command is deprecated and is not reliable on Github projects created after September 2023",
6768
}
6869
return followCommand
6970
}

cmd/namespace.go

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"strings"
65

76
"github.com/CircleCI-Public/circleci-cli/api"
87
"github.com/CircleCI-Public/circleci-cli/api/graphql"
@@ -58,7 +57,7 @@ func newNamespaceCommand(config *settings.Config) *cobra.Command {
5857
}
5958

6059
createCmd := &cobra.Command{
61-
Use: "create <name> [<vcs-type>] [<org-name>]",
60+
Use: "create <name> --org-id <your-organization-id>",
6261
Short: "Create a namespace",
6362
Long: `Create a namespace.
6463
Please note that at this time all namespaces created in the registry are world-readable.`,
@@ -84,15 +83,12 @@ Please note that at this time all namespaces created in the registry are world-r
8483

8584
return err
8685
},
87-
Args: cobra.RangeArgs(1, 3),
86+
Args: cobra.ExactArgs(1),
8887
Annotations: make(map[string]string),
89-
Example: ` circleci namespace create NamespaceName github OrgName
90-
circleci namespace create NamespaceName --org-id "your-org-id-here"`,
88+
Example: ` circleci namespace create NamespaceName --org-id 00000000-0000-0000-0000-000000000000`,
9189
}
9290

9391
createCmd.Annotations["<name>"] = "The name to give your new namespace"
94-
createCmd.Annotations["[<vcs-type>]"] = `Your VCS provider, can be either "github" or "bitbucket". Optional when passing org-id flag.`
95-
createCmd.Annotations["[<org-name>]"] = `The name used for your organization. Optional when passing org-id flag.`
9692

9793
createCmd.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.")
9894
if err := createCmd.Flags().MarkHidden("integration-testing"); err != nil {
@@ -141,42 +137,11 @@ To change the namespace, you will have to contact CircleCI customer support.
141137
return nil
142138
}
143139

144-
func createNamespaceWithVcsTypeAndOrgName(opts namespaceOptions, namespaceName, vcsType, orgName string) error {
145-
if !opts.noPrompt {
146-
fmt.Printf(`You are creating a namespace called "%s".
147-
148-
This is the only namespace permitted for your %s organization, %s.
149-
150-
To change the namespace, you will have to contact CircleCI customer support.
151-
152-
`, namespaceName, strings.ToLower(opts.args[1]), opts.args[2])
153-
}
154-
155-
confirm := fmt.Sprintf("Are you sure you wish to create the namespace: `%s`", namespaceName)
156-
if opts.noPrompt || opts.tty.askUserToConfirm(confirm) {
157-
_, err := api.CreateNamespace(opts.cl, namespaceName, opts.args[2], strings.ToUpper(opts.args[1]))
158-
if err != nil {
159-
return err
160-
}
161-
162-
fmt.Printf("Namespace `%s` created.\n", namespaceName)
163-
fmt.Println("Please note that any orbs you publish in this namespace are open orbs and are world-readable.")
164-
}
165-
return nil
166-
}
167-
168140
func createNamespace(cmd *cobra.Command, opts namespaceOptions) error {
169141
namespaceName := opts.args[0]
170-
//skip if no orgid provided
171-
if opts.orgID != nil && strings.TrimSpace(*opts.orgID) != "" {
172-
_, err := uuid.Parse(*opts.orgID)
173-
if err == nil {
174-
return createNamespaceWithOrgId(opts, namespaceName, *opts.orgID)
175-
}
176-
177-
//skip if no vcs type and org name provided
178-
} else if len(opts.args) == 3 {
179-
return createNamespaceWithVcsTypeAndOrgName(opts, namespaceName, opts.args[1], opts.args[2])
142+
_, err := uuid.Parse(*opts.orgID)
143+
if err == nil {
144+
return createNamespaceWithOrgId(opts, namespaceName, *opts.orgID)
180145
}
181146
return cmd.Help()
182147
}

cmd/namespace_test.go

Lines changed: 0 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/CircleCI-Public/circleci-cli/telemetry"
1010
. "github.com/onsi/ginkgo"
1111
. "github.com/onsi/gomega"
12-
"github.com/onsi/gomega/gbytes"
1312
"github.com/onsi/gomega/gexec"
1413
)
1514

@@ -119,213 +118,5 @@ Namespace %s created.
119118
Please note that any orbs you publish in this namespace are open orbs and are world-readable.`, "foo-ns", "bb604b45-b6b0-4b81-ad80-796f15eddf87", "`foo-ns`", "`foo-ns`")))
120119
})
121120
})
122-
123-
Describe("registering a namespace with OrgName and OrgVcs", func() {
124-
BeforeEach(func() {
125-
command = exec.Command(pathCLI,
126-
"namespace", "create",
127-
"--skip-update-check",
128-
"--token", token,
129-
"--host", tempSettings.TestServer.URL(),
130-
"--integration-testing",
131-
"foo-ns",
132-
"BITBUCKET",
133-
"test-org",
134-
)
135-
})
136-
137-
It("works with organizationName and organizationVcs", func() {
138-
By("setting up a mock server")
139-
140-
gqlOrganizationResponse := `{
141-
"organization": {
142-
"name": "test-org",
143-
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
144-
}
145-
}`
146-
147-
expectedOrganizationRequest := `{
148-
"query": "query($organizationName: String!, $organizationVcs: VCSType!) {\n\t\t\t\torganization(\n\t\t\t\t\tname: $organizationName\n\t\t\t\t\tvcsType: $organizationVcs\n\t\t\t\t) {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}","variables":{"organizationName":"test-org","organizationVcs":"BITBUCKET"}}`
149-
150-
gqlNsResponse := `{
151-
"createNamespace": {
152-
"errors": [],
153-
"namespace": {
154-
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
155-
}
156-
}
157-
}`
158-
159-
expectedNsRequest := `{
160-
"query": "\n\t\t\tmutation($name: String!, $organizationId: UUID!) {\n\t\t\t\tcreateNamespace(\n\t\t\t\t\tname: $name,\n\t\t\t\t\torganizationId: $organizationId\n\t\t\t\t) {\n\t\t\t\t\tnamespace {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t\terrors {\n\t\t\t\t\t\tmessage\n\t\t\t\t\t\ttype\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
161-
"variables": {
162-
"name": "foo-ns",
163-
"organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
164-
}
165-
}`
166-
167-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
168-
Status: http.StatusOK,
169-
Request: expectedOrganizationRequest,
170-
Response: gqlOrganizationResponse})
171-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
172-
Status: http.StatusOK,
173-
Request: expectedNsRequest,
174-
Response: gqlNsResponse})
175-
176-
By("running the command")
177-
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
178-
Expect(err).ShouldNot(HaveOccurred())
179-
Eventually(session).Should(gexec.Exit(0))
180-
181-
stdout := session.Wait().Out.Contents()
182-
183-
Expect(string(stdout)).To(ContainSubstring(fmt.Sprintf(`You are creating a namespace called "%s".
184-
185-
This is the only namespace permitted for your bitbucket organization, test-org.
186-
187-
To change the namespace, you will have to contact CircleCI customer support.
188-
189-
Are you sure you wish to create the namespace: %s
190-
Namespace %s created.
191-
Please note that any orbs you publish in this namespace are open orbs and are world-readable.`, "foo-ns", "`foo-ns`", "`foo-ns`")))
192-
})
193-
})
194-
195-
Describe("when creating / reserving a namespace", func() {
196-
BeforeEach(func() {
197-
command = exec.Command(pathCLI,
198-
"namespace", "create",
199-
"--skip-update-check",
200-
"--token", token,
201-
"--host", tempSettings.TestServer.URL(),
202-
"--integration-testing",
203-
"foo-ns",
204-
"BITBUCKET",
205-
"test-org",
206-
)
207-
})
208-
209-
It("works with organizationName and organizationVcs", func() {
210-
By("setting up a mock server")
211-
212-
gqlOrganizationResponse := `{
213-
"organization": {
214-
"name": "test-org",
215-
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
216-
}
217-
}`
218-
219-
expectedOrganizationRequest := `{
220-
"query": "query($organizationName: String!, $organizationVcs: VCSType!) {\n\t\t\t\torganization(\n\t\t\t\t\tname: $organizationName\n\t\t\t\t\tvcsType: $organizationVcs\n\t\t\t\t) {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}",
221-
"variables": {
222-
"organizationName": "test-org",
223-
"organizationVcs": "BITBUCKET"
224-
}
225-
}`
226-
227-
gqlNsResponse := `{
228-
"createNamespace": {
229-
"errors": [],
230-
"namespace": {
231-
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
232-
}
233-
}
234-
}`
235-
236-
expectedNsRequest := `{
237-
"query": "\n\t\t\tmutation($name: String!, $organizationId: UUID!) {\n\t\t\t\tcreateNamespace(\n\t\t\t\t\tname: $name,\n\t\t\t\t\torganizationId: $organizationId\n\t\t\t\t) {\n\t\t\t\t\tnamespace {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t\terrors {\n\t\t\t\t\t\tmessage\n\t\t\t\t\t\ttype\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
238-
"variables": {
239-
"name": "foo-ns",
240-
"organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
241-
}
242-
}`
243-
244-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
245-
Status: http.StatusOK,
246-
Request: expectedOrganizationRequest,
247-
Response: gqlOrganizationResponse})
248-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
249-
Status: http.StatusOK,
250-
Request: expectedNsRequest,
251-
Response: gqlNsResponse})
252-
253-
By("running the command")
254-
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
255-
Expect(err).ShouldNot(HaveOccurred())
256-
Eventually(session).Should(gexec.Exit(0))
257-
258-
stdout := session.Wait().Out.Contents()
259-
260-
Expect(string(stdout)).To(ContainSubstring(fmt.Sprintf(`You are creating a namespace called "%s".
261-
262-
This is the only namespace permitted for your bitbucket organization, test-org.
263-
264-
To change the namespace, you will have to contact CircleCI customer support.
265-
266-
Are you sure you wish to create the namespace: %s
267-
Namespace %s created.
268-
Please note that any orbs you publish in this namespace are open orbs and are world-readable.`, "foo-ns", "`foo-ns`", "`foo-ns`")))
269-
})
270-
271-
It("prints all in-band errors returned by the GraphQL API", func() {
272-
By("setting up a mock server")
273-
274-
gqlOrganizationResponse := `{
275-
"organization": {
276-
"name": "test-org",
277-
"id": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
278-
}
279-
}`
280-
281-
expectedOrganizationRequest := `{
282-
"query": "query($organizationName: String!, $organizationVcs: VCSType!) {\n\t\t\t\torganization(\n\t\t\t\t\tname: $organizationName\n\t\t\t\t\tvcsType: $organizationVcs\n\t\t\t\t) {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}",
283-
"variables": {
284-
"organizationName": "test-org",
285-
"organizationVcs": "BITBUCKET"
286-
}
287-
}`
288-
289-
gqlResponse := `{
290-
"createNamespace": {
291-
"errors": [
292-
{"message": "error1"},
293-
{"message": "error2"}
294-
],
295-
"namespace": null
296-
}
297-
}`
298-
299-
gqlNativeErrors := `[ { "message": "ignored error" } ]`
300-
301-
expectedRequestJSON := `{
302-
"query": "\n\t\t\tmutation($name: String!, $organizationId: UUID!) {\n\t\t\t\tcreateNamespace(\n\t\t\t\t\tname: $name,\n\t\t\t\t\torganizationId: $organizationId\n\t\t\t\t) {\n\t\t\t\t\tnamespace {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t\terrors {\n\t\t\t\t\t\tmessage\n\t\t\t\t\t\ttype\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
303-
"variables": {
304-
"name": "foo-ns",
305-
"organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87"
306-
}
307-
}`
308-
309-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
310-
Status: http.StatusOK,
311-
Request: expectedOrganizationRequest,
312-
Response: gqlOrganizationResponse,
313-
})
314-
tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
315-
Status: http.StatusOK,
316-
Request: expectedRequestJSON,
317-
Response: gqlResponse,
318-
ErrorResponse: gqlNativeErrors,
319-
})
320-
321-
By("running the command")
322-
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
323-
324-
Expect(err).ShouldNot(HaveOccurred())
325-
Eventually(session.Err).Should(gbytes.Say(`Error: error1
326-
error2`))
327-
Eventually(session).ShouldNot(gexec.Exit(0))
328-
})
329-
})
330121
})
331122
})

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/blang/semver v3.5.1+incompatible
99
github.com/briandowns/spinner v1.23.0
1010
github.com/fatih/color v1.16.0
11-
github.com/go-git/go-git/v5 v5.10.1
11+
github.com/go-git/go-git/v5 v5.11.0
1212
github.com/google/go-querystring v1.1.0 // indirect
1313
github.com/google/uuid v1.4.0
1414
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
@@ -56,7 +56,7 @@ require (
5656
github.com/cespare/xxhash/v2 v2.2.0 // indirect
5757
github.com/charmbracelet/bubbles v0.16.1 // indirect
5858
github.com/charmbracelet/bubbletea v0.24.2 // indirect
59-
github.com/cloudflare/circl v1.3.6 // indirect
59+
github.com/cloudflare/circl v1.3.7 // indirect
6060
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
6161
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
6262
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -71,7 +71,6 @@ require (
7171
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
7272
github.com/golang/protobuf v1.5.3 // indirect
7373
github.com/google/go-cmp v0.6.0 // indirect
74-
github.com/google/go-github v17.0.0+incompatible // indirect
7574
github.com/google/go-github/v30 v30.1.0 // indirect
7675
github.com/gorilla/mux v1.8.1 // indirect
7776
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 // indirect
@@ -114,7 +113,7 @@ require (
114113
go.opentelemetry.io/otel/metric v1.21.0 // indirect
115114
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
116115
go.opentelemetry.io/otel/trace v1.21.0 // indirect
117-
golang.org/x/crypto v0.16.0 // indirect
116+
golang.org/x/crypto v0.17.0 // indirect
118117
golang.org/x/mod v0.14.0 // indirect
119118
golang.org/x/net v0.19.0 // indirect
120119
golang.org/x/sync v0.5.0 // indirect

0 commit comments

Comments
 (0)