Skip to content

Commit 4ce31e1

Browse files
committed
add support for using Ceph's Swift-API
1 parent fbac368 commit 4ce31e1

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ The first paragraph contains the authentication parameters for
116116
OpenStack's Identity v3 API. Optionally a `region_name` can be specified, but this is only
117117
required if there are multiple regions to choose from. You can also specify the `tls_client_certificate_file` and `tls_client_key_file` for creating a TLS client.
118118

119+
Additionally, you can specify a `service_type` to select which object storage service to use from the service catalog. This defaults to `object-store` for native Swift, but can be set to `object-store-ceph` when using Ceph's Swift-compatible API.
120+
119121
You can use the `fromEnv` special syntax for the `to.container`, `to.object_prefix`, and
120122
the Swift fields (options under the `swift` key).
121123
See [specifying sensitive info as environment variables](#specifying-sensitive-info-as-environment-variables) for more details.

pkg/objects/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func (cfg JobConfiguration) Compile(ctx context.Context, name string, swift Swif
226226
cfg.Target.ApplicationCredentialName = swift.ApplicationCredentialName
227227
cfg.Target.ApplicationCredentialSecret = swift.ApplicationCredentialSecret
228228
cfg.Target.RegionName = swift.RegionName
229+
cfg.Target.ServiceType = swift.ServiceType
229230
errors = append(errors, cfg.Target.Validate(name+".to")...)
230231
}
231232

pkg/objects/swift.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type SwiftLocation struct {
3737
TLSClientCertificateFile secrets.FromEnv `yaml:"tls_client_certificate_file"`
3838
TLSClientKeyFile secrets.FromEnv `yaml:"tls_client_key_file"`
3939
RegionName secrets.FromEnv `yaml:"region_name"`
40+
ServiceType secrets.FromEnv `yaml:"service_type"`
4041
ContainerName secrets.FromEnv `yaml:"container"`
4142
ObjectNamePrefix secrets.FromEnv `yaml:"object_prefix"`
4243
// configuration for Validate()
@@ -61,6 +62,7 @@ func (s SwiftLocation) cacheKey(name string) string {
6162
string(s.ApplicationCredentialName),
6263
string(s.ApplicationCredentialSecret),
6364
string(s.RegionName),
65+
string(s.ServiceType),
6466
}
6567
if logg.ShowDebug {
6668
v = append(v, name)
@@ -208,7 +210,12 @@ func (s *SwiftLocation) Connect(ctx context.Context, name string) error {
208210
)
209211
}
210212

213+
serviceType := string(s.ServiceType)
214+
if serviceType == "" {
215+
serviceType = "object-store"
216+
}
211217
serviceClient, err := openstack.NewObjectStorageV1(provider, gophercloud.EndpointOpts{
218+
Type: serviceType,
212219
Region: string(s.RegionName),
213220
})
214221
if err != nil {

0 commit comments

Comments
 (0)