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

Blocks made with pipes have a leading new line while dumping #721

Open
sujeeet-kumar opened this issue Aug 29, 2024 · 0 comments
Open

Blocks made with pipes have a leading new line while dumping #721

sujeeet-kumar opened this issue Aug 29, 2024 · 0 comments

Comments

@sujeeet-kumar
Copy link

const yaml = require('js-yaml');

// Sample data
const pipelineData = {
    appName: "sample-app",
    eksEnv: "dev",
    secretProviderClass: {
        parameters: {}
    }
};

const jmesPathEntries = [
    { path: "CONFIG_services_postgres_password", objectAlias: "postgres_password" }
];

// Build the objects section with proper formatting
pipelineData.secretProviderClass.parameters.objects = `|\n  - objectName: "ktp/${pipelineData.appName}/${pipelineData.eksEnv}/secrets"\n    objectType: "secretsmanager"\n    jmesPath:\n${jmesPathEntries.map(entry => `    - path: ${entry.path}\n      objectAlias: ${entry.objectAlias}`).join('\n')}`;

// Convert to YAML
const yamlStr = yaml.dump(pipelineData.secretProviderClass.parameters);

console.log(yamlStr);

Output

parameters:
  objects: "|\n  - objectName: \"domain/sample-app/dev/secrets\"\n    objectType: \"secretsmanager\"\n    jmesPath:- path: CONFIG_services_postgres_password \r\n objectAlias: postgres_password"

Expected Output:

parameters:
  objects: |
    - objectName: "domain/sample-app/dev/secrets"
      objectType: "secretsmanager"
      jmesPath:
      - path: CONFIG_services_postgres_password
        objectAlias: postgres_password
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

No branches or pull requests

1 participant