// CreateFrom creates a new chart, but scaffolds it from the src chart.
765523
func CreateFrom(chartfile *chart.Metadata, dest string, src string) error {
	schart, err := Load(src)
	if err != nil {
		return fmt.Errorf("could not load %s: %s", src, err)
	}

	schart.Metadata = chartfile

	var updatedTemplates []*chart.Template

	for _, template := range schart.Templates {
		newData := Transform(string(template.Data), "<CHARTNAME>", schart.Metadata.Name)
		updatedTemplates = append(updatedTemplates, &chart.Template{Name: template.Name, Data: newData})
	}

	schart.Templates = updatedTemplates
	if schart.Values != nil {
		schart.Values = &chart.Config{Raw: string(Transform(schart.Values.Raw, "<CHARTNAME>", schart.Metadata.Name))}
	}
	return SaveDir(schart, dest)
}
982376
func (t *Type) createTypeFromPropProperty(name string, apiDef *APIDefinition) {
	p := t.Properties[name]
	// only process map[interface]interface{}
	propMap, ok := p.(map[interface{}]interface{})
	if !ok {
		return
	}

	// only process if it has 'properties' field
	propsIf, ok := propMap["properties"]
	if !ok {
		return
	}

	// check validity of the properties
	props, ok := propsIf.(map[interface{}]interface{})
	if !ok {
		panic("inline properties expect properties in type:map[string]interface{}")
	}

	newName := t.Name + name
	created := apiDef.createType(newName, propMap["type"], props)

	propMap["type"] = newName

	// delete the 'properties' field
	delete(propMap, "properties")

	t.Properties[name] = propMap

	// post process the created type
	if created {
		createdType := apiDef.Types[newName]
		createdType.postProcess(newName, apiDef)
	}

}
788870
func (c *RWI) WriteFrom(r io.Reader) error {
	_, err := io.Copy(c.writer, r)
	return err
}
1353760
func (c Config) ReadFrom(r io.Reader) (int64, error) {
	data, err := ioutil.ReadAll(r)
	if err != nil {
		return int64(len(data)), err
	}
	if err = json.Unmarshal(data, &c); err != nil {
		return int64(len(data)), err
	}
	return int64(len(data)), nil
}
934570
func (t *TraceFS) Create(ctx context.Context, path string) (wc io.WriteCloser, err error) {
	if tr, ok := trace.FromContext(ctx); ok {
		tr.LazyPrintf("%v: create: %v", t.name, path)
		defer func() {
			if err != nil {
				tr.LazyPrintf("%v: error: %v", t.name, err)
				tr.SetError()
			}
		}()
	}
	return t.fs.Create(ctx, path)
}
1250706
func ImportFrom(path string) ([]Config, error) {
	var cfgs []Config
	fmt.Println("walking:", path)
	walk := func(filename string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if info.IsDir() {
			return nil
		}
		id := filepath.Base(filepath.Dir(filename))
		base := filepath.Base(filename)
		if !strings.HasSuffix(base, ".json") {
			return nil
		}
		var tmp []Config
		// eat all these errors since we're searching for matching json
		file, _ := os.Open(filename)
		blob, _ := ioutil.ReadAll(file)
		_ = file.Close()
		_ = json.Unmarshal(blob, &tmp)
		for _, c := range tmp {
			if c.LoginURL == "" || c.Username == "" {
				continue
			}
			c.ID = fmt.Sprintf("%s:%s", id, c.Username)
			fmt.Println("importing...", c.ID)
			cfgs = append(cfgs, c)
		}
		return nil
	}
	err := filepath.Walk(path, walk)
	fmt.Printf("loaded %d configs\n", len(cfgs))
	return cfgs, err
}
1048687
func CreateDirForFile(path string) error {
	dir := filepath.Dir(path)
	return CreateDirIfNotExists(dir)
}
304978
func (c *imageStreamImports) Create(imageStreamImport *image.ImageStreamImport) (result *image.ImageStreamImport, err error) {
	result = &image.ImageStreamImport{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("imagestreamimports").
		Body(imageStreamImport).
		Do().
		Into(result)
	return
}
495619
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height int32, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(
		pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
1060016
func (c *controllerRevisions) Create(controllerRevision *v1beta2.ControllerRevision) (result *v1beta2.ControllerRevision, err error) {
	result = &v1beta2.ControllerRevision{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("controllerrevisions").
		Body(controllerRevision).
		Do().
		Into(result)
	return
}
929933
func createFromMapMixed(data map[string][]interface{}, format byte) (headers []string, tData []*TabulateRow) {

	var dataslice [][]interface{}
	for key, value := range data {
		headers = append(headers, key)
		dataslice = append(dataslice, value)
	}
	return headers, createFromMixed(dataslice, format)
}
1036563
func NewHistogramFrom(opts prometheus.HistogramOpts, labelNames []string) *Histogram {
	hv := prometheus.NewHistogramVec(opts, labelNames)
	prometheus.MustRegister(hv)
	return NewHistogram(hv)
}
751683
func (a *Driver) CreateFromTemplate(id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *graphdriver.CreateOpts, readWrite bool) error {
	return graphdriver.NaiveCreateFromTemplate(a, id, template, templateIDMappings, parent, parentIDMappings, opts, readWrite)
}
94073
func CreateTargetFrom(tablet *topodatapb.Tablet) *query.Target {
	return &query.Target{
		Cell:       tablet.Alias.Cell,
		Keyspace:   tablet.Keyspace,
		Shard:      tablet.Shard,
		TabletType: tablet.Type,
	}
}
212020
func (target *Surface) CreateForRectangle(x, y, width, height float64) *Surface {
	ret := wrapSurface(C.cairo_surface_create_for_rectangle(target.Ptr, C.double(x), C.double(y), C.double(width), C.double(height)))
	if err := target.status(); err != nil {
		panic(err)
	}
	return ret
}
1077104
func (b modelBuilder) addModelFrom(sample interface{}) {
	if modelOrNil := b.addModel(reflect.TypeOf(sample), ""); modelOrNil != nil {
		// allow customizations
		if buildable, ok := sample.(ModelBuildable); ok {
			modelOrNil = buildable.PostBuildModel(modelOrNil)
			b.Models.Put(modelOrNil.Id, *modelOrNil)
		}
	}
}
1196525
func (s *String) ReadFrom(r io.Reader) (n int64, err error) {
	// unsigned short, can't use Short
	var length uint16
	err = binary.Read(r, binary.BigEndian, &length)
	if err != nil {
		return 0, err
	}
	n = int64(length)

	if length > 0 {
		// Read length bytes
		arr := make([]byte, length)

		var nn int
		nn, err = io.ReadFull(r, arr)
		if err != nil {
			return
		}
		n += int64(nn)

		s.Value = string(arr)
	}

	return
}