PipelineModel.fromYaml constructor

PipelineModel.fromYaml(
  1. String name,
  2. Map<String, dynamic> yamlMap
)

Implementation

factory PipelineModel.fromYaml(String name, Map<String, dynamic> yamlMap) {
  final stepsData = yamlMap['steps'];
  if (stepsData == null || stepsData is! List || stepsData.isEmpty) {
    print('❌ Pipeline "$name" must have at least one step defined.');
    print('   Example:');
    print('   pipelines:');
    print('     $name:');
    print('       steps:');
    print('         - name: "My Step"');
    print('           command: "echo hello"');
    exit(1);
  }

  return PipelineModel(
    name: name,
    description: yamlMap['description']?.toString(),
    steps: List<PipelineStepModel>.from(
      (stepsData).map(
        (step) => PipelineStepModel.fromYaml(Map<String, dynamic>.from(step)),
      ),
    ),
  );
}