// BindImporter attaches a custom importer Go function to an import in Sass
559861
func BindImporter(opts SassOptions, resolver ImportResolver) int {

	idx := globalImports.Set(resolver)
	ptr := unsafe.Pointer(uintptr(idx))

	imper := C.sass_make_importer(
		C.Sass_Importer_Fn(C.SassImporterHandler),
		C.double(0),
		ptr,
	)
	impers := C.sass_make_importer_list(1)
	C.sass_importer_set_list_entry(impers, 0, imper)

	C.sass_option_set_c_importers(
		(*C.struct_Sass_Options)(unsafe.Pointer(opts)),
		impers,
	)
	return idx
}
527253
func addImportsForInterfaceMethods(imports importMap, it reflect.Type) {
	// Handle each method.
	for i := 0; i < it.NumMethod(); i++ {
		m := it.Method(i)
		addImportsForType(imports, m.Type)
	}
}
485192
func ParsedImports(imp []*ast.Import) func(r *Rego) {
	return func(r *Rego) {
		r.parsedImports = append(r.parsedImports, imp...)
	}
}
537577
func (s *GetParametersForImportOutput) SetImportToken(v []byte) *GetParametersForImportOutput {
	s.ImportToken = v
	return s
}
998394
func (p *Imports) Bind(opts libs.SassOptions) {
	entries := make([]libs.ImportEntry, p.Len())
	i := 0

	p.RLock()
	for _, ent := range p.m {
		bs := ent.bytes
		entries[i] = libs.ImportEntry{
			Parent: ent.Prev,
			Path:   ent.Path,
			Source: string(bs),
		}
		i++
	}
	p.RUnlock()

	resolver := func(url string, prev string) (newURL string, body string, resolved bool) {
		if p.resolver != nil {
			newURL, body, resolved = p.resolver(url, prev)
			if resolved {
				return
			}
		}
		entry, err := libs.GetEntry(entries, prev, url)
		if err == nil {
			return url, entry, true
		}
		return "", "", false
	}

	// set entries somewhere so GC doesn't collect it
	p.idx = libs.BindImporter(opts, resolver)
}
930388
func NewImportListener(tenantID string) *ImportListener {
	return &ImportListener{
		tenantID: tenantID,
		apps:     make(map[string]struct{}),
	}
}
795678
func NewImport(name, path string) *ImportSpec {
	return &ImportSpec{Name: name, Path: path}
}
1282697
func (w *Wrapper) inImportDir(file string) bool {
	for _, imp := range w.ImportDirs {
		if strings.HasPrefix(file, imp) {
			return true
		}
	}
	return false
}
660373
func handleImport(s *Server) http.Handler {
	return contextHandler(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
		span, jsonMetrics, err := unmarshalMetricsFromHTTP(ctx, s.TraceClient, w, r)
		if err != nil {
			log.WithError(err).Error("Error unmarshalling metrics in global import")
			span.Add(ssf.Count("import.unmarshal.errors_total", 1, nil))
			return
		}
		// the server usually waits for this to return before finalizing the
		// response, so this part must be done asynchronously
		go s.ImportMetrics(span.Attach(ctx), jsonMetrics)
	})
}
520705
func (s *SourceImportAuthor) GetImportURL() string {
	if s == nil || s.ImportURL == nil {
		return ""
	}
	return *s.ImportURL
}
1073436
func (csp *impl) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) {
	return nil, nil
}
285940
func InitializeImportCollector(
	scheduled bool,
	cbCollectISCounts QueuedImageStreamFetcher,
) {
	registerLock.Lock()
	defer registerLock.Unlock()

	if scheduled {
		isc.cbCollectScheduledCounts = cbCollectISCounts
	} else {
		isc.cbCollectISCounts = cbCollectISCounts
	}

	if collectorRegistered {
		return
	}

	if isc.cbCollectISCounts != nil && isc.cbCollectScheduledCounts != nil {
		prometheus.MustRegister(&isc)
		collectorRegistered = true
		klog.V(4).Info("Image import controller metrics registered with prometherus")
	}
}
1128216
func generateImports(ctx *context, w io.Writer) {
	fmt.Fprintf(w, "import api \"%s\"\n", govppApiImportPath)
	fmt.Fprintf(w, "import struc \"%s\"\n", "github.com/lunixbochs/struc")
	fmt.Fprintf(w, "import bytes \"%s\"\n", "bytes")
	fmt.Fprintln(w)

	fmt.Fprintf(w, "// Reference imports to suppress errors if they are not otherwise used.\n")
	fmt.Fprintf(w, "var _ = api.RegisterMessage\n")
	fmt.Fprintf(w, "var _ = struc.Pack\n")
	fmt.Fprintf(w, "var _ = bytes.NewBuffer\n")
	fmt.Fprintln(w)

	/*fmt.Fprintln(w, "// This is a compile-time assertion to ensure that this generated file")
	fmt.Fprintln(w, "// is compatible with the GoVPP api package it is being compiled against.")
	fmt.Fprintln(w, "// A compilation error at this line likely means your copy of the")
	fmt.Fprintln(w, "// GoVPP api package needs to be updated.")
	fmt.Fprintln(w, "const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package")
	fmt.Fprintln(w)*/
}
14659
func addImportsForType(imports importMap, t reflect.Type) {
	// Add any import needed for the type itself.
	addImportForType(imports, t)

	// Handle special cases where recursion is needed.
	switch t.Kind() {
	case reflect.Array, reflect.Chan, reflect.Ptr, reflect.Slice:
		addImportsForType(imports, t.Elem())

	case reflect.Func:
		// Input parameters.
		for i := 0; i < t.NumIn(); i++ {
			addImportsForType(imports, t.In(i))
		}

		// Return values.
		for i := 0; i < t.NumOut(); i++ {
			addImportsForType(imports, t.Out(i))
		}

	case reflect.Map:
		addImportsForType(imports, t.Key())
		addImportsForType(imports, t.Elem())
	}
}
396304
func (i *ImportRestriction) ForbiddenImportsFor(pkg Package) []string {
	if !i.isRestrictedPath(pkg.ImportPath) {
		return []string{}
	}
	return i.forbiddenImportsFor(pkg)
}
1051000
func (ce *ContainerEndpoints) RunImportListener(cancel <-chan struct{}, tenantID string, binds ...zkservice.ImportBinding) {
	plog.Debug("Running import listener")
	defer plog.Debug("Exited import listener")

	// set up the import listener and add the import bindings
	listener := registry.NewImportListener(tenantID)
	for _, bind := range binds {
		rgx, err := regexp.Compile(fmt.Sprintf("^%s$", bind.Application))
		if err != nil {
			plog.WithField("regex", bind.Application).WithError(err).Warn("Could not compile regex; skipping")
			continue
		}
		ch := listener.AddTerm(rgx)
		go func(bind zkservice.ImportBinding) {
			for {
				select {
				case app := <-ch:
					go ce.AddImport(cancel, app, bind)
				case <-cancel:
					return
				}
			}
		}(bind)
	}

	// start the import listener
	for {
		select {
		case conn := <-zzk.Connect("/", zzk.GetLocalConnection):
			if conn != nil {

				plog.Debug("Received coordinator connection")
				listener.Run(cancel, conn)

				select {
				case <-cancel:
					return
				default:
				}
			}
		case <-cancel:
			return
		}
	}
}
250700
func (csp *CSP) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) {
	// Validate arguments
	if raw == nil {
		return nil, errors.New("Invalid raw. It must not be nil.")
	}
	if opts == nil {
		return nil, errors.New("Invalid opts. It must not be nil.")
	}

	keyImporter, found := csp.KeyImporters[reflect.TypeOf(opts)]
	if !found {
		return nil, errors.Errorf("Unsupported 'KeyImportOpts' provided [%v]", opts)
	}

	k, err = keyImporter.KeyImport(raw, opts)
	if err != nil {
		return nil, errors.Wrapf(err, "Failed importing key with opts [%v]", opts)
	}

	// If the key is not Ephemeral, store it.
	if !opts.Ephemeral() {
		// Store the key
		err = csp.ks.StoreKey(k)
		if err != nil {
			return nil, errors.Wrapf(err, "Failed storing imported key with opts [%v]", opts)
		}
	}

	return
}