Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e25f39140a | ||
|
|
744af76df2 | ||
| ce5e5f7acb | |||
| 139c4b70cf | |||
| f20baaba03 | |||
| 3a932622b4 | |||
| a6ca0d04ec | |||
| 8147a7a6b9 | |||
|
|
41bf03682c |
81
.gitea/workflows/build.yml
Normal file
81
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install Docker
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y docker.io
|
||||||
|
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set Kubernetes Context
|
||||||
|
uses: azure/k8s-set-context@v4
|
||||||
|
with:
|
||||||
|
method: kubeconfig
|
||||||
|
kubeconfig: ${{secrets.buildx_kubeconfig}}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: kubernetes
|
||||||
|
driver-opts: |
|
||||||
|
namespace=gitea
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.coopgo.io
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker image
|
||||||
|
id: metadata
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: git.coopgo.io/${{gitea.repository}}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ steps.metadata.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
ACCESS_TOKEN_USR=${{gitea.actor}}
|
||||||
|
ACCESS_TOKEN_PWD=${{gitea.token}}
|
||||||
|
|
||||||
|
# BUILD WITH KANIKO
|
||||||
|
# - name: Kaniko build and push
|
||||||
|
# uses: aevea/action-kaniko@master
|
||||||
|
# with:
|
||||||
|
# build_file: Dockerfile
|
||||||
|
# registry: git.coopgo.io
|
||||||
|
# username: ${{secrets.registry_user}}
|
||||||
|
# password: ${{secrets.registry_token}}
|
||||||
|
# image: ${{gitea.repository}}
|
||||||
|
# tag: ${{gitea.ref_name}}
|
||||||
|
# cache: true
|
||||||
|
# cache_registry: git.coopgo.io/${{gitea.repository}}/cache
|
||||||
|
# extra-args: |
|
||||||
|
# ACCESS_TOKEN_USR=${{gitea.actor}}
|
||||||
|
# ACCESS_TOKEN_PWD=${{gitea.token}}
|
||||||
@@ -80,9 +80,6 @@ func (s FleetsServerImpl) GetVehicles(ctx context.Context, req *GetVehiclesReque
|
|||||||
return &GetVehiclesResponse{Vehicles: vehicles}, nil
|
return &GetVehiclesResponse{Vehicles: vehicles}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s FleetsServerImpl) UpdateVehicle(context.Context, *UpdateVehicleRequest) (*UpdateVehicleResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateVehicle not implemented")
|
|
||||||
}
|
|
||||||
func (s FleetsServerImpl) CreateBooking(ctx context.Context, req *CreateBookingRequest) (*CreateBookingResponse, error) {
|
func (s FleetsServerImpl) CreateBooking(ctx context.Context, req *CreateBookingRequest) (*CreateBookingResponse, error) {
|
||||||
b := req.Booking.ToStorageType()
|
b := req.Booking.ToStorageType()
|
||||||
booking, err := s.handler.AddBooking(b)
|
booking, err := s.handler.AddBooking(b)
|
||||||
@@ -196,3 +193,19 @@ func Run(done chan error, cfg *viper.Viper, handler handlers.FleetsHandler) {
|
|||||||
done <- err
|
done <- err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////update////////////////////////
|
||||||
|
func (s FleetsServerImpl) UpdateVehicle(ctx context.Context, req *UpdateVehicleRequest) (*UpdateVehicleResponse, error) {
|
||||||
|
b := req.Vehicle.ToStorageType()
|
||||||
|
vehicle, err := s.handler.UpdateVehicle(b)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, status.Errorf(codes.AlreadyExists, "vehicle update failed : %v", err)
|
||||||
|
}
|
||||||
|
response, err := VehicleFromStorageType(vehicle)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, status.Errorf(codes.Internal, "issue while retrieving vehicle : %v", err)
|
||||||
|
}
|
||||||
|
return &UpdateVehicleResponse{Vehicle: response}, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
// "Documents/go_projet/go/pkg/mod/git.coopgo.io/coopgo-platform/fleets@v0.0.0-20230310144446-feb935f8bf4e/storage"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-platform/fleets/storage"
|
"git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
@@ -56,3 +58,14 @@ func (h FleetsHandler) GetVehicles(namespaces []string, filters storage.VehicleF
|
|||||||
}
|
}
|
||||||
return newvehicles, err
|
return newvehicles, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////update///////////////
|
||||||
|
func (h FleetsHandler) UpdateVehicle(vehicle storage.Vehicle) (*storage.Vehicle, error) {
|
||||||
|
|
||||||
|
// Store the account
|
||||||
|
if err := h.storage.UpdateVehicle(vehicle); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &vehicle, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -225,14 +225,22 @@ func (s MongoDBStorage) GetBookingsForDriver(driver string) (bookings []Booking,
|
|||||||
func (s MongoDBStorage) DeleteBooking(bookingid string) error {
|
func (s MongoDBStorage) DeleteBooking(bookingid string) error {
|
||||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"])
|
collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"])
|
||||||
|
|
||||||
_, err := collection.UpdateOne(
|
_, err := collection.DeleteOne(
|
||||||
context.TODO(),
|
context.TODO(),
|
||||||
bson.M{"_id": bookingid},
|
bson.M{"_id": bookingid},
|
||||||
bson.D{
|
|
||||||
{"$set", bson.D{{"deleted", true}}},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////update///////////////
|
||||||
|
func (s MongoDBStorage) UpdateVehicle(vehicle Vehicle) error {
|
||||||
|
collection := s.Client.Database(s.DbName).Collection(s.Collections["vehicles"])
|
||||||
|
if _, err := collection.ReplaceOne(context.TODO(), bson.M{"_id": vehicle.ID}, vehicle); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -576,3 +576,7 @@ func (psql PostgresqlStorage) Migrate() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) UpdateVehicle(vehicle Vehicle) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Storage interface {
|
|||||||
CreateVehicle(Vehicle) error
|
CreateVehicle(Vehicle) error
|
||||||
GetVehicle(id string) (*Vehicle, error)
|
GetVehicle(id string) (*Vehicle, error)
|
||||||
GetVehicles(namespaces []string) ([]Vehicle, error)
|
GetVehicles(namespaces []string) ([]Vehicle, error)
|
||||||
|
UpdateVehicle(Vehicle) error
|
||||||
|
|
||||||
//Bookings management
|
//Bookings management
|
||||||
CreateBooking(Booking) error
|
CreateBooking(Booking) error
|
||||||
|
|||||||
Reference in New Issue
Block a user