func()

in pkg/runner/step_file.go [176:205]


func (s *StepFile) ReadValues(specOutputs map[string]*proto.Spec_Content_Output) (map[string]*structpb.Value, error) {
	keyValues, err := s.ReadKeyValueLines()
	if err != nil {
		return nil, fmt.Errorf("read output file: %w", err)
	}

	for key, value := range keyValues {
		outputSpec, ok := specOutputs[key]
		if !ok {
			return nil, fmt.Errorf("read output file: key %q: unexpected output, remove from step outputs or define in step specification", key)
		}

		if err := s.checkOutputType(outputSpec.Type, value); err != nil {
			return nil, fmt.Errorf("read output file: key %q: %w", key, err)
		}
	}

	for name, o := range specOutputs {
		if _, ok := keyValues[name]; ok {
			continue
		}
		if o.Default != nil {
			keyValues[name] = o.Default
			continue
		}
		return nil, fmt.Errorf("read output file: key %q: missing output, add to step outputs or remove from step specification", name)
	}

	return keyValues, nil
}