当前位置: 首页>>代码示例>>Golang>>正文


Golang simplestreams.NewURLSignedDataSource函数代码示例

本文整理汇总了Golang中github.com/juju/juju/environs/simplestreams.NewURLSignedDataSource函数的典型用法代码示例。如果您正苦于以下问题:Golang NewURLSignedDataSource函数的具体用法?Golang NewURLSignedDataSource怎么用?Golang NewURLSignedDataSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewURLSignedDataSource函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: OfficialDataSources

// OfficialDataSources returns the simplestreams datasources where official
// image metadata can be found.
func OfficialDataSources(stream string) ([]simplestreams.DataSource, error) {
	var result []simplestreams.DataSource

	// New images metadata for centos and windows and existing clouds.
	defaultJujuURL, err := ImageMetadataURL(DefaultJujuBaseURL, stream)
	if err != nil {
		return nil, err
	}
	if defaultJujuURL != "" {
		publicKey, err := simplestreams.UserPublicSigningKey()
		if err != nil {
			return nil, err
		}
		if publicKey == "" {
			publicKey = keys.JujuPublicKey
		}
		result = append(
			result,
			simplestreams.NewURLSignedDataSource("default cloud images", defaultJujuURL, publicKey, utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, true))
	}

	// Fallback to image metadata for existing Ubuntu images.
	defaultUbuntuURL, err := ImageMetadataURL(DefaultUbuntuBaseURL, stream)
	if err != nil {
		return nil, err
	}
	if defaultUbuntuURL != "" {
		result = append(
			result,
			simplestreams.NewURLSignedDataSource("default ubuntu cloud images", defaultUbuntuURL, SimplestreamsImagesPublicKey, utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, true))
	}

	return result, nil
}
开发者ID:bac,项目名称:juju,代码行数:36,代码来源:simplestreams.go

示例2: GetMetadataSources

// GetMetadataSources returns the sources to use when looking for
// simplestreams tools metadata for the given stream.
func GetMetadataSources(env environs.Environ) ([]simplestreams.DataSource, error) {
	config := env.Config()

	// Add configured and environment-specific datasources.
	var sources []simplestreams.DataSource
	if userURL, ok := config.AgentMetadataURL(); ok {
		verify := utils.VerifySSLHostnames
		if !config.SSLHostnameVerification() {
			verify = utils.NoVerifySSLHostnames
		}
		sources = append(sources, simplestreams.NewURLSignedDataSource(conf.AgentMetadataURLKey, userURL, juju.JujuPublicKey, verify, simplestreams.SPECIFIC_CLOUD_DATA, false))
	}

	envDataSources, err := environmentDataSources(env)
	if err != nil {
		return nil, err
	}
	sources = append(sources, envDataSources...)

	// Add the default, public datasource.
	defaultURL, err := ToolsURL(DefaultBaseURL)
	if err != nil {
		return nil, err
	}
	if defaultURL != "" {
		sources = append(sources,
			simplestreams.NewURLSignedDataSource("default simplestreams", defaultURL, juju.JujuPublicKey, utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, true))
	}
	return sources, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:32,代码来源:urls.go

示例3: saveCustomImageMetadata

// saveCustomImageMetadata reads the custom image metadata from disk,
// and saves it in controller.
func (c *BootstrapCommand) saveCustomImageMetadata(st *state.State, env environs.Environ) error {
	logger.Debugf("saving custom image metadata from %q", c.ImageMetadataDir)
	baseURL := fmt.Sprintf("file://%s", filepath.ToSlash(c.ImageMetadataDir))
	publicKey, _ := simplestreams.UserPublicSigningKey()
	datasource := simplestreams.NewURLSignedDataSource("custom", baseURL, publicKey, utils.NoVerifySSLHostnames, simplestreams.CUSTOM_CLOUD_DATA, false)
	return storeImageMetadataFromFiles(st, env, datasource)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:bootstrap.go

示例4: ImageMetadataSources

// ImageMetadataSources returns the sources to use when looking for
// simplestreams image id metadata for the given stream.
func ImageMetadataSources(env Environ) ([]simplestreams.DataSource, error) {
	config := env.Config()

	// Add configured and environment-specific datasources.
	var sources []simplestreams.DataSource
	if userURL, ok := config.ImageMetadataURL(); ok {
		verify := utils.VerifySSLHostnames
		if !config.SSLHostnameVerification() {
			verify = utils.NoVerifySSLHostnames
		}
		publicKey, _ := simplestreams.UserPublicSigningKey()
		sources = append(sources, simplestreams.NewURLSignedDataSource("image-metadata-url", userURL, publicKey, verify, simplestreams.SPECIFIC_CLOUD_DATA, false))
	}

	envDataSources, err := environmentDataSources(env)
	if err != nil {
		return nil, err
	}
	sources = append(sources, envDataSources...)

	// Add the official image metadata datasources.
	officialDataSources, err := imagemetadata.OfficialDataSources(config.ImageStream())
	if err != nil {
		return nil, err
	}
	for _, source := range officialDataSources {
		sources = append(sources, source)
	}
	for _, ds := range sources {
		logger.Debugf("obtained image datasource %q", ds.Description())
	}
	return sources, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:35,代码来源:imagemetadata.go

示例5: NewDataSource

// DataSource creates and returns a new simplestreams signed data source for
// fetching Juju GUI archives, at the given URL.
func NewDataSource(baseURL string) simplestreams.DataSource {
	requireSigned := true
	return simplestreams.NewURLSignedDataSource(
		sourceDescription,
		baseURL,
		juju.JujuPublicKey,
		utils.VerifySSLHostnames,
		simplestreams.DEFAULT_CLOUD_DATA,
		requireSigned)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:12,代码来源:simplestreams.go

示例6: selectSourceDatasource

// selectSourceDatasource returns a storage reader based on the source setting.
func selectSourceDatasource(syncContext *SyncContext) (simplestreams.DataSource, error) {
	source := syncContext.Source
	if source == "" {
		source = envtools.DefaultBaseURL
	}
	sourceURL, err := envtools.ToolsURL(source)
	if err != nil {
		return nil, err
	}
	logger.Infof("using sync tools source: %v", sourceURL)
	return simplestreams.NewURLSignedDataSource("sync tools source", sourceURL, juju.JujuPublicKey, utils.VerifySSLHostnames, simplestreams.CUSTOM_CLOUD_DATA, false), nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:13,代码来源:sync.go

示例7: toolsDataSources

func toolsDataSources(urls ...string) []simplestreams.DataSource {
	dataSources := make([]simplestreams.DataSource, len(urls))
	for i, url := range urls {
		dataSources[i] = simplestreams.NewURLSignedDataSource(
			"local source",
			url,
			juju.JujuPublicKey,
			utils.VerifySSLHostnames,
			simplestreams.CUSTOM_CLOUD_DATA,
			false)
	}
	return dataSources
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:13,代码来源:toolsmetadata.go

示例8: TestSignedImageMetadata

func (s *signedSuite) TestSignedImageMetadata(c *gc.C) {
	signedSource := simplestreams.NewURLSignedDataSource("test", "test://host/signed", sstesting.SignedMetadataPublicKey, utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, true)
	imageConstraint := imagemetadata.NewImageConstraint(simplestreams.LookupParams{
		CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"},
		Series:    []string{"precise"},
		Arches:    []string{"amd64"},
	})
	images, resolveInfo, err := imagemetadata.Fetch([]simplestreams.DataSource{signedSource}, imageConstraint)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(len(images), gc.Equals, 1)
	c.Assert(images[0].Id, gc.Equals, "ami-123456")
	c.Check(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{
		Source:    "test",
		Signed:    true,
		IndexURL:  "test://host/signed/streams/v1/index.sjson",
		MirrorURL: "",
	})
}
开发者ID:bac,项目名称:juju,代码行数:18,代码来源:simplestreams_test.go

示例9: TestSignedToolsMetadata

func (s *signedSuite) TestSignedToolsMetadata(c *gc.C) {
	signedSource := simplestreams.NewURLSignedDataSource(
		"test", "signedtest://host/signed", sstesting.SignedMetadataPublicKey,
		utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, true)
	toolsConstraint := tools.NewVersionedToolsConstraint(version.MustParse("1.13.0"), simplestreams.LookupParams{
		CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"},
		Series:    []string{"precise"},
		Arches:    []string{"amd64"},
		Stream:    "released",
	})
	toolsMetadata, resolveInfo, err := tools.Fetch(
		[]simplestreams.DataSource{signedSource}, toolsConstraint)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(len(toolsMetadata), gc.Equals, 1)
	c.Assert(toolsMetadata[0].Path, gc.Equals, "tools/releases/20130806/juju-1.13.1-precise-amd64.tgz")
	c.Assert(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{
		Source:    "test",
		Signed:    true,
		IndexURL:  "signedtest://host/signed/streams/v1/index.sjson",
		MirrorURL: "",
	})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:22,代码来源:simplestreams_test.go

示例10:

	}

	if c.series != "" {
		params.Series = c.series
	}
	if c.region != "" {
		params.Region = c.region
	}
	if c.endpoint != "" {
		params.Endpoint = c.endpoint
	}
	if c.metadataDir != "" {
		dir := filepath.Join(c.metadataDir, "images")
		if _, err := os.Stat(dir); err != nil {
			return nil, err
		}
		params.Sources = imagesDataSources(dir)
	}
	return params, nil
}

var imagesDataSources = func(urls ...string) []simplestreams.DataSource {
	dataSources := make([]simplestreams.DataSource, len(urls))
	publicKey, _ := simplestreams.UserPublicSigningKey()
	for i, url := range urls {
		dataSources[i] = simplestreams.NewURLSignedDataSource(
			"local metadata directory", "file://"+url, publicKey, utils.VerifySSLHostnames, simplestreams.CUSTOM_CLOUD_DATA, false)
	}
	return dataSources
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:30,代码来源:validateimagemetadata.go


注:本文中的github.com/juju/juju/environs/simplestreams.NewURLSignedDataSource函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。