(_ blobserver.Loader, config jsonconfig.Obj)
| 64 | } |
| 65 | |
| 66 | func newFromConfig(_ blobserver.Loader, config jsonconfig.Obj) (storage blobserver.Storage, err error) { |
| 67 | url := config.RequiredString("url") |
| 68 | auth := config.RequiredString("auth") |
| 69 | skipStartupCheck := config.OptionalBool("skipStartupCheck", false) |
| 70 | trustedCert := config.OptionalString("trustedCert", "") |
| 71 | if err := config.Validate(); err != nil { |
| 72 | return nil, err |
| 73 | } |
| 74 | |
| 75 | client, err := client.New( |
| 76 | client.OptionServer(url), |
| 77 | client.OptionTrustedCert(trustedCert), |
| 78 | ) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | if err = client.SetupAuthFromString(auth); err != nil { |
| 83 | return nil, err |
| 84 | } |
| 85 | sto := &remoteStorage{ |
| 86 | client: client, |
| 87 | } |
| 88 | if !skipStartupCheck { |
| 89 | // Do a quick dummy operation to check that our credentials are |
| 90 | // correct. |
| 91 | // TODO(bradfitz,mpl): skip this operation smartly if it turns out this is annoying/slow for whatever reason. |
| 92 | c := make(chan blob.SizedRef, 1) |
| 93 | err = sto.EnumerateBlobs(context.TODO(), c, "", 1) |
| 94 | if err != nil { |
| 95 | return nil, err |
| 96 | } |
| 97 | } |
| 98 | return sto, nil |
| 99 | } |
| 100 | |
| 101 | func (sto *remoteStorage) Close() error { |
| 102 | return sto.client.Close() |
nothing calls this directly
no test coverage detected