Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
soukainna | 5a67e2c377 | |
soukainna | 0e42bd7f79 | |
Nicolas CARON | 23c7b50d9b | |
Nicolas CARON | 3028dde959 | |
mfrigo | c71851add2 | |
mfrigo | 86df552bd1 |
|
@ -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}}
|
|
@ -59,6 +59,7 @@ func (h AgendaHandler) SubscribeEvent(eventid string, subscriber string, data ma
|
||||||
subscription := storage.Subscription{
|
subscription := storage.Subscription{
|
||||||
ID: id,
|
ID: id,
|
||||||
Subscriber: subscriber,
|
Subscriber: subscriber,
|
||||||
|
EventID: eventid,
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
Data: map[string]any{},
|
Data: map[string]any{},
|
||||||
|
@ -80,6 +81,7 @@ func (h AgendaHandler) DeleteSubscription(eventid string, subscriber string, dat
|
||||||
deletesubscription := storage.Subscription{
|
deletesubscription := storage.Subscription{
|
||||||
ID: id,
|
ID: id,
|
||||||
Subscriber: subscriber,
|
Subscriber: subscriber,
|
||||||
|
EventID: eventid,
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
Data: map[string]any{},
|
Data: map[string]any{},
|
||||||
|
@ -101,6 +103,17 @@ func (h AgendaHandler) UpdateEvent(event storage.Event) (*storage.Event, error)
|
||||||
return &event, nil
|
return &event, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h AgendaHandler) GetSubscriber(subscriber string) (results []storage.Subscription, err error) {
|
||||||
|
if subscriber == "" {
|
||||||
|
return nil, errors.New("missing subscriber")
|
||||||
|
}
|
||||||
|
results, err = h.storage.GetSubscriber(subscriber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h AgendaHandler) GetSubscriptionByUser(subscriber string) (results []storage.Subscription, err error) {
|
func (h AgendaHandler) GetSubscriptionByUser(subscriber string) (results []storage.Subscription, err error) {
|
||||||
if subscriber == "" {
|
if subscriber == "" {
|
||||||
return nil, errors.New("missing subscriber")
|
return nil, errors.New("missing subscriber")
|
||||||
|
|
|
@ -98,8 +98,6 @@ func (s MongoDBStorage) GetEvents(namespaces []string) (events []Event, err erro
|
||||||
return events, err
|
return events, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println(elem)
|
|
||||||
|
|
||||||
// bsonBytes, _ := bson.Marshal(elem)
|
// bsonBytes, _ := bson.Marshal(elem)
|
||||||
// fmt.Println(string(bsonBytes))
|
// fmt.Println(string(bsonBytes))
|
||||||
// bson.Unmarshal(bsonBytes, &event)
|
// bson.Unmarshal(bsonBytes, &event)
|
||||||
|
@ -154,10 +152,65 @@ func (s MongoDBStorage) UpdateEvent(event Event) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (psql MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) {
|
func (s MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) {
|
||||||
return nil, nil
|
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
|
||||||
|
subscriptions := []Subscription{}
|
||||||
|
|
||||||
|
var cur *mongo.Cursor
|
||||||
|
// findOptions := options.Find()
|
||||||
|
|
||||||
|
// cur, err := collection.Find(context.TODO(), bson.M{"subscriptions": subscriber}, findOptions)
|
||||||
|
|
||||||
|
cur, err := collection.Find(context.TODO(), bson.M{"subscriptions": bson.M{"$elemMatch": bson.M{"subscriber": subscriber}}})
|
||||||
|
if err != nil {
|
||||||
|
return subscriptions, err
|
||||||
|
}
|
||||||
|
for cur.Next(context.Background()) {
|
||||||
|
var event Event
|
||||||
|
if err := cur.Decode(&event); err != nil {
|
||||||
|
return subscriptions, err
|
||||||
|
}
|
||||||
|
for i := range event.Subscriptions {
|
||||||
|
if event.Subscriptions[i].Subscriber == subscriber {
|
||||||
|
subscriptions = append(subscriptions, event.Subscriptions[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println(subscriptions)
|
||||||
|
return subscriptions, nil
|
||||||
|
//return nil, nil
|
||||||
|
// if err != nil {
|
||||||
|
// return subscriptions, err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for cur.Next(context.TODO()) {
|
||||||
|
// var event Event
|
||||||
|
// var elem bson.M
|
||||||
|
|
||||||
|
// if err := cur.Decode(&elem); err != nil {
|
||||||
|
// return subscriptions, err
|
||||||
|
// }
|
||||||
|
// for i := range event.Subscriptions {
|
||||||
|
// if event.Subscriptions[i].Subscriber == subscriber {
|
||||||
|
// subscriptions = append(subscriptions, event.Subscriptions[i])
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // bsonBytes, _ := bson.Marshal(elem)
|
||||||
|
// // bson.Unmarshal(bsonBytes, &event)
|
||||||
|
|
||||||
|
// // subscriptions = append(subscriptions, event.Subscriptions[1])
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return subscriptions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (psql MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) {
|
func (s MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) {
|
||||||
return nil, nil
|
events, err := s.GetSubscriber(subscriber)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(events)
|
||||||
|
return events, nil
|
||||||
|
//return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ type Storage interface {
|
||||||
AddSubscription(eventid string, subscription Subscription) error
|
AddSubscription(eventid string, subscription Subscription) error
|
||||||
UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error
|
UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error
|
||||||
UpdateEvent(Event) error
|
UpdateEvent(Event) error
|
||||||
|
GetSubscriber(subscriber string) ([]Subscription, error)
|
||||||
GetSubscriptionByUser(subscriber string) ([]Subscription, error)
|
GetSubscriptionByUser(subscriber string) ([]Subscription, error)
|
||||||
}
|
}
|
||||||
type StorageImpl struct {
|
type StorageImpl struct {
|
||||||
|
|
Loading…
Reference in New Issue