// manifest is called exactly once for each constructor to generate its value.
183646
func (c *ctor) manifest(s *Psyringe) {
	defer c.finishWithError(nil)
	wg := sync.WaitGroup{}
	numArgs := len(c.inTypes)
	wg.Add(numArgs)
	args := make([]reflect.Value, numArgs)
	for i, t := range c.inTypes {
		s, c, i, t := s, c, i, t
		go func() {
			defer wg.Done()
			v, err := s.getValueForConstructor(c, i, t)
			if err != nil {
				c.finishWithError(err)
			}
			args[i] = v
		}()
	}
	wg.Wait()
	v, err := c.construct(args)
	if err != nil {
		c.finishWithError(err)
	}
	c.value = &v
}
150828
func (p *Partition) Manifest() *Manifest {
	m := &Manifest{
		Levels:  p.levels,
		Files:   make([]string, len(p.fileSet.files)),
		Version: p.version,
		path:    p.ManifestPath(),
	}

	for j, f := range p.fileSet.files {
		m.Files[j] = filepath.Base(f.Path())
	}

	return m
}
905315
func verifyGenerateManifests(
	ctx context.Context, repoRes *argoappv1.Repository, helmRepos []*argoappv1.HelmRepository, spec *argoappv1.ApplicationSpec, repoClient repository.RepoServerServiceClient) []argoappv1.ApplicationCondition {

	var conditions []argoappv1.ApplicationCondition
	if spec.Destination.Server == "" || spec.Destination.Namespace == "" {
		conditions = append(conditions, argoappv1.ApplicationCondition{
			Type:    argoappv1.ApplicationConditionInvalidSpecError,
			Message: errDestinationMissing,
		})
	}
	req := repository.ManifestRequest{
		Repo: &argoappv1.Repository{
			Repo: spec.Source.RepoURL,
		},
		HelmRepos:         helmRepos,
		Revision:          spec.Source.TargetRevision,
		Namespace:         spec.Destination.Namespace,
		ApplicationSource: &spec.Source,
	}
	if repoRes != nil {
		req.Repo.Username = repoRes.Username
		req.Repo.Password = repoRes.Password
		req.Repo.SSHPrivateKey = repoRes.SSHPrivateKey
	}

	// Only check whether we can access the application's path,
	// and not whether it actually contains any manifests.
	_, err := repoClient.GenerateManifest(ctx, &req)
	if err != nil {
		conditions = append(conditions, argoappv1.ApplicationCondition{
			Type:    argoappv1.ApplicationConditionInvalidSpecError,
			Message: fmt.Sprintf("Unable to generate manifests in %s: %v", spec.Source.Path, err),
		})
	}

	return conditions
}
263883
func ExportManifest(m interface{}) *Manifest {
	v := reflect.ValueOf(m)
	return (*Manifest)(unsafe.Pointer(v.Pointer()))
}
181829
func (cli *DockerCli) ManifestStore() manifeststore.Store {
	// TODO: support override default location from config file
	return manifeststore.NewStore(filepath.Join(config.Dir(), "manifests"))
}
1357321
func (a *Remote) Manifest(ctx context.Context, ref string) (ImageEntry, error) {
	repository, err := client.NewRepository(named{a.repo}, a.base, a.transport)
	if err != nil {
		return ImageEntry{}, err
	}
	manifests, err := repository.Manifests(ctx)
	if err != nil {
		return ImageEntry{}, err
	}
	var manifestDigest digest.Digest
	digestOpt := client.ReturnContentDigest(&manifestDigest)
	manifest, fetchErr := manifests.Get(ctx, digest.Digest(ref), digestOpt, distribution.WithTagOption{ref})

interpret:
	if fetchErr != nil {
		return ImageEntry{}, fetchErr
	}

	info := image.Info{ID: a.repo.ToRef(ref), Digest: manifestDigest.String()}

	// TODO(michael): can we type switch? Not sure how dependable the
	// underlying types are.
	switch deserialised := manifest.(type) {
	case *schema1.SignedManifest:
		var man schema1.Manifest = deserialised.Manifest
		// for decoding the v1-compatibility entry in schema1 manifests
		var v1 struct {
			ID      string    `json:"id"`
			Created time.Time `json:"created"`
			OS      string    `json:"os"`
			Arch    string    `json:"architecture"`
		}

		if err = json.Unmarshal([]byte(man.History[0].V1Compatibility), &v1); err != nil {
			return ImageEntry{}, err
		}
		// This is not the ImageID that Docker uses, but assumed to
		// identify the image as it's the topmost layer.
		info.ImageID = v1.ID
		info.CreatedAt = v1.Created
	case *schema2.DeserializedManifest:
		var man schema2.Manifest = deserialised.Manifest
		configBytes, err := repository.Blobs(ctx).Get(ctx, man.Config.Digest)
		if err != nil {
			return ImageEntry{}, err
		}

		var config struct {
			Arch    string    `json:"architecture"`
			Created time.Time `json:"created"`
			OS      string    `json:"os"`
		}
		if err = json.Unmarshal(configBytes, &config); err != nil {
			return ImageEntry{}, err
		}
		// This _is_ what Docker uses as its Image ID.
		info.ImageID = man.Config.Digest.String()
		info.CreatedAt = config.Created
	case *manifestlist.DeserializedManifestList:
		var list manifestlist.ManifestList = deserialised.ManifestList
		// TODO(michael): is it valid to just pick the first one that matches?
		for _, m := range list.Manifests {
			if m.Platform.OS == "linux" && m.Platform.Architecture == "amd64" {
				manifest, fetchErr = manifests.Get(ctx, m.Digest, digestOpt)
				goto interpret
			}
		}
		entry := ImageEntry{}
		entry.ExcludedReason = "no suitable manifest (linux amd64) in manifestlist"
		return entry, nil
	default:
		t := reflect.TypeOf(manifest)
		return ImageEntry{}, errors.New("unknown manifest type: " + t.String())
	}
	return ImageEntry{Info: info}, nil
}
641897
func (r *Registry) ManifestV2(ctx context.Context, repository, ref string) (schema2.Manifest, error) {
	uri := r.url("/v2/%s/manifests/%s", repository, ref)
	r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref)

	var m schema2.Manifest
	if _, err := r.getJSON(ctx, uri, &m); err != nil {
		r.Logf("registry.manifests response=%v", m)
		return m, err
	}

	if m.Versioned.SchemaVersion != 2 {
		return m, ErrUnexpectedSchemaVersion
	}

	return m, nil
}
669523
func Manifest(f io.ReadSeeker) (*schema.ImageManifest, error) {
	m, err := specaci.ManifestFromImage(f)
	if err != nil {
		return nil, err
	}
	return m, nil
}
299846
func (m *Manifest) Render() string {
	var b bytes.Buffer
	size := len(m.sections) - 1

	for i, section := range m.sections {
		b.WriteString(fmt.Sprintf("[%s]\n", section.key))
		if section.content != "" {
			b.WriteString(section.content)
		}
		for _, x := range section.entries {
			b.WriteString(x)
		}
		if i < size {
			b.WriteString("\n")
		}
	}

	return b.String()
}
1124124
func (d *manifestDeployer) storeManifest(url *charm.URL, manifest set.Strings) error {
	if err := os.MkdirAll(d.DataPath(manifestsDataPath), 0755); err != nil {
		return err
	}
	name := charm.Quote(url.String())
	path := filepath.Join(d.DataPath(manifestsDataPath), name)
	return utils.WriteYaml(path, manifest.SortedValues())
}
954481
func (d *manifestDeployer) loadManifest(urlFilePath string) (*charm.URL, set.Strings, error) {
	url, err := ReadCharmURL(d.CharmPath(urlFilePath))
	if err != nil {
		return nil, nil, err
	}
	name := charm.Quote(url.String())
	path := filepath.Join(d.DataPath(manifestsDataPath), name)
	manifest := []string{}
	err = utils.ReadYaml(path, &manifest)
	if os.IsNotExist(err) {
		logger.Warningf("manifest not found at %q: files from charm %q may be left unremoved", path, url)
		err = nil
	}
	return url, set.NewStrings(manifest...), err
}
677941
func (c *modifiedTracker) add(st ManifestDiff_Stat) ManifestDiff_Stat {
	*c = *c || st != ManifestDiff_EQUAL
	return st
}
94658
func ContentDigestForManifest(manifest distribution.Manifest, algo digest.Algorithm) (digest.Digest, error) {
	switch t := manifest.(type) {
	case *schema1.SignedManifest:
		// schema1 manifest digests are calculated from the payload
		if len(t.Canonical) == 0 {
			return "", fmt.Errorf("the schema1 manifest does not have a canonical representation")
		}
		return algo.FromBytes(t.Canonical), nil
	default:
		_, payload, err := manifest.Payload()
		if err != nil {
			return "", err
		}
		return algo.FromBytes(payload), nil
	}
}
83770
func (m *Manifest) Write() (int64, error) {
	buf, err := json.MarshalIndent(m, "", "  ")
	if err != nil {
		return 0, err
	}
	buf = append(buf, '\n')

	if err := ioutil.WriteFile(m.path, buf, 0666); err != nil {
		return 0, err
	}
	return int64(len(buf)), nil
}
1005755
func (k *Kubectl) Apply(context string, data []byte) error {
	localManifestFile, err := ioutil.TempFile("", "manifest")
	if err != nil {
		return fmt.Errorf("error creating temp file: %v", err)
	}

	defer func() {
		if err := os.Remove(localManifestFile.Name()); err != nil {
			glog.Warningf("error deleting temp file %q: %v", localManifestFile.Name(), err)
		}
	}()

	if err := ioutil.WriteFile(localManifestFile.Name(), data, 0600); err != nil {
		return fmt.Errorf("error writing temp file: %v", err)
	}

	_, _, err = k.execKubectl("apply", "--context", context, "-f", localManifestFile.Name())
	return err
}
765589
func ApplyManifest(ctx Context, manifest *Manifest) error {
	for _, resource := range manifest.Resources {
		if err := ctx.Apply(resource); err != nil {
			return err
		}
	}

	return nil
}
554074
func releaseManifestToUnstructured(manifest string, logger log.Logger) []unstructured.Unstructured {
	manifests := helmutil.SplitManifests(manifest)
	var objs []unstructured.Unstructured
	for _, manifest := range manifests {
		bytes, err := yaml.YAMLToJSON([]byte(manifest))
		if err != nil {
			logger.Log("err", err)
			continue
		}

		var u unstructured.Unstructured
		if err := u.UnmarshalJSON(bytes); err != nil {
			logger.Log("err", err)
			continue
		}

		// Helm charts may include list kinds, we are only interested in
		// the items on those lists.
		if u.IsList() {
			l, err := u.ToList()
			if err != nil {
				logger.Log("err", err)
				continue
			}
			objs = append(objs, l.Items...)
			continue
		}

		objs = append(objs, u)
	}
	return objs
}