Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for postgresql #59

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
name: release
on: [push, pull_request]
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
test:
strategy:
Expand Down Expand Up @@ -58,6 +64,13 @@ jobs:
attestations: "github"
command: go test -v -coverprofile=profile.cov -covermode=atomic ./...

- name: E2E Tests
uses: testifysec/witness-run-action@40aa4ef36fc431a37de7c3faebcb66513c03b934
with:
step: "e2e"
attestations: "github"
command: ./test/test.sh

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions archivista.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scalar Time
14 changes: 12 additions & 2 deletions cmd/archivista/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/testifysec/archivista"
"github.com/testifysec/archivista/internal/config"
"github.com/testifysec/archivista/internal/metadatastorage/mysqlstore"
"github.com/testifysec/archivista/internal/metadatastorage/sqlstore"
"github.com/testifysec/archivista/internal/objectstorage/blobstore"
"github.com/testifysec/archivista/internal/objectstorage/filestore"
"github.com/testifysec/archivista/internal/server"
Expand Down Expand Up @@ -86,7 +86,17 @@ func main() {
logrus.Fatalf("error initializing storage clients: %+v", err)
}

mysqlStore, mysqlStoreCh, err := mysqlstore.New(ctx, cfg.SQLStoreConnectionString)
entClient, err := sqlstore.NewEntClient(
cfg.SQLStoreBackend,
cfg.SQLStoreConnectionString,
sqlstore.ClientWithMaxIdleConns(cfg.SQLStoreMaxIdleConnections),
sqlstore.ClientWithMaxOpenConns(cfg.SQLStoreMaxOpenConnections),
sqlstore.ClientWithConnMaxLifetime(cfg.SQLStoreConnectionMaxLifetime))
if err != nil {
logrus.Fatalf("could not create ent client: %+v", err)
}

mysqlStore, mysqlStoreCh, err := sqlstore.New(ctx, entClient)
if err != nil {
logrus.Fatalf("error initializing mysql client: %+v", err)
}
Expand Down
26 changes: 26 additions & 0 deletions compose.psql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 The Archivista Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

services:
psql:
image: postgres:16
restart: always
environment:
POSTGRES_USER: testify
POSTGRES_PASSWORD: example

archivista:
environment:
ARCHIVISTA_SQL_STORE_BACKEND: PSQL
ARCHIVISTA_SQL_STORE_CONNECTION_STRING: postgresql://testify:example@psql?sslmode=disable
5 changes: 3 additions & 2 deletions ent.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package archivista
import (
"context"

"entgo.io/contrib/entgql"
"github.com/testifysec/archivista/ent"
)

Expand All @@ -31,11 +32,11 @@ func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, erro
return r.client.Noders(ctx, ids)
}

func (r *queryResolver) Dsses(ctx context.Context, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) {
func (r *queryResolver) Dsses(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) {
return r.client.Dsse.Query().Paginate(ctx, after, first, before, last, ent.WithDsseFilter(where.Filter))
}

func (r *queryResolver) Subjects(ctx context.Context, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) {
func (r *queryResolver) Subjects(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) {
return r.client.Subject.Query().Paginate(ctx, after, first, before, last, ent.WithSubjectFilter(where.Filter))
}

Expand Down
24 changes: 14 additions & 10 deletions ent/attestation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions ent/attestation/attestation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading