Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add postgresql support * go mod tidy and remove any sqlite3 references * fix build and push dev images to github package registry * fix github workflow file * only push if tests pass * push latest and build timestamp * use correct paths * fix bundle name * Update README
- Loading branch information
Showing
13 changed files
with
142 additions
and
52 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 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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["parse.go"], | ||
importpath = "github.com/uhthomas/kipp/internal/databaseutil", | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
"//filesystem:go_default_library", | ||
"//filesystem/local:go_default_library", | ||
"//filesystem/s3:go_default_library", | ||
"@com_github_aws_aws_sdk_go//aws:go_default_library", | ||
"@com_github_aws_aws_sdk_go//aws/credentials:go_default_library", | ||
], | ||
) |
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,37 @@ | ||
package filesystemutil | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/uhthomas/kipp/filesystem" | ||
"github.com/uhthomas/kipp/filesystem/local" | ||
"github.com/uhthomas/kipp/filesystem/s3" | ||
) | ||
|
||
// Parse parses s, and will create the appropriate filesystem for the scheme. | ||
func Parse(s string) (filesystem.FileSystem, error) { | ||
u, err := url.Parse(s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
switch u.Scheme { | ||
case "": | ||
return local.New(u.Path) | ||
// s3 follows the form: | ||
// s3://key:token@region/bucket?endpoint=v | ||
case "s3": | ||
c := &aws.Config{Region: &u.Host} | ||
if u.User != nil { | ||
p, _ := u.User.Password() | ||
c.Credentials = credentials.NewStaticCredentials(u.User.Username(), p, "") | ||
} | ||
if e := u.Query().Get("endpoint"); e != "" { | ||
c.Endpoint = &e | ||
} | ||
return s3.New(u.Path, c) | ||
} | ||
return nil, fmt.Errorf("invalid scheme: %s", u.Scheme) | ||
} |
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,37 +1,26 @@ | ||
package filesystemutil | ||
package databaseutil | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/uhthomas/kipp/filesystem" | ||
"github.com/uhthomas/kipp/filesystem/local" | ||
"github.com/uhthomas/kipp/filesystem/s3" | ||
"github.com/uhthomas/kipp/database" | ||
"github.com/uhthomas/kipp/database/badger" | ||
"github.com/uhthomas/kipp/database/sql" | ||
) | ||
|
||
// Parse parses s, and will create the appropriate filesystem for the scheme. | ||
func Parse(s string) (filesystem.FileSystem, error) { | ||
// Parse parses s, and will create the appropriate database for the scheme. | ||
func Parse(ctx context.Context, s string) (database.Database, error) { | ||
u, err := url.Parse(s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
switch u.Scheme { | ||
case "": | ||
return local.New(u.Path) | ||
// s3 follows the form: | ||
// s3://key:token@region/bucket?endpoint=v | ||
case "s3": | ||
c := &aws.Config{Region: &u.Host} | ||
if u.User != nil { | ||
p, _ := u.User.Password() | ||
c.Credentials = credentials.NewStaticCredentials(u.User.Username(), p, "") | ||
} | ||
if e := u.Query().Get("endpoint"); e != "" { | ||
c.Endpoint = &e | ||
} | ||
return s3.New(u.Path, c) | ||
return badger.Open(u.Path) | ||
case "postgresql": | ||
return sql.Open(ctx, "postgresql", u.String()) | ||
} | ||
return nil, fmt.Errorf("invalid scheme: %s", u.Scheme) | ||
} |