// returns all extensions found in the _extensions file in the migrations directory, or an error
// If the _extensions file does not exist, no error is returned.
186577
func getExtensions(migrationsDir string) ([]string, error) {
	contents, err := ioutil.ReadFile(filepath.Join(migrationsDir, extensionsFileName))
	if err != nil {
		if os.IsNotExist(err) {
			return nil, nil
		}
		return nil, err
	}
	extensions := strings.Split(string(contents), "\n")
	sanitizedExtensions := make([]string, 0)
	for _, extension := range extensions {
		sanitized := strings.TrimSpace(extension)
		if sanitized != "" {
			sanitizedExtensions = append(sanitizedExtensions, extension)
		}
	}
	return sanitizedExtensions, nil
}
906223
func (sb *storageBackend) AllFilesystems() ([]Filesystem, error) {
	filesystems, err := sb.filesystems(nil)
	if err != nil {
		return nil, errors.Annotate(err, "cannot get filesystems")
	}
	return filesystemsToInterfaces(filesystems), nil
}
844008
func (p *ExtensionManagerClient) GetQueryColumns(ctx context.Context, sql string) (r *ExtensionResponse, err error) {
  var _args31 ExtensionManagerGetQueryColumnsArgs
  _args31.Sql = sql
  var _result32 ExtensionManagerGetQueryColumnsResult
  if err = p.Client_().Call(ctx, "getQueryColumns", &_args31, &_result32); err != nil {
    return
  }
  return _result32.GetSuccess(), nil
}
617059
func (fd *finder) findAllGoFiles(dir string) ([]string, error) {
	var err error
	var names []string
	oncer.Do(fd.key("findAllGoFiles", dir), func() {
		plog.Debug(fd, "findAllGoFiles", "dir", dir)

		callback := func(path string, do *godirwalk.Dirent) error {
			ext := filepath.Ext(path)
			if ext != ".go" {
				return nil
			}
			names = append(names, path)
			return nil
		}
		err = godirwalk.Walk(dir, &godirwalk.Options{
			FollowSymbolicLinks: true,
			Callback:            callback,
		})
	})

	return names, err
}
680164
func GetExtensionManager(c *vim25.Client) (*ExtensionManager, error) {
	if c.ServiceContent.ExtensionManager == nil {
		return nil, ErrNotSupported
	}
	return NewExtensionManager(c), nil
}
960556
func (m *Manager) FindFiles(name string, exts ...string) []string {
	var list []string
	for _, dir := range m.dirs {
		for _, ext := range exts {
			p := filepath.Join(dir, name+ext)
			if files.Exist(p) {
				list = append(list, p)
			}
		}
	}
	return list
}
1036072
func (d *driver) getAllFileSystems(
	svc *awsefs.EFS) (filesystems []*awsefs.FileSystemDescription, err error) {

	resp, err := svc.DescribeFileSystems(&awsefs.DescribeFileSystemsInput{})
	if err != nil {
		return nil, err
	}
	filesystems = append(filesystems, resp.FileSystems...)

	for resp.NextMarker != nil {
		resp, err = svc.DescribeFileSystems(&awsefs.DescribeFileSystemsInput{
			Marker: resp.NextMarker,
		})
		if err != nil {
			return nil, err
		}
		filesystems = append(filesystems, resp.FileSystems...)
	}

	return filesystems, nil
}
692087
func (def *PackageDef) FindFiles(cwd string) ([]fs.File, error) {
	// Root of the package is defined relative to package def YAML file.
	absCwd, err := filepath.Abs(cwd)
	if err != nil {
		return nil, err
	}
	root := filepath.Clean(def.Root)
	if !filepath.IsAbs(root) {
		root = filepath.Join(absCwd, root)
	}

	// Helper to get absolute path to a file given path relative to root.
	makeAbs := func(p string) string {
		return filepath.Join(root, filepath.FromSlash(p))
	}

	// Used to skip duplicates.
	seen := map[string]fs.File{}
	add := func(f fs.File) {
		if seen[f.Name()] == nil {
			seen[f.Name()] = f
		}
	}

	scanOpts := fs.ScanOptions{
		PreserveModTime:  def.PreserveModTime,
		PreserveWritable: def.PreserveWritable,
	}

	for _, chunk := range def.Data {
		// Handled elsewhere.
		if chunk.VersionFile != "" {
			continue
		}

		// Individual file.
		if chunk.File != "" {
			file, err := fs.WrapFile(makeAbs(chunk.File), root, nil, scanOpts)
			if err != nil {
				return nil, err
			}
			add(file)
			continue
		}

		// A subdirectory to scan (with filtering).
		if chunk.Dir != "" {
			// Absolute path to directory to scan.
			startDir := makeAbs(chunk.Dir)
			// Exclude files as specified in 'exclude' section.
			exclude, err := makeExclusionFilter(startDir, chunk.Exclude)
			if err != nil {
				return nil, err
			}
			// Run the scan.
			files, err := fs.ScanFileSystem(startDir, root, exclude, scanOpts)
			if err != nil {
				return nil, err
			}
			for _, f := range files {
				add(f)
			}
			continue
		}

		// LoadPackageDef does validation, so this should not happen.
		return nil, fmt.Errorf("unexpected definition: %v", chunk)
	}

	// Sort by Name().
	names := make([]string, 0, len(seen))
	for n := range seen {
		names = append(names, n)
	}
	sort.Strings(names)

	// Final sorted array of fs.File.
	out := make([]fs.File, 0, len(names))
	for _, n := range names {
		out = append(out, seen[n])
	}
	return out, nil
}
383713
func HasExtension(filename string, extensions map[string]bool) bool {
	var ext string
	if e := filepath.Ext(filename); strings.HasPrefix(e, ".") {
		ext = e[1:]
	} else {
		return false
	}

	// Case-insensitive lookup.
	// Optimistically assume a short ASCII extension and be
	// allocation-free in that case.
	var buf [10]byte
	lower := buf[:0]
	const utf8RuneSelf = 0x80 // from utf8 package, but not importing it.
	for i := 0; i < len(ext); i++ {
		c := ext[i]
		if c >= utf8RuneSelf {
			// Slow path.
			return extensions[strings.ToLower(ext)]
		}
		if 'A' <= c && c <= 'Z' {
			lower = append(lower, c+('a'-'A'))
		} else {
			lower = append(lower, c)
		}
	}
	// The conversion from []byte to string doesn't allocate in
	// a map lookup.
	return extensions[string(lower)]
}
1306434
func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension {
	if e.p == nil {
		e.p = new(struct {
			mu           sync.Mutex
			extensionMap map[int32]Extension
		})
		e.p.extensionMap = make(map[int32]Extension)
	}
	return e.p.extensionMap
}
412799
func (t *MetaIssueType) GetAllFields() (map[string]string, error) {
	ret := make(map[string]string)
	for key := range t.Fields {

		name, err := t.Fields.String(key + "/name")
		if err != nil {
			return nil, err
		}
		ret[name] = key
	}
	return ret, nil
}
1087020
func getFiles(paths []string, globs []string) []file {
	var fs []file
	for _, p := range paths {
		for _, g := range globs {
			ms, _ := filepath.Glob(filepath.Join(p, g))
			for _, m := range ms {
				r, err1 := filepath.Rel(p, m)
				fi, err2 := os.Stat(m)
				if err1 == nil && err2 == nil && !fi.IsDir() {
					fs = append(fs, file{Abs: m, Rel: r})
				}
			}
		}
	}
	return fs
}
684512
func (r *prefixedRegistrar) FindAll() []*RegisteredEntity {
	res := []*RegisteredEntity{}
	for _, re := range r.typeIndex {
		res = append(res, re)
	}
	return res
}
1271885
func (r Dns_Domain_Registration) GetExtendedAttributes(domainName *string) (resp []datatypes.Container_Dns_Domain_Registration_ExtendedAttribute, err error) {
	params := []interface{}{
		domainName,
	}
	err = r.Session.DoRequest("SoftLayer_Dns_Domain_Registration", "getExtendedAttributes", params, &r.Options, &resp)
	return
}
1246055
func (e HandleExtensionMismatchError) Error() string {
	return fmt.Sprintf("Folder handle extension mismatch, "+
		"expected: %s, actual: %s", e.Expected, e.Actual)
}
1234093
func GenerateExtension(schemaFile string, outDir string) error {
	outFileBaseName := getBaseFileNameWithoutExt(schemaFile)
	extensionNameWithoutXDashPrefix := outFileBaseName[len("x-"):]
	outDir = path.Join(outDir, "gnostic-x-"+extensionNameWithoutXDashPrefix)
	protoPackage := toProtoPackageName(extensionNameWithoutXDashPrefix)
	protoPackageName := strings.ToLower(protoPackage)
	goPackageName := protoPackageName

	protoOutDirectory := outDir + "/" + "proto"
	var err error

	projectRoot := os.Getenv("GOPATH") + "/src/github.com/googleapis/gnostic/"
	baseSchema, err := jsonschema.NewSchemaFromFile(projectRoot + "jsonschema/schema.json")
	if err != nil {
		return err
	}
	baseSchema.ResolveRefs()
	baseSchema.ResolveAllOfs()

	openapiSchema, err := jsonschema.NewSchemaFromFile(schemaFile)
	if err != nil {
		return err
	}
	openapiSchema.ResolveRefs()
	openapiSchema.ResolveAllOfs()

	// build a simplified model of the types described by the schema
	cc := NewDomain(openapiSchema, "v2") // TODO fix for OpenAPI v3

	// create a type for each object defined in the schema
	extensionNameToMessageName := make(map[string]generatedTypeInfo)
	schemaErrors := make([]error, 0)
	supportedPrimitives := make([]string, 0)
	for key := range supportedPrimitiveTypeInfos {
		supportedPrimitives = append(supportedPrimitives, key)
	}
	sort.Strings(supportedPrimitives)
	if cc.Schema.Definitions != nil {
		for _, pair := range *(cc.Schema.Definitions) {
			definitionName := pair.Name
			definitionSchema := pair.Value
			// ensure the id field is set
			if definitionSchema.ID == nil || len(*(definitionSchema.ID)) == 0 {
				schemaErrors = append(schemaErrors,
					fmt.Errorf("schema %s has no 'id' field, which must match the "+
						"name of the OpenAPI extension that the schema represents",
						definitionName))
			} else {
				if _, ok := extensionNameToMessageName[*(definitionSchema.ID)]; ok {
					schemaErrors = append(schemaErrors,
						fmt.Errorf("schema %s and %s have the same 'id' field value",
							definitionName, extensionNameToMessageName[*(definitionSchema.ID)].schemaName))
				} else if (definitionSchema.Type == nil) || (*definitionSchema.Type.String == "object") {
					extensionNameToMessageName[*(definitionSchema.ID)] = generatedTypeInfo{schemaName: definitionName}
				} else {
					// this is a primitive type
					if val, ok := supportedPrimitiveTypeInfos[*definitionSchema.Type.String]; ok {
						extensionNameToMessageName[*(definitionSchema.ID)] = generatedTypeInfo{schemaName: definitionName, optionalPrimitiveTypeInfo: &val}
					} else {
						schemaErrors = append(schemaErrors,
							fmt.Errorf("Schema %s has type '%s' which is "+
								"not supported. Supported primitive types are "+
								"%s.\n", definitionName,
								*definitionSchema.Type.String,
								supportedPrimitives))
					}
				}
			}
			typeName := cc.TypeNameForStub(definitionName)
			typeModel := cc.BuildTypeForDefinition(typeName, definitionName, definitionSchema)
			if typeModel != nil {
				cc.TypeModels[typeName] = typeModel
			}
		}
	}
	if len(schemaErrors) > 0 {
		// error has been reported.
		return compiler.NewErrorGroupOrNil(schemaErrors)
	}

	err = os.MkdirAll(outDir, os.ModePerm)
	if err != nil {
		return err
	}

	err = os.MkdirAll(protoOutDirectory, os.ModePerm)
	if err != nil {
		return err
	}

	// generate the protocol buffer description
	protoOptions := append(protoOptionsForExtensions,
		ProtoOption{Name: "java_package", Value: "org.openapi.extension." + strings.ToLower(protoPackage), Comment: "// The Java package name must be proto package name with proper prefix."},
		ProtoOption{Name: "objc_class_prefix", Value: strings.ToLower(protoPackage),
			Comment: "// A reasonable prefix for the Objective-C symbols generated from the package.\n" +
				"// It should at a minimum be 3 characters long, all uppercase, and convention\n" +
				"// is to use an abbreviation of the package name. Something short, but\n" +
				"// hopefully unique enough to not conflict with things that may come along in\n" +
				"// the future. 'GPB' is reserved for the protocol buffer implementation itself.",
		})

	proto := cc.generateProto(protoPackageName, License, protoOptions, nil)
	protoFilename := path.Join(protoOutDirectory, outFileBaseName+".proto")

	err = ioutil.WriteFile(protoFilename, []byte(proto), 0644)
	if err != nil {
		return err
	}

	// generate the compiler
	compiler := cc.GenerateCompiler(goPackageName, License, []string{
		"fmt",
		"regexp",
		"strings",
		"github.com/googleapis/gnostic/compiler",
		"gopkg.in/yaml.v2",
	})
	goFilename := path.Join(protoOutDirectory, outFileBaseName+".go")
	err = ioutil.WriteFile(goFilename, []byte(compiler), 0644)
	if err != nil {
		return err
	}
	err = exec.Command(runtime.GOROOT()+"/bin/gofmt", "-w", goFilename).Run()

	// generate the main file.
	outDirRelativeToGoPathSrc := strings.Replace(outDir, path.Join(os.Getenv("GOPATH"), "src")+"/", "", 1)

	var extensionNameKeys []string
	for k := range extensionNameToMessageName {
		extensionNameKeys = append(extensionNameKeys, k)
	}
	sort.Strings(extensionNameKeys)

	wrapperTypeIncluded := false
	var cases string
	for _, extensionName := range extensionNameKeys {
		if extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo == nil {
			cases += fmt.Sprintf(caseStringForObjectTypes, extensionName, goPackageName, extensionNameToMessageName[extensionName].schemaName)
		} else {
			wrapperTypeIncluded = true
			cases += fmt.Sprintf(caseStringForWrapperTypes, extensionName, extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.wrapperProtoName)
		}

	}
	extMainCode := fmt.Sprintf(additionalCompilerCodeWithMain, cases)
	imports := []string{
		"github.com/golang/protobuf/proto",
		"github.com/googleapis/gnostic/extensions",
		"github.com/googleapis/gnostic/compiler",
		"gopkg.in/yaml.v2",
		outDirRelativeToGoPathSrc + "/" + "proto",
	}
	if wrapperTypeIncluded {
		imports = append(imports, "github.com/golang/protobuf/ptypes/wrappers")
	}
	main := generateMainFile("main", License, extMainCode, imports)
	mainFileName := path.Join(outDir, "main.go")
	err = ioutil.WriteFile(mainFileName, []byte(main), 0644)
	if err != nil {
		return err
	}

	// format the compiler
	return exec.Command(runtime.GOROOT()+"/bin/gofmt", "-w", mainFileName).Run()
}
199868
func homeExpand(homeDir, path string) string {
	if path == "" || path[0] != '~' || (len(path) > 1 && path[1] != os.PathSeparator) {
		return path
	}
	return filepath.Join(homeDir, path[1:])
}