Skip to content

Commit

Permalink
Merge pull request #931 from stacklok/db-internal
Browse files Browse the repository at this point in the history
Move database golang code to `internal` package
  • Loading branch information
JAORMX authored Sep 11, 2023
2 parents eb75023 + 6c63fd5 commit fcb94e3
Show file tree
Hide file tree
Showing 69 changed files with 47 additions and 48 deletions.
8 changes: 4 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/docs/docs/db/schema.md linguist-generated=true
/docs/docs/protodocs/proto.md linguist-generated=true
/pkg/generated/** linguist-generated=true
/pkg/db/db.go linguist-generated=true
/pkg/db/models.go linguist-generated=true
/pkg/db/querier.go linguist-generated=true
/pkg/db/*.sql.go linguist-generated=true
/internal/db/db.go linguist-generated=true
/internal/db/models.go linguist-generated=true
/internal/db/querier.go linguist-generated=true
/internal/db/*.sql.go linguist-generated=true
2 changes: 1 addition & 1 deletion .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- name: Check license headers
run: |
set -e
addlicense -l apache -c 'Stacklok, Inc' -v -ignore "pkg/generated/*" -ignore "**/database/query/**" -ignore "pkg/db/*" -ignore "docs/docs/**" -ignore "docs/src/**" -ignore "docs/static/**" -ignore "pkg/controlplane/policy_types/**" -ignore "docs/build/**" -ignore "examples/**" *
addlicense -l apache -c 'Stacklok, Inc' -v -ignore "pkg/generated/*" -ignore "**/database/query/**" -ignore "internal/db/*" -ignore "docs/docs/**" -ignore "docs/src/**" -ignore "docs/static/**" -ignore "pkg/controlplane/policy_types/**" -ignore "docs/build/**" -ignore "examples/**" *
git diff --exit-code
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ dbschema: ## generate database schema with schema spy, monitor file until doc is
cd database/schema && $(COMPOSE) down -v && rm -rf output

mock:
mockgen -package mockdb -destination database/mock/store.go github.com/stacklok/mediator/pkg/db Store
mockgen -package mockdb -destination database/mock/store.go github.com/stacklok/mediator/internal/db Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Mediator uses [mockgen](https://github.com/golang/mock) to generate mocks.
To generate the mocks, run:

```bash
mockgen -package mockdb -destination database/mock/store.go github.com/stacklok/mediator/pkg/db Store
mockgen -package mockdb -destination database/mock/store.go github.com/stacklok/mediator/internal/db Store
```

# Configuration
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
"golang.org/x/sync/errgroup"

"github.com/stacklok/mediator/internal/config"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/events"
"github.com/stacklok/mediator/internal/logger"
"github.com/stacklok/mediator/internal/reconcilers"
"github.com/stacklok/mediator/pkg/controlplane"
"github.com/stacklok/mediator/pkg/db"
)

var serveCmd = &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions database/mock/store.go

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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/engine/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"fmt"

"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/internal/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/engine/eval_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"fmt"
"log"

"github.com/stacklok/mediator/internal/db"
evalerrors "github.com/stacklok/mediator/internal/engine/errors"
"github.com/stacklok/mediator/pkg/db"
)

// createOrUpdateEvalStatusParams is a helper struct to pass parameters to createOrUpdateEvalStatus
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/ThreeDotsLabs/watermill/message"
"github.com/rs/zerolog"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/events"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
"github.com/stacklok/mediator/pkg/providers"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"google.golang.org/protobuf/types/known/structpb"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/pkg/entities"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/pipeline_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"os"
"path/filepath"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/pkg/entities"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/rule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/structpb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine/eval"
"github.com/stacklok/mediator/internal/engine/ingester"
engif "github.com/stacklok/mediator/internal/engine/interfaces"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/pkg/entities"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
Expand Down
2 changes: 1 addition & 1 deletion internal/gh/queries/sync_repo_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"errors"
"fmt"

"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/internal/db"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/reconcilers/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/pkg/container"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
"github.com/stacklok/mediator/pkg/providers"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
Expand Down
2 changes: 1 addition & 1 deletion internal/reconcilers/reconcilers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package reconcilers

import (
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/events"
"github.com/stacklok/mediator/pkg/db"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/reconcilers/run_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/jwauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/golang/mock/gomock"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/db"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/jwtauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/internal/db"
)

// RoleInfo contains the role information for a user
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/config"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/auth"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/util/sets"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
github "github.com/stacklok/mediator/pkg/providers/github"
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/controlplane/handlers_githubwebhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/util"
// TODO(jaosorior): This should be moved to the provider package
"github.com/stacklok/mediator/pkg/container"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
"github.com/stacklok/mediator/pkg/providers"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_githubwebhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import (
"golang.org/x/oauth2"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/db"
)

// MockClient is a mock implementation of the GitHub client.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/internal/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/controlplane/handlers_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
// "database/sql"
"encoding/base64"

// "github.com/stacklok/mediator/pkg/db"
// "github.com/stacklok/mediator/internal/db"
"github.com/google/uuid"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/stacklok/mediator/internal/db"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/config"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"google.golang.org/grpc/codes"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/reconcilers"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/pkg/entities"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
ghclient "github.com/stacklok/mediator/pkg/providers/github"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/gh/queries"
"github.com/stacklok/mediator/internal/reconcilers"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
github "github.com/stacklok/mediator/pkg/providers/github"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/pkg/db"
"github.com/stacklok/mediator/internal/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

mockdb "github.com/stacklok/mediator/database/mock"
"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/pkg/auth"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controlplane/handlers_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stacklok/mediator/internal/db"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/pkg/auth"
mcrypto "github.com/stacklok/mediator/pkg/crypto"
"github.com/stacklok/mediator/pkg/db"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
)

Expand Down
Loading

0 comments on commit fcb94e3

Please sign in to comment.