Skip to content

Commit

Permalink
implement vfs with openstack swift
Browse files Browse the repository at this point in the history
  • Loading branch information
zengchen1024 committed Oct 30, 2017
1 parent b02c3a2 commit e0d03fa
Show file tree
Hide file tree
Showing 2 changed files with 475 additions and 0 deletions.
22 changes: 22 additions & 0 deletions util/pkg/vfs/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (c *VFSContext) BuildVfsPath(p string) (Path, error) {
return c.buildKubernetesPath(p)
}

if strings.HasPrefix(p, "swift://") {
return c.buildOpenstackSwiftPath(p)
}

return nil, fmt.Errorf("unknown / unhandled path type: %q", p)
}

Expand Down Expand Up @@ -309,3 +313,21 @@ func (c *VFSContext) getGCSClient() (*storage.Service, error) {
c.gcsClient = gcsClient
return gcsClient, nil
}

func (c *VFSContext) buildOpenstackSwiftPath(p string) (*SwiftPath, error) {
u, err := url.Parse(p)
if err != nil {
return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p)
}

if u.Scheme != "swift" {
return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p)
}

swiftClient, err := NewSwiftClient()
if err != nil {
return nil, err
}

return NewSwiftPath(swiftClient, strings.TrimSuffix(u.Host, "/"), u.Path)
}
Loading

0 comments on commit e0d03fa

Please sign in to comment.