Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
92710a33
Commit
92710a33
authored
Feb 11, 2016
by
vaikas-google
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #251 from vaikas-google/master
Allow unauthenticated requests to GCS for public buckets
parents
476e71f5
740a0b4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
registryprovider.go
registry/registryprovider.go
+6
-5
No files found.
registry/registryprovider.go
View file @
92710a33
...
@@ -247,10 +247,6 @@ func NewGCSRegistryProvider(cp common.CredentialProvider) GCSRegistryProvider {
...
@@ -247,10 +247,6 @@ func NewGCSRegistryProvider(cp common.CredentialProvider) GCSRegistryProvider {
// GetGCSRegistry returns a new Google Cloud Storage . If there's a credential that is specified, will try
// GetGCSRegistry returns a new Google Cloud Storage . If there's a credential that is specified, will try
// to fetch it and use it, and if there's no credential found, will fall back to unauthenticated client.
// to fetch it and use it, and if there's no credential found, will fall back to unauthenticated client.
func
(
gcsrp
gcsRegistryProvider
)
GetGCSRegistry
(
cr
common
.
Registry
)
(
ObjectStorageRegistry
,
error
)
{
func
(
gcsrp
gcsRegistryProvider
)
GetGCSRegistry
(
cr
common
.
Registry
)
(
ObjectStorageRegistry
,
error
)
{
// If there's a credential that we need to use, fetch it and create a client for it.
if
cr
.
CredentialName
==
""
{
return
nil
,
fmt
.
Errorf
(
"No CredentialName specified for %s"
,
cr
.
Name
)
}
client
,
err
:=
gcsrp
.
createGCSClient
(
cr
.
CredentialName
)
client
,
err
:=
gcsrp
.
createGCSClient
(
cr
.
CredentialName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -263,10 +259,15 @@ func (gcsrp gcsRegistryProvider) GetGCSRegistry(cr common.Registry) (ObjectStora
...
@@ -263,10 +259,15 @@ func (gcsrp gcsRegistryProvider) GetGCSRegistry(cr common.Registry) (ObjectStora
}
}
func
(
gcsrp
gcsRegistryProvider
)
createGCSClient
(
credentialName
string
)
(
*
http
.
Client
,
error
)
{
func
(
gcsrp
gcsRegistryProvider
)
createGCSClient
(
credentialName
string
)
(
*
http
.
Client
,
error
)
{
if
credentialName
==
""
{
return
http
.
DefaultClient
,
nil
}
c
,
err
:=
gcsrp
.
cp
.
GetCredential
(
credentialName
)
c
,
err
:=
gcsrp
.
cp
.
GetCredential
(
credentialName
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"Failed to fetch credential %s: %v"
,
credentialName
,
err
)
log
.
Printf
(
"Failed to fetch credential %s: %v"
,
credentialName
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed to fetch Credential %s: %s"
,
credentialName
,
err
)
log
.
Print
(
"Trying to use unauthenticated client"
)
return
http
.
DefaultClient
,
nil
}
}
config
,
err
:=
google
.
JWTConfigFromJSON
([]
byte
(
c
.
ServiceAccount
),
storage
.
DevstorageReadOnlyScope
)
config
,
err
:=
google
.
JWTConfigFromJSON
([]
byte
(
c
.
ServiceAccount
),
storage
.
DevstorageReadOnlyScope
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment