-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
770 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
package gcp | ||
|
||
import ( | ||
"os" | ||
"path" | ||
// import ( | ||
// "os" | ||
// "path" | ||
|
||
"github.com/cdnjs/tools/util" | ||
// "github.com/cdnjs/tools/util" | ||
|
||
"golang.org/x/net/context" | ||
"google.golang.org/api/option" | ||
// "golang.org/x/net/context" | ||
// "google.golang.org/api/option" | ||
|
||
"cloud.google.com/go/storage" | ||
) | ||
// "cloud.google.com/go/storage" | ||
// ) | ||
|
||
func getCredentialsFile() string { | ||
home, err := os.UserHomeDir() | ||
util.Check(err) | ||
// func getCredentialsFile() string { | ||
// home, err := os.UserHomeDir() | ||
// util.Check(err) | ||
|
||
return path.Join(home, "google_storage_cdnjs_assets.json") | ||
} | ||
// return path.Join(home, "google_storage_cdnjs_assets.json") | ||
// } | ||
|
||
// GetStorageClient gets the GCP Storage Client. | ||
func GetStorageClient(ctx context.Context) (*storage.Client, error) { | ||
return storage.NewClient(ctx, option.WithCredentialsFile(getCredentialsFile())) | ||
} | ||
// // GetStorageClient gets the GCP Storage Client. | ||
// func GetStorageClient(ctx context.Context) (*storage.Client, error) { | ||
// return storage.NewClient(ctx, option.WithCredentialsFile(getCredentialsFile())) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ func getRepo(gitURL string) string { | |
// "[email protected]:chris-pearce/backpack.css.git" | ||
// "git+https://github.com/18F/web-design-standards.git" | ||
// "https://github.com/epeli/underscore.string" | ||
re := regexp.MustCompile(`.*github\.com[:|/](.*?)(?:\.git)?$`) | ||
// re := regexp.MustCompile(`.*github\.com[:|/](.*?)(?:\.git)?$`) | ||
re := regexp.MustCompile(`.*github\.com/.*`) | ||
return re.ReplaceAllString(gitURL, "$1") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package r2 | ||
|
||
import ( | ||
"archive/tar" | ||
"compress/gzip" | ||
"context" | ||
"io" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
func ReadObject(ctx context.Context, bucket string, name string) ([]byte, error) { | ||
panic("TODO") | ||
} | ||
|
||
func Inflate(gzipStream io.Reader, onFile func(string, io.Reader) error) error { | ||
uncompressedStream, err := gzip.NewReader(gzipStream) | ||
if err != nil { | ||
return errors.Wrap(err, "ExtractTarGz: NewReader failed") | ||
} | ||
|
||
tarReader := tar.NewReader(uncompressedStream) | ||
|
||
for { | ||
header, err := tarReader.Next() | ||
|
||
if err == io.EOF { | ||
break | ||
} | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "ExtractTarGz: Next() failed") | ||
} | ||
|
||
switch header.Typeflag { | ||
case tar.TypeDir: | ||
// do nothing | ||
case tar.TypeReg: | ||
if err := onFile(header.Name, tarReader); err != nil { | ||
return errors.Wrap(err, "failed to handle file") | ||
} | ||
default: | ||
return errors.Errorf( | ||
"ExtractTarGz: uknown type: %x in %s", | ||
header.Typeflag, | ||
header.Name) | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.