Skip to content

Commit

Permalink
fix whitespace to comply with wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed May 18, 2023
1 parent 6d2bd06 commit 130b757
Show file tree
Hide file tree
Showing 327 changed files with 8,322 additions and 34 deletions.
5 changes: 5 additions & 0 deletions cmd/spicedb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
rootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
cmd.Println(err)
cmd.Println(cmd.UsageString())

return errParsing
})
cmd.RegisterRootFlags(rootCmd)
Expand Down Expand Up @@ -63,10 +64,12 @@ func main() {

// Add server commands
var serverConfig cmdutil.Config

serveCmd := cmd.NewServeCommand(rootCmd.Use, &serverConfig)
if err := cmd.RegisterServeFlags(serveCmd, &serverConfig); err != nil {
log.Fatal().Err(err).Msg("failed to register server flags")
}

rootCmd.AddCommand(serveCmd)

devtoolsCmd := cmd.NewDevtoolsCommand(rootCmd.Use)
Expand All @@ -77,10 +80,12 @@ func main() {
testingCmd := cmd.NewTestingCommand(rootCmd.Use, &testServerConfig)
cmd.RegisterTestingFlags(testingCmd, &testServerConfig)
rootCmd.AddCommand(testingCmd)

if err := rootCmd.Execute(); err != nil {
if !errors.Is(err, errParsing) {
log.Err(err).Msg("terminated with errors")
}

os.Exit(1)
}
}
2 changes: 2 additions & 0 deletions internal/auth/presharedkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ func TestPresharedKeys(t *testing.T) {
testcase := testcase
t.Run(testcase.name, func(t *testing.T) {
f := MustRequirePresharedKey(testcase.presharedkeys)

ctx := context.Background()
if testcase.withMetadata {
ctx = withTokenMetadata(testcase.authzHeader)
}

_, err := f(ctx)
if testcase.expectedStatus != codes.OK {
require.Error(t, err)
Expand Down
7 changes: 7 additions & 0 deletions internal/caveats/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (lc loadedCaveats) Get(caveatDefName string) (*core.CaveatDefinition, *cave
}

lc.deserializedCaveats[caveatDefName] = deserialized

return caveat, deserialized, nil
}

Expand Down Expand Up @@ -198,11 +199,13 @@ func runExpressionWithCaveats(

cop := expr.GetOperation()
boolResult := false

if cop.Op == core.CaveatOperation_AND {
boolResult = true
}

var contextValues map[string]any

var exprStringPieces []string

buildExprString := func() (string, error) {
Expand Down Expand Up @@ -237,6 +240,7 @@ func runExpressionWithCaveats(

if debugOption == RunCaveatExpressionWithDebugInformation {
contextValues = combineMaps(contextValues, childResult.ContextValues())

exprString, err := childResult.ExpressionString()
if err != nil {
return nil, err
Expand All @@ -259,6 +263,7 @@ func runExpressionWithCaveats(

if debugOption == RunCaveatExpressionWithDebugInformation {
contextValues = combineMaps(contextValues, childResult.ContextValues())

exprString, err := childResult.ExpressionString()
if err != nil {
return nil, err
Expand All @@ -279,6 +284,7 @@ func runExpressionWithCaveats(
case core.CaveatOperation_NOT:
if debugOption == RunCaveatExpressionWithDebugInformation {
contextValues = combineMaps(contextValues, childResult.ContextValues())

exprString, err := childResult.ExpressionString()
if err != nil {
return nil, err
Expand Down Expand Up @@ -314,6 +320,7 @@ func combineMaps(first map[string]any, second map[string]any) map[string]any {

cloned := maps.Clone(first)
maps.Copy(cloned, second)

return cloned
}

Expand Down
9 changes: 9 additions & 0 deletions internal/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,35 +115,41 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
if err != nil {
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when parsing template")
fmt.Fprintf(w, "Internal Error")

return
}

state, err := ds.ReadyState(r.Context())
if err != nil {
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when checking database")
fmt.Fprintf(w, "Internal Error")

return
}

schema := ""
hasSampleSchema := false

isReady := state.IsReady
if isReady {
var objectDefs []string

userFound := false
resourceFound := false

headRevision, err := ds.HeadRevision(r.Context())
if err != nil {
log.Ctx(r.Context()).Error().Err(err).Msg("Got error when computing datastore revision")
fmt.Fprintf(w, "Internal Error")

return
}

nsDefs, err := ds.SnapshotReader(headRevision).ListAllNamespaces(r.Context())
if err != nil {
log.Ctx(r.Context()).Error().AnErr("datastoreError", err).Msg("Got error when trying to load namespaces")
fmt.Fprintf(w, "Internal Error")

return
}

Expand All @@ -152,6 +158,7 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
if err != nil {
log.Ctx(r.Context()).Error().Err(err).Msg("Got error when trying to generate namespace")
fmt.Fprintf(w, "Internal Error")

return
}

Expand All @@ -160,6 +167,7 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
if nsDef.Definition.Name == "user" {
userFound = true
}

if nsDef.Definition.Name == "resource" {
resourceFound = true
}
Expand Down Expand Up @@ -189,6 +197,7 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
if err != nil {
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when executing template")
fmt.Fprintf(w, "Internal Error")

return
}
})
Expand Down
Loading

0 comments on commit 130b757

Please sign in to comment.