Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func configureCmdRun(cmd *cobra.Command, args []string) {
questions = append(questions, &survey.Question{
Name: "PanelURL",
Prompt: &survey.Input{Message: "Panel URL: "},
Validate: func(ans interface{}) error {
Validate: func(ans any) error {
if str, ok := ans.(string); ok {
_, err := url.ParseRequestURI(str)
return err
Expand All @@ -81,7 +81,7 @@ func configureCmdRun(cmd *cobra.Command, args []string) {
questions = append(questions, &survey.Question{
Name: "Token",
Prompt: &survey.Input{Message: "API Token: "},
Validate: func(ans interface{}) error {
Validate: func(ans any) error {
if str, ok := ans.(string); ok {
if len(str) == 0 {
return fmt.Errorf("please provide a valid authentication token")
Expand All @@ -96,7 +96,7 @@ func configureCmdRun(cmd *cobra.Command, args []string) {
questions = append(questions, &survey.Question{
Name: "Node",
Prompt: &survey.Input{Message: "Node ID: "},
Validate: func(ans interface{}) error {
Validate: func(ans any) error {
if str, ok := ans.(string); ok {
if !nodeIdRegex.Match([]byte(str)) {
return fmt.Errorf("please provide a valid authentication token")
Expand Down
2 changes: 1 addition & 1 deletion cmd/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func uploadToHastebin(hbUrl, content string) (string, error) {
fmt.Println("Failed to upload report to ", u.String(), err)
return "", err
}
pres := make(map[string]interface{})
pres := make(map[string]any)
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println("Failed to parse response.", err)
Expand Down
2 changes: 1 addition & 1 deletion environment/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (l Limits) AsContainerResources() container.Resources {
return resources
}

type Variables map[string]interface{}
type Variables map[string]any

// Get is an ugly hacky function to handle environment variables that get passed
// through as not-a-string from the Panel. Ideally we'd just say only pass
Expand Down
6 changes: 3 additions & 3 deletions events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// Event represents an Event sent over a Bus.
type Event struct {
Topic string
Data interface{}
Data any
}

// Bus represents an Event Bus.
Expand All @@ -33,7 +33,7 @@ func NewBus() *Bus {
}

// Publish publishes a message to the Bus.
func (b *Bus) Publish(topic string, data interface{}) {
func (b *Bus) Publish(topic string, data any) {
// Some of our actions for the socket support passing a more specific namespace,
// such as "backup completed:1234" to indicate which specific backup was completed.
//
Expand Down Expand Up @@ -63,7 +63,7 @@ func MustDecode(data []byte) (e Event) {
}

// DecodeTo decodes a byte slice of event data into the given interface.
func DecodeTo(data []byte, v interface{}) error {
func DecodeTo(data []byte, v any) error {
if err := json.Unmarshal(data, &v); err != nil {
return errors.Wrap(err, "events: failed to decode byte slice")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cron/sftp_cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (em *eventMap) Push(a models.Activity) {
if a.Timestamp.Before(m.Timestamp) {
m.Timestamp = a.Timestamp
}
list := m.Metadata["files"].([]interface{})
list := m.Metadata["files"].([]any)
if s, ok := a.Metadata["files"]; ok {
v := reflect.ValueOf(s)
if v.Kind() != reflect.Slice || v.IsNil() {
Expand Down Expand Up @@ -188,7 +188,7 @@ func (em *eventMap) forActivity(a models.Activity) *models.Activity {
// function and then assign it into the map with an empty metadata value.
v := a
v.Metadata = models.ActivityMeta{
"files": make([]interface{}, 0),
"files": make([]any, 0),
}
em.m[key] = &v
return &v
Expand Down
2 changes: 1 addition & 1 deletion internal/models/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type Event string

type ActivityMeta map[string]interface{}
type ActivityMeta map[string]any

// Activity defines an activity log event for a server entity performed by a user. This is
// used for tracking commands, power actions, and SFTP events so that they can be reconciled
Expand Down
8 changes: 4 additions & 4 deletions parser/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var configMatchRegex = regexp.MustCompile(`{{\s?config\.([\w.-]+)\s?}}`)
var xmlValueMatchRegex = regexp.MustCompile(`^\[([\w]+)='(.*)'\]$`)

// Gets the value of a key based on the value type defined.
func (cfr *ConfigurationFileReplacement) getKeyValue(value string) interface{} {
func (cfr *ConfigurationFileReplacement) getKeyValue(value string) any {
if cfr.ReplaceWith.Type() == jsonparser.Boolean {
v, _ := strconv.ParseBool(value)
return v
Expand Down Expand Up @@ -115,7 +115,7 @@ var checkForArrayElement = regexp.MustCompile(`^([^\[\]]+)\[([\d]+)](\..+)?$`)
// to handle that edge case and ensure the value gets set correctly.
//
// Bless thee who has to touch these most unholy waters.
func setValueAtPath(c *gabs.Container, path string, value interface{}) error {
func setValueAtPath(c *gabs.Container, path string, value any) error {
var err error

matches := checkForArrayElement.FindStringSubmatch(path)
Expand All @@ -135,12 +135,12 @@ func setValueAtPath(c *gabs.Container, path string, value interface{}) error {
return errors.WithMessage(err, "error while parsing array element at path")
}

t := make([]interface{}, 1)
t := make([]any, 1)
// If the length of matches is 4 it means we're trying to access an object down in this array
// key, so make sure we generate the array as an array of objects, and not just a generic nil
// array.
if len(matches) == 4 {
t = []interface{}{map[string]interface{}{}}
t = []any{map[string]any{}}
}

// If the error is because this isn't an array or isn't found go ahead and create the array with
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func (f *ConfigurationFile) parseYamlFile(file ufs.File) error {
return err
}

i := make(map[string]interface{})
i := make(map[string]any)
if err := yaml.Unmarshal(b, &i); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions remote/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *client) Get(ctx context.Context, path string, query q) (*Response, erro
}

// Post executes a HTTP POST request.
func (c *client) Post(ctx context.Context, path string, data interface{}) (*Response, error) {
func (c *client) Post(ctx context.Context, path string, data any) (*Response, error) {
b, err := json.Marshal(data)
if err != nil {
return nil, err
Expand Down Expand Up @@ -242,7 +242,7 @@ func (r *Response) Read() ([]byte, error) {
// BindJSON binds a given interface with the data returned in the response. This
// is a shortcut for calling Read and then manually calling json.Unmarshal on
// the raw bytes.
func (r *Response) BindJSON(v interface{}) error {
func (r *Response) BindJSON(v any) error {
b, err := r.Read()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion remote/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
// benefit from being a typed struct.
//
// Inspired by gin.H, same concept.
type d map[string]interface{}
type d map[string]any

// Same concept as d, but a map of strings, used for querying GET requests.
type q map[string]string
Expand Down
2 changes: 1 addition & 1 deletion router/router_server_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func postServerBackup(c *gin.Context) {

// Attach the server ID and the request ID to the adapter log context for easier
// parsing in the logs.
adapter.WithLogContext(map[string]interface{}{
adapter.WithLogContext(map[string]any{
"server": s.ID(),
"request_id": c.GetString("request_id"),
})
Expand Down
2 changes: 1 addition & 1 deletion router/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (h *Handler) SendJson(v Message) error {
// Sends JSON over the websocket connection, ignoring the authentication state of the
// socket user. Do not call this directly unless you are positive a response should be
// sent back to the client!
func (h *Handler) unsafeSendJson(v interface{}) error {
func (h *Handler) unsafeSendJson(v any) error {
h.Lock()
defer h.Unlock()

Expand Down
4 changes: 2 additions & 2 deletions server/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *Server) Backup(b backup.BackupInterface) error {
s.Log().WithField("backup", b.Identifier()).Info("notified panel of failed backup state")
}

s.Events().Publish(BackupCompletedEvent+":"+b.Identifier(), map[string]interface{}{
s.Events().Publish(BackupCompletedEvent+":"+b.Identifier(), map[string]any{
"uuid": b.Identifier(),
"is_successful": false,
"checksum": "",
Expand All @@ -102,7 +102,7 @@ func (s *Server) Backup(b backup.BackupInterface) error {

// Emit an event over the socket so we can update the backup in realtime on
// the frontend for the server.
s.Events().Publish(BackupCompletedEvent+":"+b.Identifier(), map[string]interface{}{
s.Events().Publish(BackupCompletedEvent+":"+b.Identifier(), map[string]any{
"uuid": b.Identifier(),
"is_successful": true,
"checksum": ad.Checksum,
Expand Down
4 changes: 2 additions & 2 deletions server/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type BackupInterface interface {
Identifier() string
// WithLogContext attaches additional context to the log output for this
// backup.
WithLogContext(map[string]interface{})
WithLogContext(map[string]any)
// Generate creates a backup in whatever the configured source for the
// specific implementation is.
Generate(context.Context, *filesystem.Filesystem, string) (*ArchiveDetails, error)
Expand Down Expand Up @@ -80,7 +80,7 @@ type Backup struct {

client remote.Client
adapter AdapterType
logContext map[string]interface{}
logContext map[string]any
}

func (b *Backup) SetClient(c remote.Client) {
Expand Down
2 changes: 1 addition & 1 deletion server/backup/backup_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (b *LocalBackup) Remove() error {
}

// WithLogContext attaches additional context to the log output for this backup.
func (b *LocalBackup) WithLogContext(c map[string]interface{}) {
func (b *LocalBackup) WithLogContext(c map[string]any) {
b.logContext = c
}

Expand Down
2 changes: 1 addition & 1 deletion server/backup/backup_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *S3Backup) Remove() error {
}

// WithLogContext attaches additional context to the log output for this backup.
func (s *S3Backup) WithLogContext(c map[string]interface{}) {
func (s *S3Backup) WithLogContext(c map[string]any) {
s.logContext = c
}

Expand Down
2 changes: 1 addition & 1 deletion server/filesystem/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const memory = 4 * 1024

var pool = sync.Pool{
New: func() interface{} {
New: func() any {
b := make([]byte, memory)
return b
},
Expand Down
2 changes: 1 addition & 1 deletion sftp/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type FileAction struct {
// Log parses a SFTP specific file activity event and then passes it off to be stored
// in the normal activity database.
func (eh *eventHandler) Log(e models.Event, fa FileAction) error {
metadata := map[string]interface{}{
metadata := map[string]any{
"files": []string{fa.Entity},
}
if fa.Target != "" {
Expand Down