func (s *ReleaseTestSuite) TestSetup(c *C) { c.Assert(release.Setup(c.MkDir()), IsNil) c.Check(release.String(), Equals, "16-core") rel := release.Get() c.Check(rel.Flavor, Equals, "core") c.Check(rel.Series, Equals, "16") }
func sysInfo(c *Command, r *http.Request) Response { rel := release.Get() m := map[string]string{ "flavor": rel.Flavor, "series": rel.Series, } if store := snappy.StoreID(); store != "" { m["store"] = store } return SyncResponse(m, nil) }
func v1Get(c *Command, r *http.Request) Response { rel := release.Get() m := map[string]string{ "flavor": rel.Flavor, "release": rel.Series, "default_channel": rel.Channel, "api_compat": "0", } if store := snappy.StoreID(); store != "" { m["store"] = store } return SyncResponse(m) }
func info() error { rel := release.Get() release := fmt.Sprintf("%s/%s", rel.Flavor, rel.Series) frameworks, _ := snappy.ActiveSnapIterByType(snappy.FullName, snap.TypeFramework) apps, _ := snappy.ActiveSnapIterByType(snappy.FullName, snap.TypeApp) // TRANSLATORS: the %s release string fmt.Printf(i18n.G("release: %s\n"), release) // TRANSLATORS: the %s an architecture string fmt.Printf(i18n.G("architecture: %s\n"), arch.UbuntuArchitecture()) // TRANSLATORS: the %s is a comma separated list of framework names fmt.Printf(i18n.G("frameworks: %s\n"), strings.Join(frameworks, ", ")) //TRANSLATORS: the %s represents a list of installed appnames // (e.g. "apps: foo, bar, baz") fmt.Printf(i18n.G("apps: %s\n"), strings.Join(apps, ", ")) return nil }
// small helper that sets the correct http headers for the ubuntu store func (s *SnapUbuntuStoreRepository) applyUbuntuStoreHeaders(req *http.Request, accept string, auther Authenticator) { if auther != nil { auther.Authenticate(req) } if accept == "" { accept = "application/hal+json" } req.Header.Set("Accept", accept) req.Header.Set("X-Ubuntu-Architecture", string(arch.UbuntuArchitecture())) req.Header.Set("X-Ubuntu-Release", release.Get().Series) req.Header.Set("X-Ubuntu-Wire-Protocol", UbuntuCoreWireProtocol) if s.storeID != "" { req.Header.Set("X-Ubuntu-Store", s.storeID) } }
func sysInfo(c *Command, r *http.Request) Response { lock, err := lockfile.Lock(dirs.SnapLockFile, true) if err != nil { return InternalError("unable to acquire lock: %v", err) } defer lock.Unlock() rel := release.Get() m := map[string]string{ "flavor": rel.Flavor, "release": rel.Series, "default_channel": rel.Channel, "api_compat": apiCompatLevel, } if store := snappy.StoreID(); store != "" { m["store"] = store } return SyncResponse(m) }
// small helper that sets the correct http headers for the ubuntu store func setUbuntuStoreHeaders(req *http.Request) { req.Header.Set("Accept", "application/hal+json") // frameworks frameworks, _ := ActiveSnapIterByType(BareName, pkg.TypeFramework) req.Header.Set("X-Ubuntu-Frameworks", strings.Join(addCoreFmk(frameworks), ",")) req.Header.Set("X-Ubuntu-Architecture", string(Architecture())) req.Header.Set("X-Ubuntu-Release", release.String()) req.Header.Set("X-Ubuntu-Device-Channel", release.Get().Channel) if storeID := os.Getenv("UBUNTU_STORE_ID"); storeID != "" { req.Header.Set("X-Ubuntu-Store", storeID) } else if storeID := StoreID(); storeID != "" { req.Header.Set("X-Ubuntu-Store", storeID) } // sso ssoToken, err := ReadStoreToken() if err == nil { req.Header.Set("Authorization", oauth.MakePlaintextSignature(&ssoToken.Token)) } }
func (s *ReleaseTestSuite) TestOverride(c *C) { rel := release.Release{Flavor: "personal", Series: "10.06"} release.Override(rel) c.Check(release.String(), Equals, "10.06-personal") c.Check(release.Get(), DeepEquals, rel) }
func defaultPolicyVendor() string { // FIXME: slightly ugly that we have to give a prefix here return fmt.Sprintf("ubuntu-%s", release.Get().Flavor) }