From 511fb439ac19601b652f685acff3f737b4e1d18c Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 14 Sep 2016 15:29:11 +0200 Subject: [PATCH 1/2] Identity v3 support for Swift ncw/swift was bumped to latest version --- Gomfile | 2 +- context/context.go | 2 +- swift/public.go | 18 +++++++++++++++++- utils/config.go | 18 +++++++++++------- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Gomfile b/Gomfile index f5b55ed5..7f5e8929 100644 --- a/Gomfile +++ b/Gomfile @@ -11,7 +11,7 @@ gom 'github.com/julienschmidt/httprouter', :commit => '46807412fe50aaceb73bb5706 gom 'github.com/mattn/go-shellwords', :commit => 'c7ca6f94add751566a61cf2199e1de78d4c3eee4' gom 'github.com/mkrautz/goar', :commit => '282caa8bd9daba480b51f1d5a988714913b97aad' gom 'github.com/mxk/go-flowrate/flowrate', :commit => 'cca7078d478f8520f85629ad7c68962d31ed7682' -gom 'github.com/ncw/swift', :commit => '384ef27c70645e285f8bb9d02276bf654d06027e' +gom 'github.com/ncw/swift', :commit => 'b964f2ca856aac39885e258ad25aec08d5f64ee6' gom 'github.com/smira/go-aws-auth', :commit => '0070896e9d7f4f9f2d558532b2d896ce2239992a' gom 'github.com/smira/go-xz', :commit => '0c531f070014e218b21f3cfca801cc992d52726d' gom 'github.com/smira/commander', :commit => 'f408b00e68d5d6e21b9f18bd310978dafc604e47' diff --git a/context/context.go b/context/context.go index b4c76877..0db75aa0 100644 --- a/context/context.go +++ b/context/context.go @@ -337,7 +337,7 @@ func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedSto var err error publishedStorage, err = swift.NewPublishedStorage(params.UserName, params.Password, - params.AuthURL, params.Tenant, params.TenantID, params.Container, params.Prefix) + params.AuthURL, params.Tenant, params.TenantID, params.Domain, params.DomainID, params.TenantDomain, params.TenantDomainID, params.Container, params.Prefix) if err != nil { Fatal(err) } diff --git a/swift/public.go b/swift/public.go index 76d1fd29..a750937a 100644 --- a/swift/public.go +++ b/swift/public.go @@ -29,7 +29,7 @@ var ( // NewPublishedStorage creates new instance of PublishedStorage with specified Swift access // keys, tenant and tenantId -func NewPublishedStorage(username string, password string, authURL string, tenant string, tenantID string, container string, prefix string) (*PublishedStorage, error) { +func NewPublishedStorage(username string, password string, authURL string, tenant string, tenantID string, domain string, domainID string, tenantDomain string, tenantDomainID string, container string, prefix string) (*PublishedStorage, error) { if username == "" { if username = os.Getenv("OS_USERNAME"); username == "" { username = os.Getenv("ST_USER") @@ -51,6 +51,18 @@ func NewPublishedStorage(username string, password string, authURL string, tenan if tenantID == "" { tenantID = os.Getenv("OS_TENANT_ID") } + if domain == "" { + domain = os.Getenv("OS_USER_DOMAIN_NAME") + } + if domainID == "" { + domainID = os.Getenv("OS_USER_DOMAIN_ID") + } + if tenantDomain == "" { + tenantDomain = os.Getenv("OS_PROJECT_DOMAIN") + } + if tenantDomainID == "" { + tenantDomainID = os.Getenv("OS_PROJECT_DOMAIN_ID") + } ct := swift.Connection{ UserName: username, @@ -59,6 +71,10 @@ func NewPublishedStorage(username string, password string, authURL string, tenan UserAgent: "aptly/" + aptly.Version, Tenant: tenant, TenantId: tenantID, + Domain: domain, + DomainId: domainID, + TenantDomain: tenantDomain, + TenantDomainId: tenantDomainID, ConnectTimeout: 60 * time.Second, Timeout: 60 * time.Second, } diff --git a/utils/config.go b/utils/config.go index c05edbc6..a26e8917 100644 --- a/utils/config.go +++ b/utils/config.go @@ -46,13 +46,17 @@ type S3PublishRoot struct { // SwiftPublishRoot describes single OpenStack Swift publishing entry point type SwiftPublishRoot struct { - UserName string `json:"osname"` - Password string `json:"password"` - AuthURL string `json:"authurl"` - Tenant string `json:"tenant"` - TenantID string `json:"tenantid"` - Prefix string `json:"prefix"` - Container string `json:"container"` + UserName string `json:"osname"` + Password string `json:"password"` + AuthURL string `json:"authurl"` + Tenant string `json:"tenant"` + TenantID string `json:"tenantid"` + Domain string `json:"domain"` + DomainID string `json:"domainid"` + TenantDomain string `json:"tenantdomain"` + TenantDomainID string `json:"tenantdomainid"` + Prefix string `json:"prefix"` + Container string `json:"container"` } // Config is configuration for aptly, shared by all modules From 8e626208805117d11bb7652623e1ad142c87d618 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 14 Sep 2016 20:53:01 +0200 Subject: [PATCH 2/2] Fixing tests after adding v3 swift auth --- swift/public_test.go | 6 +++--- utils/config_test.go | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/swift/public_test.go b/swift/public_test.go index 1f1b83b4..6e9d8161 100644 --- a/swift/public_test.go +++ b/swift/public_test.go @@ -34,10 +34,10 @@ func (s *PublishedStorageSuite) SetUpTest(c *C) { c.Assert(err, IsNil) c.Assert(s.srv, NotNil) - s.storage, err = NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "test", "") + s.storage, err = NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "", "", "", "", "test", "") c.Assert(err, IsNil) - s.prefixedStorage, err = NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "test", "lala") + s.prefixedStorage, err = NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "", "", "", "", "test", "lala") c.Assert(err, IsNil) s.storage.conn.ContainerCreate("test", nil) @@ -48,7 +48,7 @@ func (s *PublishedStorageSuite) TearDownTest(c *C) { } func (s *PublishedStorageSuite) TestNewPublishedStorage(c *C) { - stor, err := NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "", "") + stor, err := NewPublishedStorage("swifttest", "swifttest", s.AuthURL, "", "", "", "", "", "", "", "") c.Check(stor, NotNil) c.Check(err, IsNil) } diff --git a/utils/config_test.go b/utils/config_test.go index 229eba7e..6b8a4506 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -88,6 +88,10 @@ func (s *ConfigSuite) TestSaveConfig(c *C) { " \"authurl\": \"\",\n"+ " \"tenant\": \"\",\n"+ " \"tenantid\": \"\",\n"+ + " \"domain\": \"\",\n"+ + " \"domainid\": \"\",\n"+ + " \"tenantdomain\": \"\",\n"+ + " \"tenantdomainid\": \"\",\n"+ " \"prefix\": \"\",\n"+ " \"container\": \"repo\"\n"+ " }\n"+