Skip to content

Commit

Permalink
Merge pull request #1017 from stacklok/gen-api
Browse files Browse the repository at this point in the history
cleanup: Move generated code to `pkg/api` instead of `pkg/generated`
  • Loading branch information
JAORMX authored Sep 26, 2023
2 parents 24f253c + 30c5cb5 commit 5995902
Show file tree
Hide file tree
Showing 120 changed files with 122 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ gen: ## generate protobuf files
buf generate

clean-gen:
rm -rf $(shell find pkg/generated -iname "*.go") & rm -rf $(shell find pkg/generated -iname "*.swagger.json") & rm -rf pkg/generated/protodocs
rm -rf $(shell find pkg/api -iname "*.go") & rm -rf $(shell find pkg/api -iname "*.swagger.json") & rm -rf pkg/api/protodocs

cli-docs:
@mkdir -p docs/docs/cli
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ API Doc [here](https://mediator-docs.stacklok.dev/api)

The APIs are defined in protobuf [here](https://github.com/stacklok/mediator/blob/main/proto/mediator/v1/mediator.proto).

An OpenAPI / swagger spec is generated to [JSON](https://github.com/stacklok/mediator/blob/main/pkg/generated/openapi/mediator/v1/mediator.swagger.json)
An OpenAPI / swagger spec is generated to [JSON](https://github.com/stacklok/mediator/blob/main/pkg/api/openapi/mediator/v1/mediator.swagger.json)

It can be accessed over gRPC or HTTP using [gprc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/).

Expand Down
8 changes: 4 additions & 4 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
version: v1
plugins:
- name: go
out: pkg/generated/protobuf/go
out: pkg/api/protobuf/go
opt: paths=source_relative
- name: go-grpc
out: pkg/generated/protobuf/go
out: pkg/api/protobuf/go
opt:
- paths=source_relative
- name: grpc-gateway
out: pkg/generated/protobuf/go
out: pkg/api/protobuf/go
opt:
- paths=source_relative
- name: openapiv2
out: pkg/generated/openapi
out: pkg/api/openapi
- plugin: buf.build/community/pseudomuto-doc:v1.5.1
out: docs/docs/protodocs
opt: "markdown,proto.md"
2 changes: 1 addition & 1 deletion cmd/cli/app/artifact/artifact_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/spf13/viper"

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

// repo_listCmd represents the list command to list repos with the
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/artifact/artifact_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

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

var artifact_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"google.golang.org/grpc/status"

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

// auth_loginCmd represents the login command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/spf13/viper"

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

// auth_logoutCmd represents the logout command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spf13/viper"

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

// Auth_refreshCmd represents the auth refresh command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

// Auth_revokeCmd represents the auth revoke command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_revoke_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

// Auth_revokeproviderCmd represents the auth revoke command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/group/group_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

// Group_createCmd is the command for creating a group
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/group/group_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

var group_deleteCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/group/group_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

func printGroup(group protoreflect.ProtoMessage, format string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/group/group_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spf13/viper"

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

var group_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/keys/keys_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spf13/viper"

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

var genKeys_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/org/org_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

// Org_createCmd is the command for creating an organization
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/org/org_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

var org_deleteCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/org/org_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

func printOrganization(org protoreflect.ProtoMessage, format string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/org/org_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spf13/viper"

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

var org_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy/policy_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

// Policy_createCmd represents the policy create command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy/policy_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/spf13/viper"

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

var policy_deleteCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy/policy_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var policy_getCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy/policy_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var policy_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy/table_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"gopkg.in/yaml.v2"

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

func initializeTable(cmd *cobra.Command) *tablewriter.Table {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy_status/policy_status_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/entities"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var policystatus_getCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy_status/policy_status_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var policystatus_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/policy_status/table_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"

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

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/provider/provider_enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

ghclient "github.com/stacklok/mediator/internal/providers/github"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

// Response is the response from the OAuth callback server.
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/repo/repo_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/stacklok/mediator/cmd/cli/app"
github "github.com/stacklok/mediator/internal/providers/github"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/repo/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

github "github.com/stacklok/mediator/internal/providers/github"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

// repo_listCmd represents the list command to list repos with the
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/repo/repo_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

github "github.com/stacklok/mediator/internal/providers/github"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

// repo_registerCmd represents the register command to register a repo with the
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/role/role_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

// Role_createCmd represents the role create command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/role/role_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

var role_deleteCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/role/role_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

var role_getCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/role/role_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"

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

func printRoles(rolesById *pb.GetRolesByGroupResponse, rolesByGroup *pb.GetRolesResponse, format string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/rule_type/rule_type_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/stacklok/mediator/internal/engine"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

// RuleType_createCmd represents the policy create command
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/rule_type/rule_type_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/spf13/viper"

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

var ruleType_deleteCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/rule_type/rule_type_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var ruleType_getCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/rule_type/rule_type_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stacklok/mediator/cmd/cli/app"
"github.com/stacklok/mediator/internal/util"
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)

var ruleType_listCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/rule_type/table_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"

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

func initializeTable(cmd *cobra.Command) *tablewriter.Table {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/user/user_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/spf13/viper"

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

// askForConfirmation asks the user for confirmation and returns true if confirmed, false otherwise.
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/user/user_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/spf13/viper"

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

var user_deleteCmd = &cobra.Command{
Expand Down
Loading

0 comments on commit 5995902

Please sign in to comment.