Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Added doc about server compatibility #936

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,8 @@ Development instructions for the CircleCI CLI can be found in [HACKING.md](HACKI

Please see the [documentation](https://circleci-public.github.io/circleci-cli) or `circleci help` for more.

## Server compatibility

There are some difference of behavior depending on the version you use:
- config validation will use the GraphQL API until **Server v4.0.5, v4.1.3, v4.2.0**. The above versions will use the new route `compile-config-with-defaults`
- `circleci orb validate` will only allow you to validate orbs using other private orbs with the option `--org-slug` from version **Server v4.2.0**
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func makeOrbRequest(cl *graphql.Client, configContent string, ownerId string) (*
}

if ownerId != "" {
return nil, errors.Errorf("Your version of server does not support validating orbs that refer private orbs")
return nil, errors.Errorf("Your version of Server does not support validating orbs that refer to other private orbs. Please see the README for more information on server compatibility: https://github.com/CircleCI-Public/circleci-cli#server-compatibility")
}
query := `
query ValidateOrb ($config: String!) {
Expand Down
71 changes: 71 additions & 0 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,77 @@ See a full explanation and documentation on orbs here: https://circleci.com/docs
})
})

Describe("with old server version", func() {
BeforeEach(func() {
token = "testtoken"
command = exec.Command(pathCLI,
"orb", "validate",
"--skip-update-check",
"--token", token,
"--host", tempSettings.TestServer.URL(),
"-",
)
stdin, err := command.StdinPipe()
Expect(err).ToNot(HaveOccurred())
go func() {
defer stdin.Close()
_, err := io.WriteString(stdin, "{}")
if err != nil {
panic(err)
}
}()
})

It("should use the old GraphQL resolver", func() {
By("setting up a mock server")

mockOrbIntrospection(false, "", tempSettings)

gqlResponse := `{
"orbConfig": {
"sourceYaml": "{}",
"valid": true,
"errors": []
}
}`

response := struct {
Query string `json:"query"`
Variables struct {
Config string `json:"config"`
} `json:"variables"`
}{
Query: `
query ValidateOrb ($config: String!) {
orbConfig(orbYaml: $config) {
valid,
errors { message },
sourceYaml,
outputYaml
}
}`,
Variables: struct {
Config string `json:"config"`
}{
Config: "{}",
},
}
expected, err := json.Marshal(response)
Expect(err).ShouldNot(HaveOccurred())

tempSettings.AppendPostHandler(token, clitest.MockRequestResponse{
Status: http.StatusOK,
Request: string(expected),
Response: gqlResponse})

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)

Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say("Orb input is valid."))
Eventually(session).Should(gexec.Exit(0))
})
})

Context("with 'some orb'", func() {
BeforeEach(func() {
orb.Write([]byte(`some orb`))
Expand Down