diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b73d37d..f26e7ee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,6 @@ deploy:staging: api ./deploy \ --values deploy/values.staging.yaml \ --set image.tag=$TAG \ - --set migrations.image.tag=$TAG \ --set imageCredentials.username=$REGISTRY_USERNAME \ --set imageCredentials.password=$REGISTRY_PASSWORD \ --set config.database.url=$DATABASE_URL diff --git a/Makefile b/Makefile index 3672618..9335fc2 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,3 @@ build-docker-httpserver: .PHONY: build-docker-migrations build-docker-migrations: docker build -t yggdrasil-migrations -f ./build/package/migrations/Dockerfile . - -.PHONY: helm-test -helm-test: - helm lint ./deploy - helm template api ./deploy --values ./deploy/values.test.yaml diff --git a/api/v1/openapi.yaml b/api/v1/openapi.yaml index e9e85fd..4ebef8d 100644 --- a/api/v1/openapi.yaml +++ b/api/v1/openapi.yaml @@ -560,9 +560,6 @@ components: $ref: "#/components/schemas/TrainingPrice" slug: type: string - published: - type: boolean - default: false required: - name - days @@ -576,13 +573,9 @@ components: properties: id: $ref: "#/components/schemas/TrainingID" - retired: - type: boolean required: - id - slug - - published - - retired TrainingID: type: integer diff --git a/db/migrations/002_training-published-and-retired.down.sql b/db/migrations/002_training-published-and-retired.down.sql deleted file mode 100644 index 9f629b1..0000000 --- a/db/migrations/002_training-published-and-retired.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE training.trainings - DROP COLUMN published, - DROP COLUMN retired; diff --git a/db/migrations/002_training-published-and-retired.up.sql b/db/migrations/002_training-published-and-retired.up.sql deleted file mode 100644 index efb08ed..0000000 --- a/db/migrations/002_training-published-and-retired.up.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE training.trainings ADD COLUMN published BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE training.trainings ADD COLUMN retired BOOLEAN NOT NULL DEFAULT FALSE; - -COMMIT; diff --git a/deploy/templates/deployment.yaml b/deploy/templates/deployment.yaml index 6ba38f9..b5b5236 100644 --- a/deploy/templates/deployment.yaml +++ b/deploy/templates/deployment.yaml @@ -34,7 +34,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} containers: - - name: httpserver + - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: Always ports: diff --git a/deploy/templates/migration-job.yaml b/deploy/templates/migration-job.yaml deleted file mode 100644 index 8ea39ba..0000000 --- a/deploy/templates/migration-job.yaml +++ /dev/null @@ -1,46 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }} - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "database-migrations" - batch.kubernetes.io/job-name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }} -spec: - ttlSecondsAfterFinished: 604800 # 1 week in seconds - template: - metadata: - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "database-migrations" - batch.kubernetes.io/job-name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }} - spec: - automountServiceAccountToken: false - {{- with .Values.migrations.image.pullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: migrations - image: "{{ .Values.migrations.image.repository }}:{{ .Values.migrations.image.tag }}" - command: ["/bin/ash"] - args: - - -c - - | - migrate -path /srv/migrations -database $(cat /etc/yggdrasil/secrets/database_url.txt) up - {{- with .Values.migrations.resources }} - resources: - {{- toYaml . | nindent 12 }} - {{- end }} - volumeMounts: - - mountPath: /etc/yggdrasil/secrets - name: secrets - readOnly: true - volumes: - - name: secrets - secret: - secretName: {{ .Release.Name }} - restartPolicy: Never - backoffLimit: 0 diff --git a/deploy/templates/service.yaml b/deploy/templates/service.yaml index df60c7b..83f2df6 100644 --- a/deploy/templates/service.yaml +++ b/deploy/templates/service.yaml @@ -6,7 +6,7 @@ spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port.number }} - targetPort: {{ .Values.service.port.name }} + targetPort: {{ .Values.service.port.number }} protocol: TCP name: {{ .Values.service.port.name }} selector: diff --git a/deploy/values.staging.yaml b/deploy/values.staging.yaml index 87d2517..2fa7bba 100644 --- a/deploy/values.staging.yaml +++ b/deploy/values.staging.yaml @@ -3,17 +3,9 @@ ingress: host: staging.yggdrasil.vmdevel.cz annotations: cert-manager.io/cluster-issuer: letsencrypt-dns-production - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "https://staging.midgard.vmdevel.cz,http://localhost:5173" - nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE" replicas: 2 image: pullSecrets: - name: mareshq-gitlab-registry - -migrations: - image: - pullSecrets: - - name: mareshq-gitlab-registry diff --git a/deploy/values.test.yaml b/deploy/values.test.yaml index 1b5e060..b88b000 100644 --- a/deploy/values.test.yaml +++ b/deploy/values.test.yaml @@ -2,7 +2,8 @@ ingress: enabled: true host: yggdrasil.example.com annotations: - cert-manager.io/cluster-issuer: letsencrypt-staging + cert-manager.io/cluster-issuer: letsencrypt-prod + cert-manager.io/issuer: letsencrypt-prod replicas: 2 diff --git a/deploy/values.yaml b/deploy/values.yaml index f5afb52..d445df3 100644 --- a/deploy/values.yaml +++ b/deploy/values.yaml @@ -31,17 +31,3 @@ config: port: 8080 database: url: - -migrations: - image: - pullSecrets: [] - repository: registry.mareshq.com/hq/yggdrasil/migrations - tag: latest - - resources: - limits: - cpu: 250m - memory: 512Mi - requests: - cpu: 100m - memory: 128Mi diff --git a/internal/faker/faker.go b/internal/faker/faker.go index 00f2e53..adf7380 100644 --- a/internal/faker/faker.go +++ b/internal/faker/faker.go @@ -23,31 +23,10 @@ func NewFaker(trainingRepository training.Repository, trainingDateRepository tra func (f *Faker) GenerateFakeData() error { var trainings = []training.Training{ - { - Name: "Kubernetes v1", - Days: 1, - Description: "Kubernetes-v1", - Published: false, - Retired: true, - Pricing: []training.Price{ - { - Amount: decimal.NewFromInt(3900), - Currency: money.CZK, - Type: training.OpenTrainingPrice, - }, - { - Amount: decimal.NewFromInt(24000), - Currency: money.CZK, - Type: training.CorporateTrainingPrice, - }, - }, - }, { Name: "Kubernetes", Days: 2, Description: "Kubernetes", - Published: true, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(450), @@ -75,8 +54,6 @@ func (f *Faker) GenerateFakeData() error { Name: "Terraform", Days: 1, Description: "Terraform", - Published: true, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(200), @@ -104,8 +81,6 @@ func (f *Faker) GenerateFakeData() error { Name: "RKE2", Days: 1, Description: "RKE2", - Published: false, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(200), @@ -133,8 +108,6 @@ func (f *Faker) GenerateFakeData() error { Name: "GitHub Actions", Days: 1, Description: "GitHub Actions", - Published: false, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(200), @@ -162,8 +135,6 @@ func (f *Faker) GenerateFakeData() error { Name: "GitLab CI", Days: 1, Description: "GitLab CI", - Published: true, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(200), @@ -191,8 +162,6 @@ func (f *Faker) GenerateFakeData() error { Name: "Prometheus", Days: 2, Description: "Prometheus", - Published: true, - Retired: false, Pricing: []training.Price{ { Amount: decimal.NewFromInt(450), diff --git a/internal/server/api.gen.go b/internal/server/api.gen.go index acce8ef..0d363d9 100644 --- a/internal/server/api.gen.go +++ b/internal/server/api.gen.go @@ -1,6 +1,6 @@ // Package server provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.2.0 DO NOT EDIT. package server import ( @@ -83,7 +83,6 @@ type NewTraining struct { Description string `json:"description"` Name string `json:"name"` Pricing []TrainingPrice `json:"pricing"` - Published *bool `json:"published,omitempty"` Slug *string `json:"slug,omitempty"` } @@ -140,8 +139,6 @@ type Training struct { Id TrainingID `json:"id"` Name string `json:"name"` Pricing []TrainingPrice `json:"pricing"` - Published bool `json:"published"` - Retired bool `json:"retired"` Slug string `json:"slug"` } @@ -2434,46 +2431,45 @@ func (sh *strictHandler) ListTrainingUpcomingDates(ctx *fiber.Ctx, trainingID Tr // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xcT3PbuBX/Khi0t9Ki0s3O7uhUb5zuerqN3djuoakPEPkkIiEBBgDtaDz6JD31u7Tf", - "awcASZEUKFKSZclaneKQ4MPv/cXDw4OecMCTlDNgSuLRE06JIAkoEOZ/t4JQRtn0gig4VwpYCHB5od+E", - "IANBU0U5w6NyHNIDUTESXV5gD1M9ICUqwh5mJAE8wspN1sMCvmZUQIhHSmTgYRlEkBA93x8FTPAI/8Ff", - "wPXtW+m3oJzPvRoD3cD74H0mnA18K7F1wXoGSA04N3E2XQFI6tcrId3YEe2g1CzV46USlE3xXE8uQKac", - "STCWd8kUCEbi90JwoR8EnClgSv9J0jSmAdGo/FTwcQzJnz5LDfGpJ9vX9qsLUITG0k5f57WYH4EBMPfw", - "JXsgMQ0vWZqp/aEyGBDVIBbQPnD1V56xcF+wPnCFJhpAAWleqNro8p0AosDlpR/hawbS4EwFT0EoatWv", - "YRA2c1iKhyEhNNZvJlwkROFR/sRbHkrljcrCXBIhTEgWKzyakFhCOXrMeQyE6eHWiB1TphFnLW+4pFYK", - "yzZdtf9PlrhXYrUkvZLTCqn7Ehsff4ZA6XlWydC6jVF2HF9N8OjTaoV+gEcXITz3mmoY0zjuNg8a6G9x", - "RGROKuwn7ojIa0J7DrbjNlwGqnqgIfYsYwsEdfDL8r93aqDVekkYCpDSaTABSUlA1axmwJSpH7GHE8po", - "kiV49KZEQJmCKRgvD4mC2lfmgcPqQzKTTvLkmy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z4DDDo6v2W3hK", + "rr8d2NOT+3dr1ly97SnsrvdFtWlpg/VfqY2DXQiWCLdfEb4Bhe483Kyf8g41vjzLIvN1msxLLFM3KtqG", + "LwJo7aLtDa5fe7nBjtKsX735sKajLW5X/N5dbp27J6/Z+UjJU3FF7w24Y87J8maAi+8X9s7iws2anpnf", + "5jm6Zc+LTq/ZJ1PL0O/LIdPSwNf3xjX665w/PfIq+gncP5byavoKHF14nc2wmoq5E26V0mCTByRGITxA", + "zFPrL2ZsreF95PuxHhdxqUbfDYdDo698sibFy8JaJCJjnqlaj2DeE7/AN7+f/xYAAP//ebuDfhZYAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/internal/server/api.go b/internal/server/api.go index d375170..5f8f23a 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -85,18 +85,11 @@ func (h *APIHandlers) CreateTraining(ctx context.Context, req CreateTrainingRequ slug = *req.Body.Slug } - published := false - if req.Body.Published != nil { - published = *req.Body.Published - } - t := training.Training{ Name: req.Body.Name, Slug: slug, Days: req.Body.Days, Description: req.Body.Description, - Published: published, - Retired: false, Pricing: pricing, } @@ -125,8 +118,6 @@ func (h *APIHandlers) CreateTraining(ctx context.Context, req CreateTrainingRequ Slug: t.Slug, Days: t.Days, Description: t.Description, - Published: t.Published, - Retired: t.Retired, Pricing: responsePricing, }, nil } @@ -182,8 +173,6 @@ func (h *APIHandlers) GetTraining(ctx context.Context, req GetTrainingRequestObj Slug: t.Slug, Days: t.Days, Description: t.Description, - Published: t.Published, - Retired: t.Retired, Pricing: pricing, }, nil } @@ -219,8 +208,6 @@ func (h *APIHandlers) GetTrainingBySlug(ctx context.Context, req GetTrainingBySl Slug: t.Slug, Days: t.Days, Description: t.Description, - Published: t.Published, - Retired: t.Retired, Pricing: pricing, }, nil } @@ -250,19 +237,12 @@ func (h *APIHandlers) UpdateTraining(ctx context.Context, req UpdateTrainingRequ slug = *req.Body.Slug } - published := false - if req.Body.Published != nil { - published = *req.Body.Published - } - t := training.Training{ ID: req.TrainingID, Name: req.Body.Name, Slug: slug, Days: req.Body.Days, Description: req.Body.Description, - Published: published, - Retired: false, Pricing: pricing, } @@ -282,8 +262,6 @@ func (h *APIHandlers) UpdateTraining(ctx context.Context, req UpdateTrainingRequ Slug: t.Slug, Days: t.Days, Description: t.Description, - Published: t.Published, - Retired: t.Retired, }, nil } diff --git a/internal/server/server_test.go b/internal/server/server_test.go index e7fd38b..73e0634 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -172,8 +172,6 @@ func TestServer(t *testing.T) { assert.Equal(t, tr.Name, trr.Name) assert.Equal(t, tr.ID, trr.Id) assert.Equal(t, tr.Slug, trr.Slug) - assert.Equal(t, false, trr.Published) - assert.Equal(t, false, trr.Retired) }) t.Run("List all trainings", func(t *testing.T) { @@ -204,8 +202,6 @@ func TestServer(t *testing.T) { assert.NotEmpty(t, trr.Slug) assert.NotEmpty(t, trr.Description) assert.NotEmpty(t, trr.Days) - assert.False(t, trr.Published) - assert.False(t, trr.Retired) } }) @@ -250,8 +246,6 @@ func TestServer(t *testing.T) { assert.NoError(t, err, "error unmarshalling response") assert.Equal(t, updTr.Name, trr.Name) assert.Equal(t, updatedSlug, trr.Slug) - assert.Equal(t, false, trr.Published) - assert.Equal(t, false, trr.Retired) }) t.Run("Delete training", func(t *testing.T) { diff --git a/pkg/training/model.go b/pkg/training/model.go index cd1c548..adaa5ea 100644 --- a/pkg/training/model.go +++ b/pkg/training/model.go @@ -14,8 +14,6 @@ type Training struct { Slug string Days int8 Description string - Published bool - Retired bool Pricing []Price `db:"-"` } diff --git a/pkg/training/postgres_repository.go b/pkg/training/postgres_repository.go index 233bd10..5300d4b 100644 --- a/pkg/training/postgres_repository.go +++ b/pkg/training/postgres_repository.go @@ -30,10 +30,10 @@ func (r *PostgresTrainingRepository) Create(training *Training) error { } queryErr := tx.QueryRow(ctx, ` - INSERT INTO training.trainings (name, slug, description, days, published) - VALUES ($1, $2, $3, $4, $5) + INSERT INTO training.trainings (name, slug, description, days) + VALUES ($1, $2, $3, $4) RETURNING id - `, training.Name, training.Slug, training.Description, training.Days, training.Published).Scan(&training.ID) + `, training.Name, training.Slug, training.Description, training.Days).Scan(&training.ID) if queryErr != nil { return queryErr } @@ -77,10 +77,10 @@ func (r *PostgresTrainingRepository) FindByID(id ID) (*Training, error) { var training Training err := r.pg.QueryRow(ctx, ` - SELECT id, name, slug, description, days, published, retired + SELECT id, name, slug, description, days FROM training.trainings WHERE id = $1 - `, id).Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days, &training.Published, &training.Retired) + `, id).Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days) if err != nil { return nil, err @@ -122,10 +122,10 @@ func (r *PostgresTrainingRepository) FindBySlug(slug string) (*Training, error) var training Training err := r.pg.QueryRow(ctx, ` - SELECT id, name, slug, description, days, published, retired + SELECT id, name, slug, description, days FROM training.trainings WHERE slug = $1 - `, slug).Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days, &training.Published, &training.Retired) + `, slug).Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (r *PostgresTrainingRepository) FindAll() ([]Training, error) { trainings, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (Training, error) { var training Training - scanErr := row.Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days, &training.Published, &training.Retired) + scanErr := row.Scan(&training.ID, &training.Name, &training.Slug, &training.Description, &training.Days) if scanErr != nil { return Training{}, scanErr } @@ -217,9 +217,9 @@ func (r *PostgresTrainingRepository) Update(training *Training) error { _, err = tx.Exec(ctx, ` UPDATE training.trainings - SET name = $1, slug = $2, description = $3, days = $4, published = $5, retired = $6 + SET name = $1, slug = $2, description = $3, days = $4 WHERE id = $4 - `, training.Name, training.Slug, training.Description, training.Days, training.ID, training.Published, training.Retired) + `, training.Name, training.Slug, training.Description, training.Days, training.ID) if err != nil { return err