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

Update Spec with Steps and Stages when OriginalYamlString is defined #25

Merged

Conversation

sandrogattuso
Copy link
Contributor

@sandrogattuso sandrogattuso commented Dec 12, 2020

Edit: I've pushed a second commit to address an issue with the attribute steps where the order of the steps was lost during the marshalling of the object. This happens because maps in JSON are unordered. I've updated the code to dynamically build the JSON string by parsing the original_yaml_string attribute to avoid losing the correct order

Issue Description

When defining a pipeline using the attribute original_yaml_string, running the pipeline would result in an empty execution (no steps and stages)
Steps and stages are visible from the console editor after the pipeline is created, however, the Spec.Stages and Spec.Steps are not updated causing the pipeline to be empty during execution.

Documentation references:
Original_yaml_string

originalYamlString | metadata | string | the full contents of the pipeline editor. Only kept for archival purposes

Steps and Stages

steps | spec | object | The pipeline steps to be executed
stages | spec | array | The pipeline stages for a better visual overview

Steps to reproduce

  1. Create a pipeline using the provider and leverage the original_yaml_string attribute
----pipeline.yaml ---
version: "1.0"
stages:
  - checkout
  - hello_world
steps:
  main_clone:
    title: Cloning main repository...
    type: git-clone
    repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
    revision: ${{CF_REVISION}}
    stage: checkout
  hello_world:
    stage: hello_world
    title: hello_world
    image: alpine:latest
    commands:
       - echo "Hello World"
---------

resource "codefresh_project" "test" {
  name = "myproject"
}

resource "codefresh_pipeline" "test" {
  name    = "${codefresh_project.test.name}/original_yaml_string_pipeline"

  tags = [
    "test",
  ]
 original_yaml_string = file("pipeline.yaml")
 spec {
    concurrency = 1
    priority    = 5
 }
  1. Check the Pipeline in the UI, the editor displays all the steps
  2. Execute the pipeline, no steps/stages are displayed nor executed

@palson-cf
Copy link
Contributor

@sandrogattuso Thank you for the great work!
I'll merge.

@palson-cf palson-cf merged commit b174d11 into codefresh-io:master Jan 27, 2021
@sandrogattuso
Copy link
Contributor Author

@palson-cf should I rebase the other PRs I've raised?

@palson-cf
Copy link
Contributor

@sandrogattuso yes, please
I'll review

@sandrogattuso sandrogattuso deleted the bugfix/originalyamlstring branch May 29, 2021 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants