code: func NewAppcFromApp(app *discovery.App) Distribution {
  	rawuri := NewCIMDString(TypeAppc, distAppcVersion, url.QueryEscape(app.Name.String()))
  
  	var version string
  	labels := types.Labels{}
  	for n, v := range app.Labels {
  		if n == "version" {
  			version = v
  		}
  
  		labels = append(labels, types.Label{Name: n, Value: v})
  	}
  
  	if len(labels) > 0 {
  		queries := make([]string, len(labels))
  		rawuri += "?"
  		for i, l := range labels {
  			queries[i] = fmt.Sprintf("%s=%s", l.Name, url.QueryEscape(l.Value))
  		}
  		rawuri += strings.Join(queries, "&")
  	}
  
  	u, err := url.Parse(rawuri)
  	if err != nil {
  		panic(fmt.Errorf("cannot parse URI %q: %v", rawuri, err))
  	}
  
  	// save the URI as sorted to make it ready for comparison
  	purell.NormalizeURL(u, purell.FlagSortQuery)
  
  	str := app.Name.String()
  	if version != "" {
  		str += fmt.Sprintf(":%s", version)
  	}
  
  	labelsort.By(labelsort.RankedName).Sort(labels)
  	for _, l := range labels {
  		if l.Name != "version" {
  			str += fmt.Sprintf(",%s=%s", l.Name, l.Value)
  		}
  	}
  
  	return &Appc{
  		cimd: u,
  		app:  app.Copy(),
  		str:  str,
  	}
  }
docs: // NewAppcFromApp returns an Appc distribution from an appc App discovery string