Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #31

Merged
merged 5 commits into from
Jun 2, 2022
Merged
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
Binary file modified docs/Analysis - ResIT.pdf
Binary file not shown.
Binary file added docs/Design - ResIT.pdf
Binary file not shown.
Binary file added docs/DevOps - ResIT.pdf
Binary file not shown.
Binary file added docs/Ethics Report.pdf
Binary file not shown.
Binary file added docs/Test Plan - ResIT.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
20 changes: 11 additions & 9 deletions src/config_api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
FROM golang:1.18.0-alpine as builder
FROM golang:1.18.2-buster as builder

ENV GO111MODULE=on
WORKDIR /app
COPY . .

RUN apk --no-cache add git alpine-sdk build-base gcc

# RUN apk --no-cache add git alpine-sdk build-base gcc
RUN apt-get install -y ca-certificates
RUN go get

RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN swag init --parseDependency --parseInternal
# RUN go install github.com/swaggo/swag/cmd/swag@latest
# RUN swag init --parseDependency --parseInternal

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o ./build
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o ./build

FROM scratch AS final
FROM debian:10.3-slim AS final

COPY --from=builder /app/build build
COPY --from=builder /app/docs docs

# COPY --from=builder /app/docs docs
# COPY --from=builder /app/public public
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
CMD ["/build"]

12 changes: 6 additions & 6 deletions src/reservation_api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ WORKDIR /app
COPY . .

# RUN apk --no-cache add git alpine-sdk build-base gcc

RUN apt-get install -y ca-certificates
RUN go get

RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN swag init --parseDependency --parseInternal
# RUN go install github.com/swaggo/swag/cmd/swag@latest
# RUN swag init --parseDependency --parseInternal

RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o ./build

FROM debian:10.3-slim AS final

COPY --from=builder /app/build build
COPY --from=builder /app/docs docs
COPY --from=builder /app/public public

# COPY --from=builder /app/docs docs
# COPY --from=builder /app/public public
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
CMD ["/build"]
13 changes: 0 additions & 13 deletions src/reservation_api/repository/mongodb/reservation_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,13 @@ func (repo *MongoDBReservation) All() []model.ReservationReadDTO {
lookup2 := bson.D{{Key: "$lookup", Value: bson.D{{Key: "from", Value: "timeslots"}, {Key: "localField", Value: "datetime_slot.time_slot"}, {Key: "foreignField", Value: "_id"}, {Key: "as", Value: "datetime_slot.time_slot"}}}}
unwind2 := bson.D{{Key: "$unwind", Value: bson.D{{Key: "path", Value: "$datetime_slot.time_slot"}, {Key: "preserveNullAndEmptyArrays", Value: false}}}}
collection := repo.db.Collection("reservations")
//result, err := collection.Find(context.TODO(), bson.D{})
result, err := collection.Aggregate(context.TODO(), mongo.Pipeline{lookup, unwind, lookup2, unwind2})
if err != nil {
log.Error(err)
}
// for result.Next(context.TODO()) {

// // create a value into which the single document can be decoded
// var elem model.Reservation
// err := result.Decode(&elem)
// if err != nil {
// fmt.Println(err)
// }

// reservations = append(reservations, elem)
// }
if err = result.All(context.TODO(), &reservations); err != nil {
log.Error(err)
}
fmt.Println(reservations)
return reservations
}

Expand Down
5 changes: 1 addition & 4 deletions src/reservation_api/util/rewrite/convert_to_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rewrite

import (
"encoding/json"
"log"
"math/rand"
"strconv"
"strings"
Expand Down Expand Up @@ -80,14 +79,12 @@ func StructToJson(res model.ReservationReadDTO) ([]byte, []byte) {
sr, sc := ReservationToModels(res)
final_res, err := json.Marshal(sr)
if err != nil {
log.Println("test_res", err)
return nil, nil
}
final_custs, err := json.Marshal(sc)
if err != nil {
log.Println("test_cust", err)
return nil, nil
}
log.Println("Test reservation:", string(final_res), "Test customers:", string(final_custs))

return final_res, final_custs
}