Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into auth-error
Browse files Browse the repository at this point in the history
  • Loading branch information
evankanderson committed Sep 26, 2023
2 parents 31658a0 + ccd7862 commit b68f5ba
Show file tree
Hide file tree
Showing 171 changed files with 6,376 additions and 4,450 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
/docs/docs/cli/*.md linguist-generated=true
/docs/docs/db/schema.md linguist-generated=true
/docs/docs/protodocs/proto.md linguist-generated=true
/pkg/generated/** linguist-generated=true
/pkg/api/openapi/** linguist-generated=true
/pkg/api/protobuf/go/mediator/v1/*.pb.go linguist-generated=true
/pkg/api/protobuf/go/mediator/v1/*.gw.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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.20.3@sha256:403f48633fb5ebd49f9a2b6ad6719f912df23dae44974a0c9445be331e72ff5e AS builder
FROM golang:1.21.1@sha256:c416ceeec1cdf037b80baef1ccb402c230ab83a9134b34c0902c542eb4539c82 AS builder
ENV APP_ROOT=/opt/app-root
ENV GOPATH=$APP_ROOT

Expand Down
5 changes: 3 additions & 2 deletions 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 All @@ -58,6 +58,7 @@ build: ## build golang binary
# @go build -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -o bin/$(projectname)
CGO_ENABLED=0 go build -trimpath -o ./bin/medic ./cmd/cli
CGO_ENABLED=0 go build -trimpath -o ./bin/$(projectname)-server ./cmd/server
CGO_ENABLED=0 go build -trimpath -o ./bin/medev ./cmd/dev

run-cli: ## run the CLI, needs additional arguments
@go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" ./cmd/cli
Expand Down Expand Up @@ -144,4 +145,4 @@ dbschema: ## generate database schema with schema spy, monitor file until doc is

mock:
mockgen -package mockdb -destination database/mock/store.go github.com/stacklok/mediator/internal/db Store
mockgen -package mockgh -destination internal/providers/github/mock/github.go -source internal/providers/github/github.go RestAPI
mockgen -package mockgh -destination internal/providers/github/mock/github.go -source pkg/providers/v1/providers.go GitHub
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
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -61,7 +61,7 @@ var Auth_revokeproviderCmd = &cobra.Command{
defer cancel()
client := pb.NewOAuthServiceClient(conn)
if all {
result, err := client.RevokeOauthTokens(ctx, &pb.RevokeOauthTokensRequest{Provider: provider})
result, err := client.RevokeOauthTokens(ctx, &pb.RevokeOauthTokensRequest{})
util.ExitNicelyOnError(err, "Error revoking tokens")
cmd.Println("Revoked a total of ", result.RevokedTokens, " tokens")
} else {
Expand All @@ -79,5 +79,6 @@ var Auth_revokeproviderCmd = &cobra.Command{
func init() {
AuthCmd.AddCommand(Auth_revokeproviderCmd)
Auth_revokeproviderCmd.Flags().StringP("provider", "n", "", "Name for the provider to revoke tokens for")
Auth_revokeproviderCmd.Flags().Int32P("group-id", "g", 0, "ID of the group for repo registration")
Auth_revokeproviderCmd.Flags().BoolP("all", "a", false, "Revoke all tokens")
}
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
12 changes: 10 additions & 2 deletions cmd/cli/app/policy_status/table_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"strings"
"time"

"github.com/charmbracelet/glamour"
"github.com/olekukonko/tablewriter"
"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 Expand Up @@ -160,5 +161,12 @@ func guidanceOrEncouragement(status, guidance string) string {
return "No guidance available for this rule 😞"
}

return guidance
// TODO: use a color scheme for mediator instead of a pre-defined one.
// Related-to: https://github.com/stacklok/mediator/issues/1006
renderedGuidance, err := glamour.Render(guidance, "dark")
if err != nil {
return guidance
}

return renderedGuidance
}
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
Loading

0 comments on commit b68f5ba

Please sign in to comment.