// ReadStepSpec ...
438920
func ReadStepSpec(uri string) (models.StepCollectionModel, error) {
	route, found := ReadRoute(uri)
	if !found {
		return models.StepCollectionModel{}, errors.New("No route found for lib: " + uri)
	}
	pth := GetStepSpecPath(route)
	bytes, err := fileutil.ReadBytesFromFile(pth)
	if err != nil {
		return models.StepCollectionModel{}, err
	}
	var stepLib models.StepCollectionModel
	if err := json.Unmarshal(bytes, &stepLib); err != nil {
		return models.StepCollectionModel{}, err
	}

	return stepLib, nil
}
102735
func ParseShardingSpec(spec string) ([]*topodatapb.KeyRange, error) {
	parts := strings.Split(spec, "-")
	if len(parts) == 1 {
		return nil, fmt.Errorf("malformed spec: doesn't define a range: %q", spec)
	}
	old := parts[0]
	ranges := make([]*topodatapb.KeyRange, len(parts)-1)

	for i, p := range parts[1:] {
		if p == "" && i != (len(parts)-2) {
			return nil, fmt.Errorf("malformed spec: MinKey/MaxKey cannot be in the middle of the spec: %q", spec)
		}
		if p != "" && p <= old {
			return nil, fmt.Errorf("malformed spec: shard limits should be in order: %q", spec)
		}
		s, err := hex.DecodeString(old)
		if err != nil {
			return nil, err
		}
		if len(s) == 0 {
			s = nil
		}
		e, err := hex.DecodeString(p)
		if err != nil {
			return nil, err
		}
		if len(e) == 0 {
			e = nil
		}
		ranges[i] = &topodatapb.KeyRange{Start: s, End: e}
		old = p
	}
	return ranges, nil
}
10472
func readCommandsFromSpecFile(specfile string) ([]string, error) {

	spec, e := ioutil.ReadFile(specfile)
	if e != nil {
		return nil, e
	}
	slen := len(spec)
	if spec[slen-1] == 0x0a {
		spec = spec[:slen-1]
	}
	commands := strings.Split(string(spec), "\n")

	return commands, nil
}
466314
func readSync(pipe io.Reader, expected syncType) error {
	var procSync syncT
	if err := json.NewDecoder(pipe).Decode(&procSync); err != nil {
		if err == io.EOF {
			return fmt.Errorf("parent closed synchronisation channel")
		}

		if procSync.Type == procError {
			var ierr genericError

			if err := json.NewDecoder(pipe).Decode(&ierr); err != nil {
				return fmt.Errorf("failed reading error from parent: %v", err)
			}

			return &ierr
		}

		if procSync.Type != expected {
			return fmt.Errorf("invalid synchronisation flag from parent")
		}
	}
	return nil
}
618678
func (ccpack *CDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec {
	//this has to be after creating a package and initializing it
	//If those steps fail, GetDepSpec() should never be called
	if ccpack.depSpec == nil {
		panic("GetDepSpec called on uninitialized package")
	}
	return ccpack.depSpec
}
1224684
func ReadFeatureProbes(filename string) {
	f, err := os.Open(filename)
	if err != nil {
		// Should not happen; the caller ensured that the file exists
		log.WithFields(logrus.Fields{
			logfields.Path: filename,
		}).WithError(err).Fatal("Failed to read feature probes")
	}
	defer f.Close()
	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		for mapType := MapTypeHash; mapType < MapTypeMaximum; mapType++ {
			featureString := mapTypeToFeatureString(mapType)
			if featureString != "" &&
				bytes.Compare(scanner.Bytes(), []byte(featureString)) == 0 {
				log.Debugf("Detected support for map type %s", mapType.String())
				supportedMapTypes[mapType] = true
			}
		}
	}

	for mapType := MapTypeHash; mapType < MapTypeMaximum; mapType++ {
		if mapTypeToFeatureString(mapType) == "" {
			log.Debugf("Skipping support detection for map type %s", mapType.String())
		} else if _, probed := supportedMapTypes[mapType]; !probed {
			log.Debugf("Detected no support for map type %s", mapType.String())
			supportedMapTypes[mapType] = false
		}
	}
}
385509
func (q QueueProps) ReadFrom(r io.Reader) (int64, error) {
	var queueType QueuePropType

	rm := func() (io.ReaderFrom, error) {
		if rm, ok := queuePropTypeMap[queueType]; ok {
			rd, err := rm.MakeReader()
			q = append(q, rd.(QueueProp))
			return rd, err
		}

		format := "ofp: unknown queue property type: '%x'"
		return nil, fmt.Errorf(format, queueType)
	}

	return encoding.ScanFrom(r, &queueType,
		encoding.ReaderMakerFunc(rm))
}
923645
func GetStepIDStepDataPair(stepListItem StepListItemModel) (string, stepmanModels.StepModel, error) {
	if len(stepListItem) > 1 {
		return "", stepmanModels.StepModel{}, errors.New("StepListItem contains more than 1 key-value pair")
	}
	for key, value := range stepListItem {
		return key, value, nil
	}
	return "", stepmanModels.StepModel{}, errors.New("StepListItem does not contain a key-value pair")
}
1112477
func (s *MeshData) SetSpec(v *MeshSpec) *MeshData {
	s.Spec = v
	return s
}
776361
func GetContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
	for i, c := range pod.Spec.Containers {
		if containerName == c.Name {
			return &pod.Spec.Containers[i]
		}
	}
	for i, c := range pod.Spec.InitContainers {
		if containerName == c.Name {
			return &pod.Spec.InitContainers[i]
		}
	}
	return nil
}
215994
func (s *CreateMeshInput) SetSpec(v *MeshSpec) *CreateMeshInput {
	s.Spec = v
	return s
}
512828
func (p *pktLineParser) step() error {
	switch p.state {
	case ready:
		p.state = readingLen
		p.next = pktLenSize
		return nil
	case readingLen:
		// len(p.buf) is 4.
		pktLen, err := parsePktLen(p.buf)
		if err != nil {
			return err
		}

		switch {
		case pktLen == 0:
			p.state = done
			p.next = 0
			p.buf = nil
			return nil
		default:
			p.state = readingPayload
			p.next = pktLen - pktLenSize // (pkt-len - 4)*(OCTET)
			p.buf = p.buf[:0]
			return nil
		}
	case readingPayload:
		p.state = readingLen
		p.next = pktLenSize
		p.Lines = append(p.Lines, string(p.buf))
		p.buf = p.buf[:0]
		return nil
	default:
		panic(fmt.Errorf("unreachable: %v", p.state))
	}
}
398733
func (d *driver) SnapshotInspect(
	ctx types.Context,
	snapshotID string,
	opts types.Store) (*types.Snapshot, error) {
	// TODO Snapshots are not implemented yet
	return nil, types.ErrNotImplemented
}
1145709
func (s *CreateVirtualNodeInput) SetSpec(v *VirtualNodeSpec) *CreateVirtualNodeInput {
	s.Spec = v
	return s
}
1143131
func (p *parser) parseComprehensionSpecs(end tokenKind) (*ast.ForSpec, *token, error) {
	var parseComprehensionSpecsHelper func(outer *ast.ForSpec) (*ast.ForSpec, *token, error)
	parseComprehensionSpecsHelper = func(outer *ast.ForSpec) (*ast.ForSpec, *token, error) {
		var ifSpecs []ast.IfSpec

		varID, err := p.popExpect(tokenIdentifier)
		if err != nil {
			return nil, nil, err
		}
		id := ast.Identifier(varID.data)
		_, err = p.popExpect(tokenIn)
		if err != nil {
			return nil, nil, err
		}
		arr, err := p.parse(maxPrecedence)
		if err != nil {
			return nil, nil, err
		}
		forSpec := &ast.ForSpec{
			VarName: id,
			Expr:    arr,
			Outer:   outer,
		}

		maybeIf := p.pop()
		for ; maybeIf.kind == tokenIf; maybeIf = p.pop() {
			cond, err := p.parse(maxPrecedence)
			if err != nil {
				return nil, nil, err
			}
			ifSpecs = append(ifSpecs, ast.IfSpec{
				Expr: cond,
			})
		}
		forSpec.Conditions = ifSpecs
		if maybeIf.kind == end {
			return forSpec, maybeIf, nil
		}

		if maybeIf.kind != tokenFor {
			return nil, nil, MakeStaticError(
				fmt.Sprintf("Expected for, if or %v after for clause, got: %v", end, maybeIf), maybeIf.loc)
		}

		return parseComprehensionSpecsHelper(forSpec)
	}
	return parseComprehensionSpecsHelper(nil)
}
203092
func (f *MockFile) Read(b []byte) (n int, err error) {
	if f.fs.WithReadError {
		return 0, readErr
	}

	count := len(b)
	if len(f.Contents) < count {
		count = len(f.Contents)
	}
	copy(b, []byte(f.Contents)[:count])
	f.Seq = f.fs.next()

	return count, nil
}
898097
func (s *Job) SetSteps(v []*Step) *Job {
	s.Steps = v
	return s
}