// GetAssembleInputFiles finds a io.openshift.s2i.assemble-input-files label on the given image.
483110
func (f *FakeDocker) GetAssembleInputFiles(image string) (string, error) {
	return f.AssembleInputFilesResult, f.AssembleInputFilesError
}
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
}
1279843
func getSymlinkedAssets(path string) ([]string, error) {
	assets := []string{}
	maxLevels := 100
	levels := maxLevels
	for {
		if levels < 1 {
			return nil, fmt.Errorf("Too many levels of symlinks (>$d)", maxLevels)
		}
		fi, err := os.Lstat(path)
		if err != nil {
			return nil, err
		}
		asset := getAssetString(path, path)
		assets = append(assets, asset)
		if !isSymlink(fi.Mode()) {
			break
		}
		symTarget, err := os.Readlink(path)
		if err != nil {
			return nil, err
		}
		if filepath.IsAbs(symTarget) {
			path = symTarget
		} else {
			path = filepath.Join(filepath.Dir(path), symTarget)
		}
		levels--
	}
	return assets, nil
}
959450
func generateInputValidator(packageName, dir string) error {
	var ctx = struct {
		PackageName string
	}{
		PackageName: packageName,
	}
	fileName := filepath.Join(dir, inputValidatorFileResult)
	return commons.GenerateFile(ctx, inputValidatorTemplateLocation, "struct_input_validator_template", fileName, true)
}
1014474
func (r Network_Storage_Iscsi) GetFolderList() (resp []datatypes.Container_Network_Storage_Hub_ObjectStorage_Folder, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Iscsi", "getFolderList", nil, &r.Options, &resp)
	return
}
1120827
func (f *FakeDocker) GetLabels(name string) (map[string]string, error) {
	return f.Labels, f.LabelsError
}
514302
func setupInputConfigMaps(pod *corev1.Pod, container *corev1.Container, configs []buildv1.ConfigMapBuildSource) {
	for _, c := range configs {
		mountConfigMapVolume(pod, container, c.ConfigMap.Name, filepath.Join(ConfigMapBuildSourceBaseMountPath, c.ConfigMap.Name), "build")
		klog.V(3).Infof("%s will be used as a build config in %s", c.ConfigMap.Name, ConfigMapBuildSourceBaseMountPath)
	}
}
1048776
func getLabelsByContainerID(containerID string, frameworks []frameworkInfo, log *logrus.Entry) map[string]string {
	labels := map[string]string{}
	for _, framework := range frameworks {
		log.Debugf("Attempting to add labels to %v framework", framework)
		for _, executor := range framework.Executors {
			log.Debugf("Found executor %v for framework %v", framework, executor)
			if executor.Container == containerID {
				log.Debugf("ContainerID %v for executor %v is a match, adding labels", containerID, executor)
				for _, pair := range executor.Labels {
					if _, inSlice := cosmosLabels[pair.Key]; inSlice {
						continue
					}
					if len(pair.Value) > maxLabelLength {
						log.Warnf("Label %s is longer than %d chars; discarding label", pair.Key, maxLabelLength)
						log.Debugf("Discarded label value: %s", pair.Value)
						continue
					}
					log.Debugf("Adding label for containerID %v: %v = %+v", containerID, pair.Key, pair.Value)
					labels[pair.Key] = pair.Value
				}
				return labels
			}
		}
	}
	return labels
}
992564
func disassemble(asm []byte) ([]plugin.Inst, error) {
	buf := bytes.NewBuffer(asm)
	function, file, line := "", "", 0
	var assembly []plugin.Inst
	for {
		input, err := buf.ReadString('\n')
		if err != nil {
			if err != io.EOF {
				return nil, err
			}
			if input == "" {
				break
			}
		}

		if fields := objdumpAsmOutputRE.FindStringSubmatch(input); len(fields) == 3 {
			if address, err := strconv.ParseUint(fields[1], 16, 64); err == nil {
				assembly = append(assembly,
					plugin.Inst{
						Addr:     address,
						Text:     fields[2],
						Function: function,
						File:     file,
						Line:     line,
					})
				continue
			}
		}
		if fields := objdumpOutputFileLine.FindStringSubmatch(input); len(fields) == 3 {
			if l, err := strconv.ParseUint(fields[2], 10, 32); err == nil {
				file, line = fields[1], int(l)
			}
			continue
		}
		if fields := objdumpOutputFunction.FindStringSubmatch(input); len(fields) == 2 {
			function = fields[1]
			continue
		}
		// Reset on unrecognized lines.
		function, file, line = "", "", 0
	}

	return assembly, nil
}
409081
func getLabelsFromContainerInspect(containerInfo *types.ContainerJSON) map[string]string {
	if containerInfo != nil && containerInfo.Config != nil {
		return containerInfo.Config.Labels
	}
	return nil
}
738214
func (r ComponentReferences) ImageComponentRefs() (refs ComponentReferences) {
	return r.filter(func(ref ComponentReference) bool {
		if ref.Input().ScratchImage {
			return true
		}
		return ref.Input() != nil && ref.Input().ResolvedMatch != nil && ref.Input().ResolvedMatch.IsImage()
	})
}
859579
func getKernelFiles(context *cli.Context, spec *specs.Spec) (string, string, string, string, error) {
	kernel := chooseKernelFromConfigs(context, spec)
	initrd := chooseInitrdFromConfigs(context, spec)
	bios := chooseBiosFromConfigs(context, spec)
	cbfs := chooseCbfsFromConfigs(context, spec)
	bundle := context.String("bundle")

	if kernel != "" && initrd != "" {
		return kernel, initrd, bios, cbfs, nil
	}

	// choose from filesystem
	for k, v := range map[*string][]string{
		&kernel: {
			filepath.Join(bundle, spec.Root.Path, "boot/vmlinuz"),
			filepath.Join(bundle, "boot/vmlinuz"),
			filepath.Join(bundle, "vmlinuz"),
			filepath.Join(defaultKernelInstallDir, "kernel"),
		},
		&initrd: {
			filepath.Join(bundle, spec.Root.Path, "boot/initrd.img"),
			filepath.Join(bundle, "boot/initrd.img"),
			filepath.Join(bundle, "initrd.img"),
			filepath.Join(defaultKernelInstallDir, "hyper-initrd.img"),
		},
		&bios: {
			filepath.Join(bundle, spec.Root.Path, "boot/bios.bin"),
			filepath.Join(bundle, "boot/bios.bin"),
			filepath.Join(bundle, "bios.bin"),
			filepath.Join(defaultKernelInstallDir, "bios.bin"),
		},
		&cbfs: {
			filepath.Join(bundle, spec.Root.Path, "boot/cbfs.rom"),
			filepath.Join(bundle, "boot/cbfs.rom"),
			filepath.Join(bundle, "cbfs.rom"),
			filepath.Join(defaultKernelInstallDir, "cbfs.rom"),
		},
	} {
		if *k == "" {
			*k = firstExistingFile(v)
		}
		if *k != "" {
			var err error
			*k, err = filepath.Abs(*k)
			if err != nil {
				return "", "", "", "", fmt.Errorf("cannot get abs path for kernel files: %v", err)
			}
		}
	}

	return kernel, initrd, bios, cbfs, nil
}
826146
func (d *stiDocker) GetLabels(name string) (map[string]string, error) {
	name = getImageName(name)
	resp, err := d.InspectImage(name)
	if err != nil {
		glog.V(4).Infof("error inspecting image %s: %v", name, err)
		return nil, s2ierr.NewInspectImageError(name, err)
	}
	return resp.Config.Labels, nil
}
1353798
func getImageComponents(
	g genericgraph.Graph,
	processedImages map[*imagegraph.ImageNode]*Job,
	image *imagegraph.ImageNode,
) (components ComponentRetentions, blocked bool) {
	components = make(ComponentRetentions)

	for _, node := range g.From(image) {
		kinds := g.EdgeKinds(g.Edge(image, node))
		if len(kinds.Intersection(sets.NewString(
			ReferencedImageLayerEdgeKind,
			ReferencedImageConfigEdgeKind,
			ReferencedImageManifestEdgeKind,
		))) == 0 {
			continue
		}

		imageStrongRefCounter := 0
		imageMarkedForDeletionCounter := 0
		referencingStreams := map[*imagegraph.ImageStreamNode]struct{}{}
		referencingImages := map[*imagegraph.ImageNode]struct{}{}

		comp, ok := node.(*imagegraph.ImageComponentNode)
		if !ok {
			continue
		}

		for _, ref := range g.To(comp) {
			switch t := ref.(type) {
			case (*imagegraph.ImageNode):
				imageStrongRefCounter++
				if _, processed := processedImages[t]; processed {
					imageMarkedForDeletionCounter++
				}
				referencingImages[t] = struct{}{}

			case *imagegraph.ImageStreamNode:
				referencingStreams[t] = struct{}{}

			default:
				continue
			}
		}

		switch {
		// the component is referenced only by the given image -> prunable globally
		case imageStrongRefCounter < 2:
			components.Add(comp, true)
		// the component can be pruned once the other referencing image that is being deleted is finished;
		// don't touch it until then
		case imageStrongRefCounter-imageMarkedForDeletionCounter < 2:
			return nil, true
		// not prunable component
		default:
			components.Add(comp, false)
		}

		if addComponentReferencingStreams(
			g,
			components,
			referencingImages,
			referencingStreams,
			processedImages,
			comp,
		) {
			return nil, true
		}
	}

	return
}
266862
func zipInputFiles(ctx context.Context, files []fs.File, w io.Writer, level int) error {
	logging.Infof(ctx, "About to zip %d files with compression level %d", len(files), level)

	writer := zip.NewWriter(w)
	defer writer.Close()

	writer.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
		return flate.NewWriter(out, level)
	})

	// Reports zipping progress to the log each second.
	lastReport := time.Time{}
	progress := func(count int) {
		if time.Since(lastReport) > time.Second {
			lastReport = time.Now()
			logging.Infof(ctx, "Zipping files: %d files left", len(files)-count)
		}
	}

	for i, in := range files {
		progress(i)

		// Bail out early if context is canceled.
		if err := ctx.Err(); err != nil {
			return err
		}

		// Intentionally do not add file mode to make zip archive
		// deterministic. Timestamps sometimes need to be preserved, but normally
		// are zero valued. See also zip.FileInfoHeader() implementation.
		fh := zip.FileHeader{
			Name:   in.Name(),
			Method: zip.Deflate,
		}
		if level == 0 || in.Symlink() || isLikelyAlreadyCompressed(in) {
			fh.Method = zip.Store
		}

		mode := os.FileMode(0400)
		if in.Executable() {
			mode |= 0100
		}
		if in.Writable() {
			mode |= 0200
		}
		if in.Symlink() {
			mode |= os.ModeSymlink
		}
		fh.SetMode(mode)

		if !in.ModTime().IsZero() {
			fh.SetModTime(in.ModTime())
		}

		fh.ExternalAttrs |= uint32(in.WinAttrs())

		dst, err := writer.CreateHeader(&fh)
		if err != nil {
			return err
		}
		if in.Symlink() {
			err = zipSymlinkFile(dst, in)
		} else {
			err = zipRegularFile(dst, in)
		}
		if err != nil {
			return err
		}
	}

	return nil
}
41301
func getBucketMultipartResources(values url.Values) (prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int, encodingType string, errCode APIErrorCode) {
	errCode = ErrNone

	if values.Get("max-uploads") != "" {
		var err error
		if maxUploads, err = strconv.Atoi(values.Get("max-uploads")); err != nil {
			errCode = ErrInvalidMaxUploads
			return
		}
	} else {
		maxUploads = maxUploadsList
	}

	prefix = values.Get("prefix")
	keyMarker = values.Get("key-marker")
	uploadIDMarker = values.Get("upload-id-marker")
	delimiter = values.Get("delimiter")
	encodingType = values.Get("encoding-type")
	return
}
893034
func GeneratorInputFromMatch(match *ComponentMatch) (GeneratorInput, error) {
	input := GeneratorInput{}
	errs := []error{}

	if match.DockerImage != nil && match.DockerImage.Config != nil {
		input.Job = isGeneratorJobImage(match.DockerImage)

		if value, ok := match.DockerImage.Config.Labels[labelGenerateTokenAs]; ok {
			if token, err := parseGenerateTokenAs(value); err != nil {
				errs = append(errs, err)
			} else {
				input.Token = token
			}
		}
	}

	if match.ImageStream != nil {
		input.Job = isGeneratorJobImageStreamTag(match.ImageStream, match.ImageTag)

		if t, hasTag := imageutil.SpecHasTag(match.ImageStream, match.ImageTag); hasTag {
			if value, ok := t.Annotations[labelGenerateTokenAs]; ok {
				if token, err := parseGenerateTokenAs(value); err != nil {
					errs = append(errs, err)
				} else {
					input.Token = token
				}
			}
		}
	}
	return input, errors.NewAggregate(errs)
}