// TransformFromStorage finds the first transformer with a prefix matching the provided data and returns
// the result of transforming the value. It will always mark any transformation as stale that is not using
// the first transformer.
355499
func (t *prefixTransformers) TransformFromStorage(data []byte, context Context) ([]byte, bool, error) {
	for i, transformer := range t.transformers {
		if bytes.HasPrefix(data, transformer.Prefix) {
			result, stale, err := transformer.Transformer.TransformFromStorage(data[len(transformer.Prefix):], context)
			// To migrate away from encryption, user can specify an identity transformer higher up
			// (in the config file) than the encryption transformer. In that scenario, the identity transformer needs to
			// identify (during reads from disk) whether the data being read is encrypted or not. If the data is encrypted,
			// it shall throw an error, but that error should not prevent subsequent transformers from being tried.
			if len(transformer.Prefix) == 0 && err != nil {
				continue
			}
			return result, stale || i != 0, err
		}
	}
	return nil, false, t.err
}
415424
func (_m *TransientStoreRetriever) StoreForChannel(channel string) transientstore.Store {
	ret := _m.Called(channel)

	var r0 transientstore.Store
	if rf, ok := ret.Get(0).(func(string) transientstore.Store); ok {
		r0 = rf(channel)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(transientstore.Store)
		}
	}

	return r0
}
591178
func (r *RenameFamilies) Transform(mfs []*dto.MetricFamily) []*dto.MetricFamily {
	renamed := mfs[:0]
	for _, mf := range mfs {
		if to, ok := r.FromTo[mf.GetName()]; ok {
			mf.Name = &to
		}
		renamed = append(renamed, mf)

	}
	sort.Sort(familySorter(renamed))
	return renamed
}
750020
func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationCtx) error {

	const localPostCSSPath = "node_modules/postcss-cli/bin/"
	const binaryName = "postcss"

	// Try first in the project's node_modules.
	csiBinPath := filepath.Join(t.rs.WorkingDir, localPostCSSPath, binaryName)

	binary := csiBinPath

	if _, err := exec.LookPath(binary); err != nil {
		// Try PATH
		binary = binaryName
		if _, err := exec.LookPath(binary); err != nil {
			// This may be on a CI server etc. Will fall back to pre-built assets.
			return herrors.ErrFeatureNotAvailable
		}
	}

	var configFile string
	logger := t.rs.Logger

	if t.options.Config != "" {
		configFile = t.options.Config
	} else {
		configFile = "postcss.config.js"
	}

	configFile = filepath.Clean(configFile)

	// We need an abolute filename to the config file.
	if !filepath.IsAbs(configFile) {
		// We resolve this against the virtual Work filesystem, to allow
		// this config file to live in one of the themes if needed.
		fi, err := t.rs.BaseFs.Work.Fs.Stat(configFile)
		if err != nil {
			if t.options.Config != "" {
				// Only fail if the user specificed config file is not found.
				return errors.Wrapf(err, "postcss config %q not found:", configFile)
			}
			configFile = ""
		} else {
			configFile = fi.(hugofs.RealFilenameInfo).RealFilename()
		}
	}

	var cmdArgs []string

	if configFile != "" {
		logger.INFO.Println("postcss: use config file", configFile)
		cmdArgs = []string{"--config", configFile}
	}

	if optArgs := t.options.toArgs(); len(optArgs) > 0 {
		cmdArgs = append(cmdArgs, optArgs...)
	}

	cmd := exec.Command(binary, cmdArgs...)

	cmd.Stdout = ctx.To
	cmd.Stderr = os.Stderr

	stdin, err := cmd.StdinPipe()
	if err != nil {
		return err
	}

	go func() {
		defer stdin.Close()
		io.Copy(stdin, ctx.From)
	}()

	err = cmd.Run()
	if err != nil {
		return err
	}

	return nil
}
1266037
func Transform(extensions map[string]interface{}) map[string]interface{} {
	if extensions == nil {
		return nil
	}
	out := make(map[string]interface{}, len(extensions))
	for name, payload := range extensions {
		transform, ok := transformers[name]
		if !ok {
			// No transformer registered, skip.
			continue
		}
		transformedPayload := transform(payload)
		if transformedPayload == nil {
			// Transformer returned nothing, skip.
			continue
		}
		out[name] = transformedPayload
	}
	return out
}
1024282
func (sb *storageBackend) StorageInstance(tag names.StorageTag) (StorageInstance, error) {
	s, err := sb.storageInstance(tag)
	return s, err
}
325346
func (identityTransformer) TransformToStorage(b []byte, context value.Context) ([]byte, error) {
	return b, nil
}
446539
func (r *RemoveLabels) Transform(mfs []*dto.MetricFamily) []*dto.MetricFamily {
	for i := range mfs {
		for j, m := range mfs[i].Metric {
			// Filter out labels
			labels := m.Label[:0]
			for _, l := range m.Label {
				if _, ok := r.Labels[l.GetName()]; !ok {
					labels = append(labels, l)
				}
			}
			mfs[i].Metric[j].Label = labels
		}
	}
	return mfs
}
1053498
func ReadCharmFromStorage(store storage.Storage, dataDir, storagePath string) (string, error) {
	// Ensure the working directory exists.
	tmpDir := filepath.Join(dataDir, "charm-get-tmp")
	if err := os.MkdirAll(tmpDir, 0755); err != nil {
		return "", errors.Annotate(err, "cannot create charms tmp directory")
	}

	// Use the storage to retrieve and save the charm archive.
	reader, _, err := store.Get(storagePath)
	if err != nil {
		return "", errors.Annotate(err, "cannot get charm from model storage")
	}
	defer reader.Close()

	charmFile, err := ioutil.TempFile(tmpDir, "charm")
	if err != nil {
		return "", errors.Annotate(err, "cannot create charm archive file")
	}
	if _, err = io.Copy(charmFile, reader); err != nil {
		cleanupFile(charmFile)
		return "", errors.Annotate(err, "error processing charm archive download")
	}
	charmFile.Close()
	return charmFile.Name(), nil
}
770305
func (t *prefixTransformers) TransformToStorage(data []byte, context Context) ([]byte, error) {
	transformer := t.transformers[0]
	prefixedData := make([]byte, len(transformer.Prefix), len(data)+len(transformer.Prefix))
	copy(prefixedData, transformer.Prefix)
	result, err := transformer.Transformer.TransformToStorage(data, context)
	if err != nil {
		return nil, err
	}
	prefixedData = append(prefixedData, result...)
	return prefixedData, nil
}
1322644
func (t removeF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
	for r, sz := rune(0), 0; len(src) > 0; src = src[sz:] {

		if r = rune(src[0]); r < utf8.RuneSelf {
			sz = 1
		} else {
			r, sz = utf8.DecodeRune(src)

			if sz == 1 {
				// Invalid rune.
				if !atEOF && !utf8.FullRune(src) {
					err = ErrShortSrc
					break
				}
				// We replace illegal bytes with RuneError. Not doing so might
				// otherwise turn a sequence of invalid UTF-8 into valid UTF-8.
				// The resulting byte sequence may subsequently contain runes
				// for which t(r) is true that were passed unnoticed.
				if !t(r) {
					if nDst+3 > len(dst) {
						err = ErrShortDst
						break
					}
					nDst += copy(dst[nDst:], "\uFFFD")
				}
				nSrc++
				continue
			}
		}

		if !t(r) {
			if nDst+sz > len(dst) {
				err = ErrShortDst
				break
			}
			nDst += copy(dst[nDst:], src[:sz])
		}
		nSrc += sz
	}
	return
}
1145110
func (b *Base) Transform(entity interface{}) map[string]interface{} {
	b.raw = entity
	b.reflected = reflect.Indirect(reflect.ValueOf(entity))
	return b.result()
}
318250
func GetStorageNodeAffinityFromAnnotation(annotations map[string]string) (*v1.NodeAffinity, error) {
	if len(annotations) > 0 && annotations[common.AlphaStorageNodeAffinityAnnotation] != "" {
		var affinity v1.NodeAffinity
		err := json.Unmarshal([]byte(annotations[common.AlphaStorageNodeAffinityAnnotation]), &affinity)
		if err != nil {
			return nil, err
		}
		return &affinity, nil
	}
	return nil, nil
}
642777
func (xf *Transform) TransformVect(v vect.Vect) vect.Vect {
	return vect.Add(xf.Position, xf.RotateVect(v))
}
1279836
func NewObjectStorage(base, temporal storer.EncodedObjectStorer) *ObjectStorage {
	return &ObjectStorage{EncodedObjectStorer: base, temporal: temporal}
}
1073090
func (c *Client) FindStoragePoolsForMigration(p *FindStoragePoolsForMigrationParameter) (*StoragePool, error) {
	obj, err := c.Request("findStoragePoolsForMigration", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*StoragePool), err
}
1005632
func (st *State) ImageStorage() imagestorage.Storage {
	return imageStorageNewStorage(st.session, st.ModelUUID())
}