diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f380c80..297ab9e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -42,14 +42,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx @@ -96,16 +88,3 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} \ No newline at end of file diff --git a/controller/FoodDetailController.go b/controller/FoodDetailController.go deleted file mode 100644 index 5d1198d..0000000 --- a/controller/FoodDetailController.go +++ /dev/null @@ -1,32 +0,0 @@ -package controller - -import ( - "food-track-be/model/dto" - "food-track-be/service" - "github.com/gin-gonic/gin" - "strconv" -) - -type FoodDetailController struct { - foodDetailService *service.FoodDetailService -} - -func NewFoodDetailController(f *service.FoodDetailService) *FoodDetailController { - return &FoodDetailController{foodDetailService: f} -} - -func (s *FoodDetailController) GetFoodKcals(c *gin.Context) { - var baseResponse dto.BaseResponse[float64] - barcode := c.Param("barcode") - quantity := c.Query("quantity") - parsedQuantity, err := strconv.ParseFloat(quantity, 64) - kcals, err := s.foodDetailService.GetKcalsForFoodConsumed(barcode, parsedQuantity) - if err != nil { - c.AbortWithStatusJSON(200, gin.H{ - "error": err.Error(), - }) - return - } - baseResponse.Body = kcals - c.JSON(200, baseResponse) -} diff --git a/k8s/overlays/qa/kustomization.yaml b/k8s/overlays/qa/kustomization.yaml index cc15e76..b353596 100644 --- a/k8s/overlays/qa/kustomization.yaml +++ b/k8s/overlays/qa/kustomization.yaml @@ -14,6 +14,5 @@ configMapGenerator: - DB_PORT=5432 - DB_USER=foodtrack - GROCERY_BASE_URL=http://grocery-be-service.grocery.svc.cluster.local:8000 - - FOOD_DETAIL_BASE_URL=http://food-details-integrator-be-service.grocery.svc.cluster.local:8080 patchesStrategicMerge: - deployment_patch.yaml \ No newline at end of file diff --git a/main.go b/main.go index 9e08a1d..c63e188 100644 --- a/main.go +++ b/main.go @@ -44,14 +44,10 @@ func main() { ms := service.NewMealService(mr, fcs) mc := controller.NewMealController(ms) fcc := controller.NewFoodConsumptionController(fcs) - fds := service.NewFoodDetailService() - fdc := controller.NewFoodDetailController(fds) r := gin.Default() r.Use(cors.Default()) - r.GET("/meal/detail/:barcode", fdc.GetFoodKcals) - r.GET("/meal", mc.FindAllMeals) r.GET("/meal/:mealId", mc.FindMealById) r.POST("/meal", mc.CreateMeal) diff --git a/service/FoodDetailService.go b/service/FoodDetailService.go deleted file mode 100644 index a349cdf..0000000 --- a/service/FoodDetailService.go +++ /dev/null @@ -1,40 +0,0 @@ -package service - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "os" -) - -type FoodDetailService struct { - baseUrl string -} - -func NewFoodDetailService() *FoodDetailService { - return &FoodDetailService{baseUrl: os.Getenv("FOOD_DETAIL_BASE_URL")} -} - -func (s FoodDetailService) getCall(url string) ([]byte, error) { - request, err := http.NewRequest(http.MethodGet, url, nil) - request.Header.Add("Content-Type", "application/json") - response, err := http.DefaultClient.Do(request) - if err != nil { - return nil, err - } - return io.ReadAll(response.Body) -} - -func (s FoodDetailService) GetKcalsForFoodConsumed(barcode string, quantity float64) (float64, error) { - var response float64 - responseData, err := s.getCall(s.baseUrl + "/food/" + barcode + "/kcal?quantity=" + fmt.Sprintf("%f", quantity) + "&unit=g") - if err != nil { - return 0, err - } - err = json.Unmarshal(responseData, &response) - if err != nil { - return 0, err - } - return response, nil -}