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

PIPE-3873 fixing type-casting issue #897

Merged
merged 3 commits into from
Mar 31, 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
1 change: 0 additions & 1 deletion config/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (c *ConfigCompiler) getOrgID(
optsOrgSlug string,
) (string, error) {
if optsOrgID == "" && optsOrgSlug == "" {
fmt.Println("No org id or slug has been provided")
return "", nil
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type CompileConfigRequest struct {
type Options struct {
OwnerID string `json:"owner_id,omitempty"`
PipelineParameters map[string]interface{} `json:"pipeline_parameters,omitempty"`
PipelineValues map[string]string `json:"pipeline_values,omitempty"`
PipelineValues map[string]interface{} `json:"pipeline_values,omitempty"`
}

// ConfigQuery - attempts to compile or validate a given config file with the
Expand Down
6 changes: 3 additions & 3 deletions config/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// CircleCI provides various `<< pipeline.x >>` values to be used in your config, but sometimes we need to fabricate those values when validating config.
type Values map[string]string
type Values map[string]interface{}

// Static typing is bypassed using an empty interface here due to pipeline parameters supporting multiple types.
type Parameters map[string]interface{}
Expand All @@ -31,9 +31,9 @@ func LocalPipelineValues() Values {
}
}

vals := map[string]string{
vals := map[string]interface{}{
"id": "00000000-0000-0000-0000-000000000001",
"number": "1",
"number": 1,
"project.git_url": gitUrl,
"project.type": projectType,
"git.tag": git.Tag(),
Expand Down
30 changes: 30 additions & 0 deletions integration_tests/features/circleci_config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,36 @@ Feature: Config checking
Then the output should contain "fighters"
And the exit status should be 0

Scenario: Testing new type casting works as expected
Given a file named "config.yml" with:
"""
version: 2.1

jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
parameters:
an-integer:
description: a test case to ensure parameters are passed correctly
type: integer
default: -1
steps:
- unless:
condition:
equal: [<< parameters.an-integer >>, -1]
steps:
- run: echo "<< parameters.an-integer >> - test"
workflows:
main-workflow:
jobs:
- datadog-hello-world:
an-integer: << pipeline.number >>
"""
When I run `circleci config process config.yml`
Then the output should contain "1 - test"
And the exit status should be 0

Scenario: Checking a valid config file with default pipeline params
Given a file named "config.yml" with:
"""
Expand Down