Skip to content

Commit 5f07cb5

Browse files
authored
Merge pull request #166 from HyperloopUPV-H8/backend/adj
[backend][1] ADJ
2 parents 76a270f + 91c90bd commit 5f07cb5

32 files changed

Lines changed: 218 additions & 1836 deletions

backend/cmd/main.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/binary"
77
"flag"
88
"fmt"
9+
"github.com/HyperloopUPV-H8/h9-backend/internal/adj"
910
"log"
1011
"net"
1112
"net/http"
@@ -87,22 +88,14 @@ func main() {
8788
runtime.SetBlockProfileRate(*blockprofile)
8889
config := getConfig("./config.toml")
8990

90-
file, err := excel.Download(excel.DownloadConfig(config.Excel.Download))
91-
if err != nil {
92-
trace.Fatal().Err(err).Msg("downloading file")
93-
}
94-
95-
ade, err := ade.CreateADE(file)
96-
if err != nil {
97-
trace.Fatal().Err(err).Msg("creating ade")
98-
}
91+
// <--- ADJ --->
9992

100-
info, err := info.NewInfo(ade.Info)
93+
adj, err := adj.NewADJ()
10194
if err != nil {
102-
trace.Fatal().Err(err).Msg("creating info")
95+
trace.Fatal().Err(err).Msg("setting up ADJ")
10396
}
10497

105-
podData, err := pod_data.NewPodData(ade.Boards, info.Units)
98+
podData, err := pod_data.NewPodData(adj.Boards, adj.Info.Units)
10699
if err != nil {
107100
fmt.Println(err)
108101
trace.Fatal().Err(err).Msg("creating podData")

backend/go.mod

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.21.3
44

55
require (
66
github.com/HyperloopUPV-H8/ade-linter v0.0.0-20230530153315-3379f05a664f
7+
github.com/go-git/go-git/v5 v5.12.0
78
github.com/google/gopacket v1.1.19
89
github.com/google/uuid v1.3.0
910
github.com/gorilla/websocket v1.5.0
@@ -20,29 +21,46 @@ require (
2021
require (
2122
cloud.google.com/go/compute v1.19.1 // indirect
2223
cloud.google.com/go/compute/metadata v0.2.3 // indirect
23-
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
24+
dario.cat/mergo v1.0.0 // indirect
25+
github.com/Microsoft/go-winio v0.6.1 // indirect
26+
github.com/ProtonMail/go-crypto v1.0.0 // indirect
27+
github.com/cloudflare/circl v1.3.7 // indirect
28+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
29+
github.com/emirpasic/gods v1.18.1 // indirect
30+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
31+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
32+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
2433
github.com/golang/protobuf v1.5.3 // indirect
2534
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
2635
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
36+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
37+
github.com/kevinburke/ssh_config v1.2.0 // indirect
2738
github.com/mattn/go-colorable v0.1.13 // indirect
2839
github.com/mattn/go-isatty v0.0.17 // indirect
2940
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
41+
github.com/pjbgf/sha1cd v0.3.0 // indirect
3042
github.com/richardlehane/mscfb v1.0.4 // indirect
3143
github.com/richardlehane/msoleps v1.0.3 // indirect
44+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
45+
github.com/skeema/knownhosts v1.2.2 // indirect
46+
github.com/xanzy/ssh-agent v0.3.3 // indirect
3247
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
3348
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
3449
go.opencensus.io v0.24.0 // indirect
35-
golang.org/x/crypto v0.14.0 // indirect
50+
golang.org/x/crypto v0.21.0 // indirect
51+
golang.org/x/mod v0.12.0 // indirect
3652
golang.org/x/oauth2 v0.7.0 // indirect
37-
golang.org/x/sys v0.13.0 // indirect
38-
golang.org/x/text v0.13.0 // indirect
53+
golang.org/x/sys v0.18.0 // indirect
54+
golang.org/x/text v0.14.0 // indirect
55+
golang.org/x/tools v0.13.0 // indirect
3956
google.golang.org/appengine v1.6.7 // indirect
4057
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
4158
google.golang.org/grpc v1.56.3 // indirect
4259
google.golang.org/protobuf v1.30.0 // indirect
60+
gopkg.in/warnings.v0 v0.1.2 // indirect
4361
)
4462

4563
require (
4664
github.com/fatih/color v1.15.0
47-
golang.org/x/net v0.17.0 // indirect
65+
golang.org/x/net v0.22.0 // indirect
4866
)

backend/go.sum

Lines changed: 104 additions & 12 deletions
Large diffs are not rendered by default.

backend/internal/adj/adj.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package adj
2+
3+
import (
4+
"encoding/json"
5+
"github.com/go-git/go-git/v5"
6+
"os"
7+
)
8+
9+
const (
10+
RepoUrl = "https://github.com/HyperloopUPV-H8/JSON_ADE.git" // URL of the ADJ repository
11+
)
12+
13+
func downloadADJ() (json.RawMessage, json.RawMessage, error) {
14+
_, err := git.PlainClone("", false, &git.CloneOptions{
15+
URL: RepoUrl,
16+
})
17+
if err != nil {
18+
return nil, nil, err
19+
}
20+
21+
info, err := os.ReadFile("general_info.json")
22+
if err != nil {
23+
return nil, nil, err
24+
}
25+
26+
boards, err := os.ReadFile("boards.json")
27+
if err != nil {
28+
return nil, nil, err
29+
}
30+
31+
return info, boards, nil
32+
}
33+
34+
func NewADJ() (*ADJ, error) {
35+
infoRaw, boardsRaw, err := downloadADJ()
36+
if err != nil {
37+
return nil, err
38+
}
39+
40+
var info Info
41+
if err := json.Unmarshal(infoRaw, &info); err != nil {
42+
return nil, err
43+
}
44+
45+
var boards map[string]Board
46+
if err := json.Unmarshal(boardsRaw, &boards); err != nil {
47+
return nil, err
48+
}
49+
50+
adj := &ADJ{
51+
Info: info,
52+
Boards: boards,
53+
}
54+
55+
return adj, nil
56+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package ade
1+
package adj
22

3-
type ADE struct {
3+
type ADJ struct {
44
Info Info
55
Boards map[string]Board
66
}
77

88
type Info struct {
9-
Addresses map[string]string
10-
Units map[string]string
11-
Ports map[string]string
9+
Ports map[string]string `json:"ports"`
10+
Addresses map[string]string `json:"addresses"`
11+
Units map[string]string `json:"units"`
12+
MessageIds map[string]string `json:"message_ids"`
1213
BoardIds map[string]string
13-
MessageIds map[string]string
1414
}
1515

1616
type Board struct {

backend/internal/excel/ade/ade.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)