// RootModuleURL 生成根Module网址
979282
func (c *Context) RootModuleURL(ctl string, act string, args ...interface{}) string {
	return c.Application.URLBuilder.Build(c.Module.RootModuleName, ctl, act, args...)
}
898342
func BaseUrl() (*url.URL, error) {
	// returning cached value
	// Avoid repeated logging
	if kopsBaseUrl != nil {
		glog.V(8).Infof("Using cached kopsBaseUrl url: %q", kopsBaseUrl.String())
		return copyBaseURL(kopsBaseUrl)
	}

	baseUrlString := os.Getenv("KOPS_BASE_URL")
	var err error
	if baseUrlString == "" {
		baseUrlString = fmt.Sprintf(defaultKopsBaseUrl, kops.Version)
		glog.V(8).Infof("Using default base url: %q", baseUrlString)
		kopsBaseUrl, err = url.Parse(baseUrlString)
		if err != nil {
			return nil, fmt.Errorf("unable to parse %q as a url: %v", baseUrlString, err)
		}
	} else {
		kopsBaseUrl, err = url.Parse(baseUrlString)
		if err != nil {
			return nil, fmt.Errorf("unable to parse env var KOPS_BASE_URL %q as a url: %v", baseUrlString, err)
		}
		glog.Warningf("Using base url from KOPS_BASE_URL env var: %q", baseUrlString)
	}

	return copyBaseURL(kopsBaseUrl)
}
49446
func (s *Application) FindModuleByDomain(host string) (*Module, bool) {
	module, has := s.moduleHosts[host]
	if !has {
		if p := strings.LastIndexByte(host, ':'); p > -1 {
			module, has = s.moduleHosts[host[0:p]]
		}
	}
	return module, has
}
246030
func (fp *FieldPath) Root() *FieldPath {
	for ; fp.parent != nil; fp = fp.parent {
		// Do nothing.
	}
	return fp
}
283378
func NodeModuleAbs(relativePath string) string {
	return NodeModulesPath() + PathSeparator + strings.Replace(relativePath, "/", PathSeparator, -1)
}
1188058
func (r *ResourceAddress) WholeModuleAddress() *ResourceAddress {
	return &ResourceAddress{
		Path:            r.Path,
		Index:           -1,
		InstanceTypeSet: false,
	}
}
1341827
func NodeModuleExists(execPath string) bool {
	if !filepath.IsAbs(execPath) {
		execPath = NodeModuleAbs(execPath)
	}

	return Exists(execPath)
}
611045
func rootHandler(w http.ResponseWriter, r *http.Request) {
	if r.URL.Path == "/" {
		// 跳转到 /index.html
		w.Header().Set("Location", "/index.html")
		http.Error(w, "", 301)
	} else {
		http.Error(w, "404 Not Found", 404)
	}
}
695710
func (u *DockerRegistryURL) baseURL(includeCredentials bool) string {
	if u.Scheme == "" || u.Host == "" {
		return ""
	}

	var result string
	if u.Userinfo != nil && includeCredentials {
		result = fmt.Sprintf("%s://%s@%s", u.Scheme, u.Userinfo, u.Host)
	} else {
		result = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
	}

	if u.Port != "" {
		result = fmt.Sprintf("%s:%s", result, u.Port)
	}
	return result

}
473976
func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string {
	var (
		modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
		modulesType  = modulesValue.Type()
		numField     = modulesType.NumField()
		kind         = string(moduleKind)
	)
	for i := 0; i < numField; i++ {
		var (
			fieldValue = modulesValue.Field(i)
			fieldType  = modulesType.Field(i)
		)
		if fieldType.Tag.Get("json") == kind {
			return fieldValue.Interface().(string)
		}
	}

	return ""
}
765806
func (g *Gitlab) ResourceUrl(path string, params map[string]string) *url.URL {
	if params != nil {
		for key, val := range params {
			path = strings.Replace(path, key, val, -1)
		}
	}

	u, err := url.Parse(g.BaseUrl + g.ApiPath + path)
	if err != nil {
		panic("Error while building gitlab url, unable to parse generated url")
	}

	return u
}
1163129
func (rw *repoWalker) parseModuleMap(t *object.Tree) error {
	modEntry, _ := t.File(".gitmodules")
	if modEntry != nil {
		c, err := blobContents(&modEntry.Blob)
		if err != nil {
			return err
		}
		mods, err := ParseGitModules(c)
		if err != nil {
			return err
		}
		rw.submodules = map[string]*SubmoduleEntry{}
		for _, entry := range mods {
			rw.submodules[entry.Path] = entry
		}
	}
	return nil
}
1022249
func (v *GenerateServiceRequest) GetModules() (o map[ModuleID]*Module) {
	if v != nil {
		o = v.Modules
	}
	return
}
79850
func (c Static) ServeModule(moduleName, prefix, filepath string) revel.Result {
	// Fix for #503.
	prefix = c.Params.Fixed.Get("prefix")
	if prefix == "" {
		return c.NotFound("")
	}

	var basePath string
	if module, found := revel.ModuleByName(moduleName); !found {
		c.Log.Errorf("static: Module not found %s", moduleName)
		return c.NotFound(moduleName)
	} else {
		basePath = module.Path
	}

	absPath := fpath.Join(basePath, fpath.FromSlash(prefix))

	return serve(c, absPath, filepath, false)
}
938057
func NewModule(addr addrs.ModuleInstance) *Module {
	return &Module{
		Addr:         addr,
		Resources:    map[string]*Resource{},
		OutputValues: map[string]*OutputValue{},
		LocalValues:  map[string]cty.Value{},
	}
}
89050
func (s Storage) getModuleRoot(dir string) (string, error) {
	manifest, err := s.loadManifest()
	if err != nil {
		return "", err
	}

	for _, mod := range manifest.Modules {
		if mod.Dir == dir {
			return mod.Root, nil
		}
	}
	return "", nil
}
382997
func (c *Client) ArtifactFileURL(av *ArtifactVersion) (*url.URL, error) {
	if !av.File {
		return nil, nil
	}

	u := *c.URL
	u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/%d/file",
		av.User, av.Name, av.Type, av.Version)
	return &u, nil
}