Skip to content

Commit

Permalink
fix: patch pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
lanathlor authored and LeVraiBaptiste committed Jul 4, 2024
1 parent 064d322 commit dd9e158
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
dist/

.configs/
tmp/
docs/
tmp/
26 changes: 11 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ build cli:
script:
- |
apk add --no-cache gcc musl-dev make
go install github.com/swaggo/swag/cmd/swag@latest
swag init -g root.go -o cmd/docs -d cmd/daemon/run/
make cli
mv dist/stamusctl .
Expand Down Expand Up @@ -124,8 +122,6 @@ build test:
script:
- |
apk add --no-cache gcc musl-dev make
go install github.com/swaggo/swag/cmd/swag@latest
swag init -g root.go -o cmd/docs -d cmd/daemon/run/
chmod +x $(pwd)/scripts/move.sh
$(pwd)/scripts/move.sh
make test-cli
Expand All @@ -139,7 +135,7 @@ test cli:
- build cli
script:
- |
./stamusctl
STAMUS_APP_NAME=stamusctl ./stamusctl
test daemon:
image: busybox
Expand All @@ -148,7 +144,7 @@ test daemon:
- build daemon
script:
- |
./stamusd
STAMUS_APP_NAME=stamusd ./stamusd
unit tests:
image: golang:alpine
Expand All @@ -165,7 +161,7 @@ compose init:
- build test
script:
- |
./cli compose init --default nginx.exec=nginx
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx.exec=nginx
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init
Expand All @@ -176,7 +172,7 @@ compose init set:
- build test
script:
- |
./cli compose init --default nginx.exec=nginx websocket.response=lel
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx.exec=nginx websocket.response=lel
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init-set
Expand All @@ -187,7 +183,7 @@ compose init optional:
- build test
script:
- |
./cli compose init --default nginx=false
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx=false
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init-optional
Expand All @@ -198,7 +194,7 @@ compose init arbitrary:
- build test
script:
- |
./cli compose init --default nginx.exec=nginx websocket.port=6969
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx.exec=nginx websocket.port=6969
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init-arbitrary
Expand All @@ -209,8 +205,8 @@ compose config set:
- build test
script:
- |
./cli compose init --default nginx.exec=nginx
./cli compose config set websocket.response=lel
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx.exec=nginx
STAMUS_APP_NAME=stamusctl ./cli compose config set websocket.response=lel
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init-set
Expand All @@ -221,8 +217,8 @@ compose config reload:
- build test
script:
- |
./cli compose init --default nginx.exec=nginx
./cli compose config set websocket.port=6969
./cli compose config set --reload
STAMUS_APP_NAME=stamusctl ./cli compose init --default nginx.exec=nginx
STAMUS_APP_NAME=stamusctl ./cli compose config set websocket.port=6969
STAMUS_APP_NAME=stamusctl ./cli compose config set --reload
chmod +x $(pwd)/scripts/compare.sh
$(pwd)/scripts/compare.sh ./tmp ./outputs/compose-init
3 changes: 2 additions & 1 deletion cmd/daemon/run/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

func NewPrometheusServer(ctx context.Context) {
engineProm := gin.New()

p := ginprometheus.NewPrometheus("gin")
p.Use(engineProm)

Expand Down Expand Up @@ -70,7 +71,7 @@ func RunCmd() *cobra.Command {

logging.LoggerWithSpanContext(span.SpanContext()).Info("Setup middleware")
r.Use(gin.Recovery())
r.Use(otelgin.Middleware("service-name", otelgin.WithTracerProvider(logging.TracerProvider)))
r.Use(otelgin.Middleware("stamusd", otelgin.WithTracerProvider(logging.TracerProvider)))

logging.LoggerWithSpanContext(span.SpanContext()).Info("Setup routes")
v1 := r.Group("/api/v1")
Expand Down
83 changes: 83 additions & 0 deletions cmd/docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/compose/pingcompose": {
"get": {
"description": "do ping",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"example"
],
"summary": "ping example",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/ping": {
"get": {
"description": "do ping",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"example"
],
"summary": "ping example",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "",
BasePath: "/api/v1",
Schemes: []string{},
Title: "Swagger Stamusd API",
Description: "Stamus daemon server.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
58 changes: 58 additions & 0 deletions cmd/docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"swagger": "2.0",
"info": {
"description": "Stamus daemon server.",
"title": "Swagger Stamusd API",
"contact": {},
"version": "1.0"
},
"basePath": "/api/v1",
"paths": {
"/compose/pingcompose": {
"get": {
"description": "do ping",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"example"
],
"summary": "ping example",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/ping": {
"get": {
"description": "do ping",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"example"
],
"summary": "ping example",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
}
}
}
38 changes: 38 additions & 0 deletions cmd/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
basePath: /api/v1
info:
contact: {}
description: Stamus daemon server.
title: Swagger Stamusd API
version: "1.0"
paths:
/compose/pingcompose:
get:
consumes:
- application/json
description: do ping
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: ping example
tags:
- example
/ping:
get:
consumes:
- application/json
description: do ping
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: ping example
tags:
- example
swagger: "2.0"
11 changes: 10 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (

// cli "stamus-ctl/cmd/stamusctl/commands"
"os"
ctl "stamus-ctl/cmd/ctl"
daemon "stamus-ctl/cmd/daemon"
"stamus-ctl/internal/app"
Expand All @@ -17,7 +18,15 @@ func main() {
case "stamusd":
daemon.Execute()
default:
daemon.Execute()
exec := os.Getenv("STAMUS_APP_NAME")
switch exec {
case "stamusctl":
ctl.Execute()
case "stamusd":
daemon.Execute()
default:
daemon.Execute()
}
}

// if err != nil {
Expand Down

0 comments on commit dd9e158

Please sign in to comment.