// loadSpec loads the specification from the provided path.
496122
func loadSpec(cPath string) (spec *specs.Spec, err error) {
	cf, err := os.Open(cPath)
	if err != nil {
		if os.IsNotExist(err) {
			return nil, fmt.Errorf("JSON specification file %s not found", cPath)
		}
		return nil, err
	}
	defer cf.Close()

	if err = json.NewDecoder(cf).Decode(&spec); err != nil {
		return nil, err
	}
	return spec, validateProcessSpec(spec.Process)
}
1256331
func GetSpecific(path string) (*File, error) {
	resolv, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	hash, err := ioutils.HashData(bytes.NewReader(resolv))
	if err != nil {
		return nil, err
	}
	return &File{Content: resolv, Hash: hash}, nil
}
1012185
func (s *CreateRouteInput) SetSpec(v *RouteSpec) *CreateRouteInput {
	s.Spec = v
	return s
}
627781
func (s *VirtualNodeData) SetSpec(v *VirtualNodeSpec) *VirtualNodeData {
	s.Spec = v
	return s
}
94425
func (bond *Bond) loadPath() {
	if bond.HostProc == "" {
		bond.HostProc = proc(envProc, defaultHostProc)
	}
}
254646
func LoadPEMCertPool(certsFile string) (*x509.CertPool, error) {
	if certsFile == "" {
		return nil, nil
	}
	pemCerts, err := ioutil.ReadFile(certsFile)
	if err != nil {
		return nil, err
	}

	return PEMToCertPool(pemCerts)
}
272846
func LoadConfig(path string, v *Config) error {
	if v == nil {
		return errors.Wrapf(errdefs.ErrInvalidArgument, "argument v must not be nil")
	}
	md, err := toml.DecodeFile(path, v)
	if err != nil {
		return err
	}
	v.md = md
	return nil
}
1142161
func (spec LookupInSpec) Get(path string, opts *LookupInSpecGetOptions) LookupInOp {
	if opts == nil {
		opts = &LookupInSpecGetOptions{}
	}
	return spec.getWithFlags(path, opts.IsXattr)
}
497993
func (ns *Nstat) loadPaths() {
	if ns.ProcNetNetstat == "" {
		ns.ProcNetNetstat = proc(ENV_NETSTAT, NET_NETSTAT)
	}
	if ns.ProcNetSNMP == "" {
		ns.ProcNetSNMP = proc(ENV_SNMP, NET_SNMP)
	}
	if ns.ProcNetSNMP6 == "" {
		ns.ProcNetSNMP6 = proc(ENV_SNMP6, NET_SNMP6)
	}
}
668169
func (s *UpdateMeshInput) SetSpec(v *MeshSpec) *UpdateMeshInput {
	s.Spec = v
	return s
}
542423
func loadConfigFile(path string) (*Config, tfdiags.Diagnostics) {
	var diags tfdiags.Diagnostics
	result := &Config{}

	log.Printf("Loading CLI configuration from %s", path)

	// Read the HCL file and prepare for parsing
	d, err := ioutil.ReadFile(path)
	if err != nil {
		diags = diags.Append(fmt.Errorf("Error reading %s: %s", path, err))
		return result, diags
	}

	// Parse it
	obj, err := hcl.Parse(string(d))
	if err != nil {
		diags = diags.Append(fmt.Errorf("Error parsing %s: %s", path, err))
		return result, diags
	}

	// Build up the result
	if err := hcl.DecodeObject(&result, obj); err != nil {
		diags = diags.Append(fmt.Errorf("Error parsing %s: %s", path, err))
		return result, diags
	}

	// Replace all env vars
	for k, v := range result.Providers {
		result.Providers[k] = os.ExpandEnv(v)
	}
	for k, v := range result.Provisioners {
		result.Provisioners[k] = os.ExpandEnv(v)
	}

	if result.PluginCacheDir != "" {
		result.PluginCacheDir = os.ExpandEnv(result.PluginCacheDir)
	}

	return result, diags
}
1112477
func (s *MeshData) SetSpec(v *MeshSpec) *MeshData {
	s.Spec = v
	return s
}
293580
func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
	s := bufio.NewScanner(r)
	i := int(0)
	creator := dhCreator{
		DH: &DirectoryHierarchy{},
	}
	for s.Scan() {
		str := s.Text()
		trimmedStr := strings.TrimLeftFunc(str, func(c rune) bool {
			return c == ' ' || c == '\t'
		})
		e := Entry{Pos: i}
		switch {
		case strings.HasPrefix(trimmedStr, "#"):
			e.Raw = str
			if strings.HasPrefix(trimmedStr, "#mtree") {
				e.Type = SignatureType
			} else {
				e.Type = CommentType
				// from here, the comment could be "# key: value" metadata
				// or a relative path hint
			}
		case str == "":
			e.Type = BlankType
			// nothing else to do here
		case strings.HasPrefix(str, "/"):
			e.Type = SpecialType
			// collapse any escaped newlines
			for {
				if strings.HasSuffix(str, `\`) {
					str = str[:len(str)-1]
					s.Scan()
					str += s.Text()
				} else {
					break
				}
			}
			// parse the options
			f := strings.Fields(str)
			e.Name = f[0]
			e.Keywords = StringToKeyVals(f[1:])
			if e.Name == "/set" {
				creator.curSet = &e
			} else if e.Name == "/unset" {
				creator.curSet = nil
			}
		case len(strings.Fields(str)) > 0 && strings.Fields(str)[0] == "..":
			e.Type = DotDotType
			e.Raw = str
			if creator.curDir != nil {
				creator.curDir = creator.curDir.Parent
			}
			// nothing else to do here
		case len(strings.Fields(str)) > 0:
			// collapse any escaped newlines
			for {
				if strings.HasSuffix(str, `\`) {
					str = str[:len(str)-1]
					s.Scan()
					str += s.Text()
				} else {
					break
				}
			}
			// parse the options
			f := strings.Fields(str)
			e.Name = filepath.Clean(f[0])
			if strings.Contains(e.Name, "/") {
				e.Type = FullType
			} else {
				e.Type = RelativeType
			}
			e.Keywords = StringToKeyVals(f[1:])
			// TODO: gather keywords if using tar stream
			e.Parent = creator.curDir
			for i := range e.Keywords {
				kv := KeyVal(e.Keywords[i])
				if kv.Keyword() == "type" {
					if kv.Value() == "dir" {
						creator.curDir = &e
					} else {
						creator.curEnt = &e
					}
				}
			}
			e.Set = creator.curSet
		default:
			// TODO(vbatts) log a warning?
			continue
		}
		creator.DH.Entries = append(creator.DH.Entries, e)
		i++
	}
	return creator.DH, s.Err()
}
857726
func LoadCertFromPEM(pemBytes []byte) (*x509.Certificate, error) {
	for len(pemBytes) > 0 {
		var block *pem.Block
		block, pemBytes = pem.Decode(pemBytes)
		if block == nil {
			return nil, errors.New("no certificates found in PEM data")
		}
		if block.Type != "CERTIFICATE" || len(block.Headers) != 0 {
			continue
		}

		cert, err := x509.ParseCertificate(block.Bytes)
		if err != nil {
			continue
		}

		return cert, nil
	}

	return nil, errors.New("no certificates found in PEM data")
}
1145709
func (s *CreateVirtualNodeInput) SetSpec(v *VirtualNodeSpec) *CreateVirtualNodeInput {
	s.Spec = v
	return s
}
640408
func (ut *URLTransformer) LoadPaths(paths []string) error {
	for _, path := range paths {
		err := ut.LoadPath(path)
		if err != nil {
			return err
		}
	}
	return nil
}
1346516
func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
	return nil, errors.New("not supported")
}