// ParseModule returns a parsed Module object.
// For details on Module objects and their fields, see policy.go.
// Empty input will return nil, nil.
422367
func ParseModule(filename, input string) (*Module, error) {
	stmts, comments, err := ParseStatements(filename, input)
	if err != nil {
		return nil, err
	}
	return parseModule(stmts, comments)
}
97860
func (d *Diff) AddModule(path addrs.ModuleInstance) *ModuleDiff {
	// Lower the new-style address into a legacy-style address.
	// This requires that none of the steps have instance keys, which is
	// true for all addresses at the time of implementing this because
	// "count" and "for_each" are not yet implemented for modules.
	legacyPath := make([]string, len(path))
	for i, step := range path {
		if step.InstanceKey != addrs.NoKey {
			// FIXME: Once the rest of Terraform is ready to use count and
			// for_each, remove all of this and just write the addrs.ModuleInstance
			// value itself into the ModuleState.
			panic("diff cannot represent modules with count or for_each keys")
		}

		legacyPath[i] = step.Name
	}

	m := &ModuleDiff{Path: legacyPath}
	m.init()
	d.Modules = append(d.Modules, m)
	return m
}
1260279
func (w *Worktree) Submodule(name string) (*Submodule, error) {
	l, err := w.Submodules()
	if err != nil {
		return nil, err
	}

	for _, m := range l {
		if m.Config().Name == name {
			return m, nil
		}
	}

	return nil, ErrSubmoduleNotFound
}
362078
func (s Storage) GetModule(dst, src string) error {
	// reset this in case the caller was going to re-use it
	mode := s.Mode
	s.Mode = GetModeUpdate
	defer func() {
		s.Mode = mode
	}()

	rec, err := s.findRegistryModule(src, anyVersion)
	if err != nil {
		return err
	}

	pwd, err := os.Getwd()
	if err != nil {
		return err
	}

	source := rec.url
	if source == "" {
		source, err = getter.Detect(src, pwd, getter.Detectors)
		if err != nil {
			return fmt.Errorf("module %s: %s", src, err)
		}
	}

	if source == "" {
		return fmt.Errorf("module %q not found", src)
	}

	return GetCopy(dst, source)
}
574524
func (s *State) RootModule() *Module {
	if s == nil {
		panic("RootModule called on nil State")
	}
	return s.Modules[addrs.RootModuleInstance.String()]
}
567472
func NewModule(host, namespace, name, provider, submodule string) (*Module, error) {
	m := &Module{
		RawNamespace: namespace,
		RawName:      name,
		RawProvider:  provider,
		RawSubmodule: submodule,
	}
	if host != "" {
		h := NewFriendlyHost(host)
		if h != nil {
			fmt.Println("HOST:", h)
			if !h.Valid() || disallowed[h.Display()] {
				return nil, ErrInvalidModuleSource
			}
		}
		m.RawHost = h
	}
	return m, nil
}
751354
func (t Modules) DependOnce(usedModules ...Module) Modules {
	modules := Modules{}
	usage := nameUsage{}

	for _, module := range usedModules {
		usage.Use(module.Name)
	}

	for _, module := range t {
		depmods := module.Depend.DependOnce()
		for _, depend := range depmods {
			if !usage.IsUsed(depend.Name) {
				usage.Use(depend.Name)
				modules = append(modules, depend)
			}
		}

		if !usage.IsUsed(module.Name) {
			usage.Use(module.Name)
			modules = append(modules, module)
		}
	}

	return modules
}
1338358
func startModules() {
	logger.Log.Debug("initializing all modules")
	for _, modWrapper := range modulesArr {
		logger.Log.Debugf("initializing module: %s", modWrapper.name)
		if err := modWrapper.module.Init(); err != nil {
			logger.Log.Fatalf("error starting module %s, error: %s", modWrapper.name, err.Error())
		}
	}

	for _, modWrapper := range modulesArr {
		modWrapper.module.AfterInit()
		logger.Log.Infof("module: %s successfully loaded", modWrapper.name)
	}
}
1349519
func (c *Config) AllModules() []*Config {
	var ret []*Config
	c.DeepEach(func(c *Config) {
		ret = append(ret, c)
	})
	return ret
}
979282
func (c *Context) RootModuleURL(ctl string, act string, args ...interface{}) string {
	return c.Application.URLBuilder.Build(c.Module.RootModuleName, ctl, act, args...)
}
1033437
func loadIPVModule() error {
	out, err := k8sexec.New().Command("modprobe", "ip_vs").CombinedOutput()
	if err != nil {
		glog.V(2).Infof("Error loading ip_vip: %s, %v", string(out), err)
		return err
	}

	_, err = os.Stat("/proc/net/ip_vs")
	return err
}
432940
func listModules() ([]string, error) {
	fModules, err := os.Open(modulesFilepath)
	if err != nil {
		return nil, fmt.Errorf(
			"failed to open modules information at %s: %s",
			modulesFilepath, err)
	}
	defer fModules.Close()
	return parseModulesFile(fModules)
}
1341827
func NodeModuleExists(execPath string) bool {
	if !filepath.IsAbs(execPath) {
		execPath = NodeModuleAbs(execPath)
	}

	return Exists(execPath)
}
197686
func (f ModuleWalkerFunc) LoadModule(req *ModuleRequest) (*Module, *version.Version, hcl.Diagnostics) {
	return f(req)
}
696893
func getModuleName(m Module) string {
	moduleType := reflect.TypeOf(m)
	if moduleType.Kind() == reflect.Ptr {
		moduleType = moduleType.Elem()
	}
	return moduleType.PkgPath() + "." + moduleType.Name() // todo: allow aliases
}
41890
func ParseRuleFromBody(module *Module, body Body) (*Rule, error) {

	if len(body) != 1 {
		return nil, fmt.Errorf("multiple expressions cannot be used for rule head")
	}

	return ParseRuleFromExpr(module, body[0])
}
406361
func ParseFileMode(s string) (FileMode, error) {
	var fm FileMode
	if err := fm.UnmarshalText([]byte(s)); err != nil {
		return 0, err
	}
	return fm, nil
}