go fmt
This commit is contained in:
parent
da2ea12f30
commit
03d7250cf6
|
|
@ -1,13 +1,13 @@
|
||||||
package acl
|
package acl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
config "github.com/jamesread/OliveTin/internal/config"
|
config "github.com/jamesread/OliveTin/internal/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Username string;
|
Username string
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsAllowedExec(cfg *config.Config, user *User, action *config.ActionButton) bool {
|
func IsAllowedExec(cfg *config.Config, user *User, action *config.ActionButton) bool {
|
||||||
|
|
@ -37,7 +37,7 @@ func IsAllowedExec(cfg *config.Config, user *User, action *config.ActionButton)
|
||||||
"CanExec": canExec,
|
"CanExec": canExec,
|
||||||
}).Debug("isAllowedExec Final Result")
|
}).Debug("isAllowedExec Final Result")
|
||||||
|
|
||||||
return canExec;
|
return canExec
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsAllowedView(cfg *config.Config, user *User, action *config.ActionButton) bool {
|
func IsAllowedView(cfg *config.Config, user *User, action *config.ActionButton) bool {
|
||||||
|
|
@ -68,13 +68,11 @@ func IsAllowedView(cfg *config.Config, user *User, action *config.ActionButton)
|
||||||
"CanView": canView,
|
"CanView": canView,
|
||||||
}).Debug("isAllowedView Final Result")
|
}).Debug("isAllowedView Final Result")
|
||||||
|
|
||||||
return canView;
|
return canView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func isUserInGroup(user *User, usergroup string) bool {
|
func isUserInGroup(user *User, usergroup string) bool {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserFromContext(ctx context.Context) *User {
|
func UserFromContext(ctx context.Context) *User {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pb "github.com/jamesread/OliveTin/gen/grpc"
|
pb "github.com/jamesread/OliveTin/gen/grpc"
|
||||||
|
acl "github.com/jamesread/OliveTin/internal/acl"
|
||||||
config "github.com/jamesread/OliveTin/internal/config"
|
config "github.com/jamesread/OliveTin/internal/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
acl "github.com/jamesread/OliveTin/internal/acl"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -34,7 +34,7 @@ func (e *Executor) ExecAction(cfg *config.Config, user *acl.User, actualAction *
|
||||||
|
|
||||||
res := execAction(cfg, actualAction)
|
res := execAction(cfg, actualAction)
|
||||||
|
|
||||||
e.Logs = append(e.Logs, *res);
|
e.Logs = append(e.Logs, *res)
|
||||||
|
|
||||||
return &pb.StartActionResponse{
|
return &pb.StartActionResponse{
|
||||||
LogEntry: &pb.LogEntry{
|
LogEntry: &pb.LogEntry{
|
||||||
|
|
@ -44,7 +44,7 @@ func (e *Executor) ExecAction(cfg *config.Config, user *acl.User, actualAction *
|
||||||
Stdout: res.Stdout,
|
Stdout: res.Stdout,
|
||||||
ExitCode: res.ExitCode,
|
ExitCode: res.ExitCode,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func execAction(cfg *config.Config, actualAction *config.ActionButton) *InternalLogEntry {
|
func execAction(cfg *config.Config, actualAction *config.ActionButton) *InternalLogEntry {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
acl "github.com/jamesread/OliveTin/internal/acl"
|
||||||
config "github.com/jamesread/OliveTin/internal/config"
|
config "github.com/jamesread/OliveTin/internal/config"
|
||||||
executor "github.com/jamesread/OliveTin/internal/executor"
|
executor "github.com/jamesread/OliveTin/internal/executor"
|
||||||
acl "github.com/jamesread/OliveTin/internal/acl"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -37,8 +37,7 @@ func (api *oliveTinAPI) StartAction(ctx ctx.Context, req *pb.StartActionRequest)
|
||||||
user := acl.UserFromContext(ctx)
|
user := acl.UserFromContext(ctx)
|
||||||
|
|
||||||
if !acl.IsAllowedExec(cfg, user, actualAction) {
|
if !acl.IsAllowedExec(cfg, user, actualAction) {
|
||||||
return &pb.StartActionResponse{
|
return &pb.StartActionResponse{}, nil
|
||||||
}, nil
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +74,7 @@ func (api *oliveTinAPI) GetButtons(ctx ctx.Context, req *pb.GetButtonsRequest) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *oliveTinAPI) GetLogs(ctx ctx.Context, req *pb.GetLogsRequest) (*pb.GetLogsResponse, error) {
|
func (api *oliveTinAPI) GetLogs(ctx ctx.Context, req *pb.GetLogsRequest) (*pb.GetLogsResponse, error) {
|
||||||
ret := &pb.GetLogsResponse{};
|
ret := &pb.GetLogsResponse{}
|
||||||
|
|
||||||
// TODO Limit to 10 entries or something to prevent browser lag.
|
// TODO Limit to 10 entries or something to prevent browser lag.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue