本文整理匯總了Golang中github.com/juju/juju/environs/storage.StorageReader.List方法的典型用法代碼示例。如果您正苦於以下問題:Golang StorageReader.List方法的具體用法?Golang StorageReader.List怎麽用?Golang StorageReader.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/environs/storage.StorageReader
的用法示例。
在下文中一共展示了StorageReader.List方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: migrateCustomImageMetadata
// migrateCustomImageMetadata copies uploaded image metadata from provider
// storage to environment storage, preserving paths.
func migrateCustomImageMetadata(st *state.State, agentConfig agent.Config) error {
logger.Debugf("migrating custom image metadata to environment storage")
estor := newStateStorage(st.EnvironUUID(), st.MongoSession())
// Local and manual provider host storage on the state server's
// filesystem, and serve via HTTP storage. The storage worker
// doesn't run yet, so we just open the files directly.
var pstor storage.StorageReader
providerType := agentConfig.Value(agent.ProviderType)
if providerType == provider.Local || provider.IsManual(providerType) {
storageDir := agentConfig.Value(agent.StorageDir)
var err error
pstor, err = filestorage.NewFileStorageReader(storageDir)
if err != nil {
return errors.Annotate(err, "cannot get local filesystem storage reader")
}
} else {
var err error
pstor, err = environs.LegacyStorage(st)
if errors.IsNotSupported(err) {
return nil
} else if err != nil {
return errors.Annotate(err, "cannot get provider storage")
}
}
paths, err := pstor.List(storage.BaseImagesPath)
if err != nil {
return err
}
for _, path := range paths {
logger.Infof("migrating image metadata at path %q", path)
data, err := readImageMetadata(pstor, path)
if err != nil {
return errors.Annotate(err, "failed to read image metadata")
}
err = estor.Put(path, bytes.NewReader(data), int64(len(data)))
if err != nil {
return errors.Annotate(err, "failed to write image metadata")
}
}
return nil
}