コード例 #1
0
ファイル: release_test.go プロジェクト: dholbach/snappy
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")
}
コード例 #2
0
ファイル: api.go プロジェクト: dholbach/snappy
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)
}
コード例 #3
0
ファイル: api.go プロジェクト: pombredanne/snappy-1
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)
}
コード例 #4
0
ファイル: cmd_info.go プロジェクト: alecu/snappy
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
}
コード例 #5
0
ファイル: snap_remote_repo.go プロジェクト: dholbach/snappy
// 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)
	}
}
コード例 #6
0
ファイル: api.go プロジェクト: alecu/snappy
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)
}
コード例 #7
0
ファイル: snapp.go プロジェクト: strukturag/snappy
// 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))
	}
}
コード例 #8
0
ファイル: release_test.go プロジェクト: dholbach/snappy
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)
}
コード例 #9
0
ファイル: security.go プロジェクト: General-Beck/snappy
func defaultPolicyVendor() string {
	// FIXME: slightly ugly that we have to give a prefix here
	return fmt.Sprintf("ubuntu-%s", release.Get().Flavor)
}