From 4f868461a882b0a83bff3ec767b5bc0beabbeb66 Mon Sep 17 00:00:00 2001 From: Charles Francoise Date: Mon, 11 Dec 2023 16:47:47 +0100 Subject: [PATCH 01/10] ci: restore brew autoupdate (#1025) --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 13b92383c..945143e17 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,6 @@ executors: resource_class: macos.m1.medium.gen1 environment: CGO_ENABLED: 0 - HOMEBREW_NO_AUTO_UPDATE: 1 TERM: xterm-256color commands: From caf170baafb544dabb50d9160ea35a486382f026 Mon Sep 17 00:00:00 2001 From: Bryan Johnson Date: Thu, 14 Dec 2023 10:03:15 -0500 Subject: [PATCH 02/10] Enrich github prompt to capture organization ID for GitHub App integration users --- cmd/orb.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/orb.go b/cmd/orb.go index e77097157..224d0f9d7 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -17,6 +17,12 @@ import ( "strings" "time" + "github.com/fatih/color" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "golang.org/x/exp/slices" + "gopkg.in/yaml.v3" + "github.com/CircleCI-Public/circleci-cli/api" "github.com/CircleCI-Public/circleci-cli/api/collaborators" "github.com/CircleCI-Public/circleci-cli/api/graphql" @@ -28,11 +34,6 @@ import ( "github.com/CircleCI-Public/circleci-cli/settings" "github.com/CircleCI-Public/circleci-cli/telemetry" "github.com/CircleCI-Public/circleci-cli/version" - "github.com/fatih/color" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "golang.org/x/exp/slices" - "gopkg.in/yaml.v3" "github.com/AlecAivazis/survey/v2" "github.com/go-git/go-git/v5" @@ -1301,6 +1302,12 @@ func initOrb(opts orbOptions) error { Message: fmt.Sprintf("Enter your %s username or organization", vcsProvider), Default: opts.cfg.OrbPublishing.DefaultOwner, } + if vcsProvider == "GitHub" { + iprompt = &survey.Input{ + Message: fmt.Sprintf("If your organization is using CircleCI’s GitHub App integration (see %s to check), enter your organization ID found in Organization Settings. If not, enter your organization name as a string.", + "https://circleci.com/docs/github-apps-integration/"), + } + } err = survey.AskOne(iprompt, &ownerName) if err != nil { return err From d78516c1999028f8ba5cd718bebf5704ce385e62 Mon Sep 17 00:00:00 2001 From: abdelDriowya <111757332+abdelDriowya@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:26:51 +0100 Subject: [PATCH 03/10] deprecate follow command --- cmd/follow.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/follow.go b/cmd/follow.go index 9512423ee..67a92c552 100644 --- a/cmd/follow.go +++ b/cmd/follow.go @@ -53,7 +53,7 @@ func followProjectCommand(config *settings.Config) *cobra.Command { } followCommand := &cobra.Command{ Use: "follow", - Short: "Attempt to follow the project for the current git repository.", + 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", RunE: func(cmd *cobra.Command, _ []string) error { err := followProject(opts) @@ -64,6 +64,7 @@ func followProjectCommand(config *settings.Config) *cobra.Command { return err }, + Deprecated: "This command is deprecated and is not reliable on Github projects created after September 2023", } return followCommand } From 5acc30c9684b5899b7017d6a6ae92ff9ea7965f1 Mon Sep 17 00:00:00 2001 From: George Livas Date: Mon, 8 Jan 2024 15:29:22 +0000 Subject: [PATCH 04/10] update docs --- cmd/namespace.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/namespace.go b/cmd/namespace.go index 37cf6cbab..799131ada 100644 --- a/cmd/namespace.go +++ b/cmd/namespace.go @@ -58,7 +58,7 @@ func newNamespaceCommand(config *settings.Config) *cobra.Command { } createCmd := &cobra.Command{ - Use: "create [] []", + Use: "create --org-id ", Short: "Create a namespace", Long: `Create a namespace. Please note that at this time all namespaces created in the registry are world-readable.`, @@ -86,13 +86,10 @@ Please note that at this time all namespaces created in the registry are world-r }, Args: cobra.RangeArgs(1, 3), Annotations: make(map[string]string), - Example: ` circleci namespace create NamespaceName github OrgName - circleci namespace create NamespaceName --org-id "your-org-id-here"`, + Example: ` circleci namespace create NamespaceName --org-id 00000000-0000-0000-0000-000000000000`, } createCmd.Annotations[""] = "The name to give your new namespace" - createCmd.Annotations["[]"] = `Your VCS provider, can be either "github" or "bitbucket". Optional when passing org-id flag.` - createCmd.Annotations["[]"] = `The name used for your organization. Optional when passing org-id flag.` createCmd.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") if err := createCmd.Flags().MarkHidden("integration-testing"); err != nil { From eb7e96613bd26f589c21d579a697b1cdc573bd60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:53:54 +0000 Subject: [PATCH 05/10] chore(deps): bump github.com/cloudflare/circl from 1.3.6 to 1.3.7 Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.6 to 1.3.7. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.3.6...v1.3.7) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 5 ++--- go.sum | 14 ++++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index d78740d26..28cb4da21 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/charmbracelet/bubbles v0.16.1 // indirect github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/cloudflare/circl v1.3.6 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -71,7 +71,6 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-github v17.0.0+incompatible // indirect github.com/google/go-github/v30 v30.1.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 // indirect @@ -114,7 +113,7 @@ require ( go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/go.sum b/go.sum index 02ce9c2a4..1f39b56ed 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FD github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg= github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.6 h1:/xbKIqSHbZXHwkhbrhrt2YOHIwYJlXH94E3tI/gDlUg= -github.com/cloudflare/circl v1.3.6/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -147,8 +147,6 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= -github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo= github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= @@ -259,8 +257,6 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rhysd/go-github-selfupdate v0.0.0-20180520142321-41c1bbb0804a h1:YNh/SV+Z0p7kQDUE9Ux+46ruTucvQP43XB06DfZa8Es= -github.com/rhysd/go-github-selfupdate v0.0.0-20180520142321-41c1bbb0804a/go.mod h1:mOFQaTkPA4plTgFW6Gnejb/RsEIqAoIqOACC2XaZX04= github.com/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag= github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -342,12 +338,10 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= From 169d9e38b3cb9d13c76b8f807ca0a7d5e7545e4d Mon Sep 17 00:00:00 2001 From: George Livas Date: Tue, 9 Jan 2024 15:22:11 +0000 Subject: [PATCH 06/10] remove VCS functionality --- cmd/.circleci/update_check.yml | 2 +- cmd/namespace.go | 42 +------ cmd/namespace_test.go | 209 --------------------------------- 3 files changed, 6 insertions(+), 247 deletions(-) diff --git a/cmd/.circleci/update_check.yml b/cmd/.circleci/update_check.yml index b4e5bdc0f..c2d7a0089 100644 --- a/cmd/.circleci/update_check.yml +++ b/cmd/.circleci/update_check.yml @@ -1 +1 @@ -last_update_check: 2023-12-11T13:24:04.24843+01:00 +last_update_check: 2024-01-11T10:44:52.12818Z diff --git a/cmd/namespace.go b/cmd/namespace.go index 799131ada..b8950b2ff 100644 --- a/cmd/namespace.go +++ b/cmd/namespace.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "strings" "github.com/CircleCI-Public/circleci-cli/api" "github.com/CircleCI-Public/circleci-cli/api/graphql" @@ -84,9 +83,9 @@ Please note that at this time all namespaces created in the registry are world-r return err }, - Args: cobra.RangeArgs(1, 3), + Args: cobra.RangeArgs(1, 1), Annotations: make(map[string]string), - Example: ` circleci namespace create NamespaceName --org-id 00000000-0000-0000-0000-000000000000`, + Example: ` circleci namespace create NamespaceName --org-id 00000000-0000-0000-0000-000000000000`, } createCmd.Annotations[""] = "The name to give your new namespace" @@ -138,42 +137,11 @@ To change the namespace, you will have to contact CircleCI customer support. return nil } -func createNamespaceWithVcsTypeAndOrgName(opts namespaceOptions, namespaceName, vcsType, orgName string) error { - if !opts.noPrompt { - fmt.Printf(`You are creating a namespace called "%s". - -This is the only namespace permitted for your %s organization, %s. - -To change the namespace, you will have to contact CircleCI customer support. - -`, namespaceName, strings.ToLower(opts.args[1]), opts.args[2]) - } - - confirm := fmt.Sprintf("Are you sure you wish to create the namespace: `%s`", namespaceName) - if opts.noPrompt || opts.tty.askUserToConfirm(confirm) { - _, err := api.CreateNamespace(opts.cl, namespaceName, opts.args[2], strings.ToUpper(opts.args[1])) - if err != nil { - return err - } - - fmt.Printf("Namespace `%s` created.\n", namespaceName) - fmt.Println("Please note that any orbs you publish in this namespace are open orbs and are world-readable.") - } - return nil -} - func createNamespace(cmd *cobra.Command, opts namespaceOptions) error { namespaceName := opts.args[0] - //skip if no orgid provided - if opts.orgID != nil && strings.TrimSpace(*opts.orgID) != "" { - _, err := uuid.Parse(*opts.orgID) - if err == nil { - return createNamespaceWithOrgId(opts, namespaceName, *opts.orgID) - } - - //skip if no vcs type and org name provided - } else if len(opts.args) == 3 { - return createNamespaceWithVcsTypeAndOrgName(opts, namespaceName, opts.args[1], opts.args[2]) + _, err := uuid.Parse(*opts.orgID) + if err == nil { + return createNamespaceWithOrgId(opts, namespaceName, *opts.orgID) } return cmd.Help() } diff --git a/cmd/namespace_test.go b/cmd/namespace_test.go index 216817c96..bf45842e8 100644 --- a/cmd/namespace_test.go +++ b/cmd/namespace_test.go @@ -9,7 +9,6 @@ import ( "github.com/CircleCI-Public/circleci-cli/telemetry" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" ) @@ -119,213 +118,5 @@ Namespace %s created. 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`"))) }) }) - - Describe("registering a namespace with OrgName and OrgVcs", func() { - BeforeEach(func() { - command = exec.Command(pathCLI, - "namespace", "create", - "--skip-update-check", - "--token", token, - "--host", tempSettings.TestServer.URL(), - "--integration-testing", - "foo-ns", - "BITBUCKET", - "test-org", - ) - }) - - It("works with organizationName and organizationVcs", func() { - By("setting up a mock server") - - gqlOrganizationResponse := `{ - "organization": { - "name": "test-org", - "id": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - expectedOrganizationRequest := `{ - "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"}}` - - gqlNsResponse := `{ - "createNamespace": { - "errors": [], - "namespace": { - "id": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - } - }` - - expectedNsRequest := `{ - "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}", - "variables": { - "name": "foo-ns", - "organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedOrganizationRequest, - Response: gqlOrganizationResponse}) - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedNsRequest, - Response: gqlNsResponse}) - - By("running the command") - session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - Eventually(session).Should(gexec.Exit(0)) - - stdout := session.Wait().Out.Contents() - - Expect(string(stdout)).To(ContainSubstring(fmt.Sprintf(`You are creating a namespace called "%s". - -This is the only namespace permitted for your bitbucket organization, test-org. - -To change the namespace, you will have to contact CircleCI customer support. - -Are you sure you wish to create the namespace: %s -Namespace %s created. -Please note that any orbs you publish in this namespace are open orbs and are world-readable.`, "foo-ns", "`foo-ns`", "`foo-ns`"))) - }) - }) - - Describe("when creating / reserving a namespace", func() { - BeforeEach(func() { - command = exec.Command(pathCLI, - "namespace", "create", - "--skip-update-check", - "--token", token, - "--host", tempSettings.TestServer.URL(), - "--integration-testing", - "foo-ns", - "BITBUCKET", - "test-org", - ) - }) - - It("works with organizationName and organizationVcs", func() { - By("setting up a mock server") - - gqlOrganizationResponse := `{ - "organization": { - "name": "test-org", - "id": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - expectedOrganizationRequest := `{ - "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" - } - }` - - gqlNsResponse := `{ - "createNamespace": { - "errors": [], - "namespace": { - "id": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - } - }` - - expectedNsRequest := `{ - "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}", - "variables": { - "name": "foo-ns", - "organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedOrganizationRequest, - Response: gqlOrganizationResponse}) - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedNsRequest, - Response: gqlNsResponse}) - - By("running the command") - session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - Eventually(session).Should(gexec.Exit(0)) - - stdout := session.Wait().Out.Contents() - - Expect(string(stdout)).To(ContainSubstring(fmt.Sprintf(`You are creating a namespace called "%s". - -This is the only namespace permitted for your bitbucket organization, test-org. - -To change the namespace, you will have to contact CircleCI customer support. - -Are you sure you wish to create the namespace: %s -Namespace %s created. -Please note that any orbs you publish in this namespace are open orbs and are world-readable.`, "foo-ns", "`foo-ns`", "`foo-ns`"))) - }) - - It("prints all in-band errors returned by the GraphQL API", func() { - By("setting up a mock server") - - gqlOrganizationResponse := `{ - "organization": { - "name": "test-org", - "id": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - expectedOrganizationRequest := `{ - "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" - } - }` - - gqlResponse := `{ - "createNamespace": { - "errors": [ - {"message": "error1"}, - {"message": "error2"} - ], - "namespace": null - } - }` - - gqlNativeErrors := `[ { "message": "ignored error" } ]` - - expectedRequestJSON := `{ - "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}", - "variables": { - "name": "foo-ns", - "organizationId": "bb604b45-b6b0-4b81-ad80-796f15eddf87" - } - }` - - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedOrganizationRequest, - Response: gqlOrganizationResponse, - }) - tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{ - Status: http.StatusOK, - Request: expectedRequestJSON, - Response: gqlResponse, - ErrorResponse: gqlNativeErrors, - }) - - By("running the command") - session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) - - Expect(err).ShouldNot(HaveOccurred()) - Eventually(session.Err).Should(gbytes.Say(`Error: error1 -error2`)) - Eventually(session).ShouldNot(gexec.Exit(0)) - }) - }) }) }) From 1a1e3b16674b64f7a1d309198195a3b6b3f03a2f Mon Sep 17 00:00:00 2001 From: JulesFaucherre Date: Thu, 11 Jan 2024 12:07:46 +0100 Subject: [PATCH 07/10] ci: trigger CI From 0d659babd880896a1a203198117d2a2f64ea28f8 Mon Sep 17 00:00:00 2001 From: George Livas Date: Thu, 11 Jan 2024 15:05:09 +0000 Subject: [PATCH 08/10] use ExactArgs --- cmd/namespace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/namespace.go b/cmd/namespace.go index b8950b2ff..d6cf8945a 100644 --- a/cmd/namespace.go +++ b/cmd/namespace.go @@ -83,7 +83,7 @@ Please note that at this time all namespaces created in the registry are world-r return err }, - Args: cobra.RangeArgs(1, 1), + Args: cobra.ExactArgs(1), Annotations: make(map[string]string), Example: ` circleci namespace create NamespaceName --org-id 00000000-0000-0000-0000-000000000000`, } From c96b18cff93a2874afa834136be9f00fe8c3e94b Mon Sep 17 00:00:00 2001 From: George Livas Date: Mon, 15 Jan 2024 12:37:42 +0000 Subject: [PATCH 09/10] upgrade go-git --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d78740d26..e09e3719b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/briandowns/spinner v1.23.0 github.com/fatih/color v1.16.0 - github.com/go-git/go-git/v5 v5.10.1 + github.com/go-git/go-git/v5 v5.11.0 github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.4.0 github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect diff --git a/go.sum b/go.sum index 02ce9c2a4..4acc1e585 100644 --- a/go.sum +++ b/go.sum @@ -105,6 +105,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.10.1 h1:tu8/D8i+TWxgKpzQ3Vc43e+kkhXqtsZCKI/egajKnxk= github.com/go-git/go-git/v5 v5.10.1/go.mod h1:uEuHjxkHap8kAl//V5F/nNWwqIYtP/402ddd05mp0wg= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= From 1d8af3dd3bebf1b1316a62759e3326a1cd1bf69e Mon Sep 17 00:00:00 2001 From: JulesFaucherre Date: Wed, 14 Feb 2024 12:02:42 +0100 Subject: [PATCH 10/10] Merge main (#1040) * Enrich github prompt to capture organization ID for GitHub App integration users * fix brew --------- Co-authored-by: Bryan Johnson Co-authored-by: abdelDriowya <111757332+abdelDriowya@users.noreply.github.com> --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 945143e17..4edc39607 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -281,6 +281,7 @@ jobs: git config --global user.email "$GH_EMAIL" > /dev/null 2>&1 git config --global user.name "$GH_NAME" > /dev/null 2>&1 - run: brew --version + - run: brew tap --force homebrew/core - run: ./.circleci/brew-deploy.sh chocolatey-deploy: