Skip to content

Commit

Permalink
Remove pgsql implementation (#1)
Browse files Browse the repository at this point in the history
All the pgsql specific code will be moved out to tetradio repo, as mentioned
upstream in grafeas#341
When we are ready, we can submit this and pgsql code to be merged upstream.
  • Loading branch information
maditya authored and GitHub Enterprise committed Jan 16, 2021
1 parent bd4801d commit 83e6c75
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 1,368 deletions.
2 changes: 0 additions & 2 deletions go.mod
Expand Up @@ -6,13 +6,11 @@ require (
github.com/antlr/antlr4 v0.0.0-20190819145818-b43a4c3a8015
github.com/boltdb/bolt v1.3.1
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292
github.com/fernet/fernet-go v0.0.0-20191111064656-eff2850e6001
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.2
github.com/google/logger v1.0.1
github.com/google/uuid v1.1.2
github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1
github.com/lib/pq v1.2.0
github.com/rs/cors v1.7.0
github.com/spf13/viper v1.4.0
golang.org/x/net v0.0.0-20200822124328-c89045814202
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Expand Up @@ -68,10 +68,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e h1:P10tZmVD2XclAaT9l7OduMH1OLFzTa1wUuUqHZnEdI0=
github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c=
github.com/fernet/fernet-go v0.0.0-20191111064656-eff2850e6001 h1:/UMxx5lGDg30aioUL9e7xJnbJfJeX7vhcm57fa5udaI=
github.com/fernet/fernet-go v0.0.0-20191111064656-eff2850e6001/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
Expand Down Expand Up @@ -169,8 +165,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down
13 changes: 0 additions & 13 deletions go/config/config.go
Expand Up @@ -53,19 +53,6 @@ type EmbeddedStoreConfig struct {
Path string `mapstructure:"path"` // Path is the folder path to storage files
}

// TODO(#341) Move this to its own project
// PgSQLConfig is the configuration for PostgreSQL store.
type PgSQLConfig struct {
Host string `mapstructure:"host"`
DbName string `mapstructure:"dbname"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
// Valid sslmodes: disable, allow, prefer, require, verify-ca, verify-full.
// See https://www.postgresql.org/docs/current/static/libpq-connect.html for details
SSLMode string `mapstructure:"sslmode"`
PaginationKey string `mapstructure:"paginationkey"`
}

// defaultConfig is a configuration that can be used as a fallback value.
var defaultConfig = []byte(`
grafeas:
Expand Down
85 changes: 0 additions & 85 deletions go/config/config_test.go
Expand Up @@ -199,91 +199,6 @@ func TestLoadConfig_ReturnsConfig_UserSuppliedValues_Embedded(t *testing.T) {
}
}

// TODO(#341) move these 2 supporting functions and the test case to the new project
func userPostgresConfig(t *testing.T) *PgSQLConfig {
t.Helper()
return &PgSQLConfig{
Host: "127.0.0.1:5432",
DbName: "postgres",
User: "postgres",
Password: "password",
SSLMode: "require",
PaginationKey: "",
}
}

func userConfig_postgres_yaml(t *testing.T) []byte {
t.Helper()
return []byte(`
grafeas:
api:
address: "0.0.0.0:8081"
certfile: abc
keyfile: def
cafile: ghi
cors_allowed_origins:
- "http://example.com"
- "https://somewhere.else.com"
storage_type: "postgres"
postgres:
host: "127.0.0.1:5432"
dbname: "postgres"
user: "postgres"
password: "password"
sslmode: "require"
paginationkey:
`)
}

func TestLoadConfig_ReturnsConfig_UserSuppliedValues_Postgres(t *testing.T) {
file, err := ioutil.TempFile("", "config.*.yaml")
if err != nil {
t.Fatalf("%s", err)
}
defer func() {
_ = os.Remove(file.Name())
}()

if _, err = file.Write(userConfig_postgres_yaml(t)); err != nil {
t.Fatalf("%s", err)
}

if err = file.Close(); err != nil {
t.Fatalf("%s", err)
}

cfg, err := LoadConfig(file.Name())
if err != nil {
t.Error(err)
}

if cfg.API == nil {
t.Errorf("config API is nil")
}

if !cmp.Equal(cfg.API, userServerConfig(t)) {
t.Errorf("Values in cfg.API are not correct\n%s", cmp.Diff(cfg.API, userServerConfig(t)))
}

if cfg.StorageType != "postgres" {
t.Errorf("Storage type %s is not postgres", cfg.StorageType)
}

if cfg.StorageConfig == nil {
t.Errorf("storage configuration is nil")
}

var storeConfig PgSQLConfig

if err = ConvertGenericConfigToSpecificType(*cfg.StorageConfig, &storeConfig); err != nil {
t.Fatalf("%s", err)
}

if !cmp.Equal(storeConfig, *userPostgresConfig(t)) {
t.Errorf("Values in storage configuration are not correct\n%s", cmp.Diff(storeConfig, *userPostgresConfig(t)))
}
}

// The project defines an example of configuration in go/v1beta1/config.yaml, so this test
// confirms that this file remains parseable.
// It does not check the config file values to avoid the test becoming brittle.
Expand Down
187 changes: 0 additions & 187 deletions go/v1beta1/storage/pgsqlfilter.go

This file was deleted.

0 comments on commit 83e6c75

Please sign in to comment.