Compare commits
No commits in common. "5e1149d1ff37bbdac6d604161644e1c386e885d4" and "d04359aa58f54d6e84154b13dddb1cf0d6e14b7c" have entirely different histories.
5e1149d1ff
...
d04359aa58
17 changed files with 54 additions and 208 deletions
|
|
@ -78,7 +78,6 @@ deploy:staging:
|
||||||
api ./deploy \
|
api ./deploy \
|
||||||
--values deploy/values.staging.yaml \
|
--values deploy/values.staging.yaml \
|
||||||
--set image.tag=$TAG \
|
--set image.tag=$TAG \
|
||||||
--set migrations.image.tag=$TAG \
|
|
||||||
--set imageCredentials.username=$REGISTRY_USERNAME \
|
--set imageCredentials.username=$REGISTRY_USERNAME \
|
||||||
--set imageCredentials.password=$REGISTRY_PASSWORD \
|
--set imageCredentials.password=$REGISTRY_PASSWORD \
|
||||||
--set config.database.url=$DATABASE_URL
|
--set config.database.url=$DATABASE_URL
|
||||||
|
|
|
||||||
5
Makefile
5
Makefile
|
|
@ -49,8 +49,3 @@ build-docker-httpserver:
|
||||||
.PHONY: build-docker-migrations
|
.PHONY: build-docker-migrations
|
||||||
build-docker-migrations:
|
build-docker-migrations:
|
||||||
docker build -t yggdrasil-migrations -f ./build/package/migrations/Dockerfile .
|
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
|
|
||||||
|
|
|
||||||
|
|
@ -560,9 +560,6 @@ components:
|
||||||
$ref: "#/components/schemas/TrainingPrice"
|
$ref: "#/components/schemas/TrainingPrice"
|
||||||
slug:
|
slug:
|
||||||
type: string
|
type: string
|
||||||
published:
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- days
|
- days
|
||||||
|
|
@ -576,13 +573,9 @@ components:
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
$ref: "#/components/schemas/TrainingID"
|
$ref: "#/components/schemas/TrainingID"
|
||||||
retired:
|
|
||||||
type: boolean
|
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- slug
|
- slug
|
||||||
- published
|
|
||||||
- retired
|
|
||||||
|
|
||||||
TrainingID:
|
TrainingID:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
ALTER TABLE training.trainings
|
|
||||||
DROP COLUMN published,
|
|
||||||
DROP COLUMN retired;
|
|
||||||
|
|
@ -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;
|
|
||||||
|
|
@ -34,7 +34,7 @@ spec:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: httpserver
|
- name: {{ .Chart.Name }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -6,7 +6,7 @@ spec:
|
||||||
type: {{ .Values.service.type }}
|
type: {{ .Values.service.type }}
|
||||||
ports:
|
ports:
|
||||||
- port: {{ .Values.service.port.number }}
|
- port: {{ .Values.service.port.number }}
|
||||||
targetPort: {{ .Values.service.port.name }}
|
targetPort: {{ .Values.service.port.number }}
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
name: {{ .Values.service.port.name }}
|
name: {{ .Values.service.port.name }}
|
||||||
selector:
|
selector:
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,9 @@ ingress:
|
||||||
host: staging.yggdrasil.vmdevel.cz
|
host: staging.yggdrasil.vmdevel.cz
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-dns-production
|
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
|
replicas: 2
|
||||||
|
|
||||||
image:
|
image:
|
||||||
pullSecrets:
|
pullSecrets:
|
||||||
- name: mareshq-gitlab-registry
|
- name: mareshq-gitlab-registry
|
||||||
|
|
||||||
migrations:
|
|
||||||
image:
|
|
||||||
pullSecrets:
|
|
||||||
- name: mareshq-gitlab-registry
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
host: yggdrasil.example.com
|
host: yggdrasil.example.com
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-staging
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
cert-manager.io/issuer: letsencrypt-prod
|
||||||
|
|
||||||
replicas: 2
|
replicas: 2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,3 @@ config:
|
||||||
port: 8080
|
port: 8080
|
||||||
database:
|
database:
|
||||||
url:
|
url:
|
||||||
|
|
||||||
migrations:
|
|
||||||
image:
|
|
||||||
pullSecrets: []
|
|
||||||
repository: registry.mareshq.com/hq/yggdrasil/migrations
|
|
||||||
tag: latest
|
|
||||||
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 250m
|
|
||||||
memory: 512Mi
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 128Mi
|
|
||||||
|
|
|
||||||
|
|
@ -23,31 +23,10 @@ func NewFaker(trainingRepository training.Repository, trainingDateRepository tra
|
||||||
|
|
||||||
func (f *Faker) GenerateFakeData() error {
|
func (f *Faker) GenerateFakeData() error {
|
||||||
var trainings = []training.Training{
|
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",
|
Name: "Kubernetes",
|
||||||
Days: 2,
|
Days: 2,
|
||||||
Description: "Kubernetes",
|
Description: "Kubernetes",
|
||||||
Published: true,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(450),
|
Amount: decimal.NewFromInt(450),
|
||||||
|
|
@ -75,8 +54,6 @@ func (f *Faker) GenerateFakeData() error {
|
||||||
Name: "Terraform",
|
Name: "Terraform",
|
||||||
Days: 1,
|
Days: 1,
|
||||||
Description: "Terraform",
|
Description: "Terraform",
|
||||||
Published: true,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(200),
|
Amount: decimal.NewFromInt(200),
|
||||||
|
|
@ -104,8 +81,6 @@ func (f *Faker) GenerateFakeData() error {
|
||||||
Name: "RKE2",
|
Name: "RKE2",
|
||||||
Days: 1,
|
Days: 1,
|
||||||
Description: "RKE2",
|
Description: "RKE2",
|
||||||
Published: false,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(200),
|
Amount: decimal.NewFromInt(200),
|
||||||
|
|
@ -133,8 +108,6 @@ func (f *Faker) GenerateFakeData() error {
|
||||||
Name: "GitHub Actions",
|
Name: "GitHub Actions",
|
||||||
Days: 1,
|
Days: 1,
|
||||||
Description: "GitHub Actions",
|
Description: "GitHub Actions",
|
||||||
Published: false,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(200),
|
Amount: decimal.NewFromInt(200),
|
||||||
|
|
@ -162,8 +135,6 @@ func (f *Faker) GenerateFakeData() error {
|
||||||
Name: "GitLab CI",
|
Name: "GitLab CI",
|
||||||
Days: 1,
|
Days: 1,
|
||||||
Description: "GitLab CI",
|
Description: "GitLab CI",
|
||||||
Published: true,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(200),
|
Amount: decimal.NewFromInt(200),
|
||||||
|
|
@ -191,8 +162,6 @@ func (f *Faker) GenerateFakeData() error {
|
||||||
Name: "Prometheus",
|
Name: "Prometheus",
|
||||||
Days: 2,
|
Days: 2,
|
||||||
Description: "Prometheus",
|
Description: "Prometheus",
|
||||||
Published: true,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: []training.Price{
|
Pricing: []training.Price{
|
||||||
{
|
{
|
||||||
Amount: decimal.NewFromInt(450),
|
Amount: decimal.NewFromInt(450),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Package server provides primitives to interact with the openapi HTTP API.
|
// 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
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -83,7 +83,6 @@ type NewTraining struct {
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Pricing []TrainingPrice `json:"pricing"`
|
Pricing []TrainingPrice `json:"pricing"`
|
||||||
Published *bool `json:"published,omitempty"`
|
|
||||||
Slug *string `json:"slug,omitempty"`
|
Slug *string `json:"slug,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,8 +139,6 @@ type Training struct {
|
||||||
Id TrainingID `json:"id"`
|
Id TrainingID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Pricing []TrainingPrice `json:"pricing"`
|
Pricing []TrainingPrice `json:"pricing"`
|
||||||
Published bool `json:"published"`
|
|
||||||
Retired bool `json:"retired"`
|
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2434,46 +2431,45 @@ func (sh *strictHandler) ListTrainingUpcomingDates(ctx *fiber.Ctx, trainingID Tr
|
||||||
// Base64 encoded, gzipped, json marshaled Swagger object
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
||||||
var swaggerSpec = []string{
|
var swaggerSpec = []string{
|
||||||
|
|
||||||
"H4sIAAAAAAAC/+xcT3PbuBX/Khi0t9Ki0s3O7uhUb5zuerqN3djuoakPEPkkIiEBBgDtaDz6JD31u7Tf",
|
"H4sIAAAAAAAC/+xc3XLbuBV+FQzau9Ki0s3O7uiqXjvd9XQbu/7pRVNfQOSRiIQEGAC0o/HoSXrVd2nf",
|
||||||
"awcASZEUKFKSZclaneKQ4MPv/cXDw4OecMCTlDNgSuLRE06JIAkoEOZ/t4JQRtn0gig4VwpYCHB5od+E",
|
"awcASZEUKFKSZcle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qUbfDYdDo698sibFy8JaJCJjnqlaj2DeE7/AN7+f/xYAAP//ebuDfhZYAAA=",
|
||||||
"rUcw74lf4Jvfz38LAAD//+HPwchvWQAA",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSwagger returns the content of the embedded swagger specification file
|
// GetSwagger returns the content of the embedded swagger specification file
|
||||||
|
|
|
||||||
|
|
@ -85,18 +85,11 @@ func (h *APIHandlers) CreateTraining(ctx context.Context, req CreateTrainingRequ
|
||||||
slug = *req.Body.Slug
|
slug = *req.Body.Slug
|
||||||
}
|
}
|
||||||
|
|
||||||
published := false
|
|
||||||
if req.Body.Published != nil {
|
|
||||||
published = *req.Body.Published
|
|
||||||
}
|
|
||||||
|
|
||||||
t := training.Training{
|
t := training.Training{
|
||||||
Name: req.Body.Name,
|
Name: req.Body.Name,
|
||||||
Slug: slug,
|
Slug: slug,
|
||||||
Days: req.Body.Days,
|
Days: req.Body.Days,
|
||||||
Description: req.Body.Description,
|
Description: req.Body.Description,
|
||||||
Published: published,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: pricing,
|
Pricing: pricing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,8 +118,6 @@ func (h *APIHandlers) CreateTraining(ctx context.Context, req CreateTrainingRequ
|
||||||
Slug: t.Slug,
|
Slug: t.Slug,
|
||||||
Days: t.Days,
|
Days: t.Days,
|
||||||
Description: t.Description,
|
Description: t.Description,
|
||||||
Published: t.Published,
|
|
||||||
Retired: t.Retired,
|
|
||||||
Pricing: responsePricing,
|
Pricing: responsePricing,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +173,6 @@ func (h *APIHandlers) GetTraining(ctx context.Context, req GetTrainingRequestObj
|
||||||
Slug: t.Slug,
|
Slug: t.Slug,
|
||||||
Days: t.Days,
|
Days: t.Days,
|
||||||
Description: t.Description,
|
Description: t.Description,
|
||||||
Published: t.Published,
|
|
||||||
Retired: t.Retired,
|
|
||||||
Pricing: pricing,
|
Pricing: pricing,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -219,8 +208,6 @@ func (h *APIHandlers) GetTrainingBySlug(ctx context.Context, req GetTrainingBySl
|
||||||
Slug: t.Slug,
|
Slug: t.Slug,
|
||||||
Days: t.Days,
|
Days: t.Days,
|
||||||
Description: t.Description,
|
Description: t.Description,
|
||||||
Published: t.Published,
|
|
||||||
Retired: t.Retired,
|
|
||||||
Pricing: pricing,
|
Pricing: pricing,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -250,19 +237,12 @@ func (h *APIHandlers) UpdateTraining(ctx context.Context, req UpdateTrainingRequ
|
||||||
slug = *req.Body.Slug
|
slug = *req.Body.Slug
|
||||||
}
|
}
|
||||||
|
|
||||||
published := false
|
|
||||||
if req.Body.Published != nil {
|
|
||||||
published = *req.Body.Published
|
|
||||||
}
|
|
||||||
|
|
||||||
t := training.Training{
|
t := training.Training{
|
||||||
ID: req.TrainingID,
|
ID: req.TrainingID,
|
||||||
Name: req.Body.Name,
|
Name: req.Body.Name,
|
||||||
Slug: slug,
|
Slug: slug,
|
||||||
Days: req.Body.Days,
|
Days: req.Body.Days,
|
||||||
Description: req.Body.Description,
|
Description: req.Body.Description,
|
||||||
Published: published,
|
|
||||||
Retired: false,
|
|
||||||
Pricing: pricing,
|
Pricing: pricing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,8 +262,6 @@ func (h *APIHandlers) UpdateTraining(ctx context.Context, req UpdateTrainingRequ
|
||||||
Slug: t.Slug,
|
Slug: t.Slug,
|
||||||
Days: t.Days,
|
Days: t.Days,
|
||||||
Description: t.Description,
|
Description: t.Description,
|
||||||
Published: t.Published,
|
|
||||||
Retired: t.Retired,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,8 +172,6 @@ func TestServer(t *testing.T) {
|
||||||
assert.Equal(t, tr.Name, trr.Name)
|
assert.Equal(t, tr.Name, trr.Name)
|
||||||
assert.Equal(t, tr.ID, trr.Id)
|
assert.Equal(t, tr.ID, trr.Id)
|
||||||
assert.Equal(t, tr.Slug, trr.Slug)
|
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) {
|
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.Slug)
|
||||||
assert.NotEmpty(t, trr.Description)
|
assert.NotEmpty(t, trr.Description)
|
||||||
assert.NotEmpty(t, trr.Days)
|
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.NoError(t, err, "error unmarshalling response")
|
||||||
assert.Equal(t, updTr.Name, trr.Name)
|
assert.Equal(t, updTr.Name, trr.Name)
|
||||||
assert.Equal(t, updatedSlug, trr.Slug)
|
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) {
|
t.Run("Delete training", func(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ type Training struct {
|
||||||
Slug string
|
Slug string
|
||||||
Days int8
|
Days int8
|
||||||
Description string
|
Description string
|
||||||
Published bool
|
|
||||||
Retired bool
|
|
||||||
Pricing []Price `db:"-"`
|
Pricing []Price `db:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ func (r *PostgresTrainingRepository) Create(training *Training) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
queryErr := tx.QueryRow(ctx, `
|
queryErr := tx.QueryRow(ctx, `
|
||||||
INSERT INTO training.trainings (name, slug, description, days, published)
|
INSERT INTO training.trainings (name, slug, description, days)
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
VALUES ($1, $2, $3, $4)
|
||||||
RETURNING id
|
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 {
|
if queryErr != nil {
|
||||||
return queryErr
|
return queryErr
|
||||||
}
|
}
|
||||||
|
|
@ -77,10 +77,10 @@ func (r *PostgresTrainingRepository) FindByID(id ID) (*Training, error) {
|
||||||
|
|
||||||
var training Training
|
var training Training
|
||||||
err := r.pg.QueryRow(ctx, `
|
err := r.pg.QueryRow(ctx, `
|
||||||
SELECT id, name, slug, description, days, published, retired
|
SELECT id, name, slug, description, days
|
||||||
FROM training.trainings
|
FROM training.trainings
|
||||||
WHERE id = $1
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -122,10 +122,10 @@ func (r *PostgresTrainingRepository) FindBySlug(slug string) (*Training, error)
|
||||||
|
|
||||||
var training Training
|
var training Training
|
||||||
err := r.pg.QueryRow(ctx, `
|
err := r.pg.QueryRow(ctx, `
|
||||||
SELECT id, name, slug, description, days, published, retired
|
SELECT id, name, slug, description, days
|
||||||
FROM training.trainings
|
FROM training.trainings
|
||||||
WHERE slug = $1
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -172,7 +172,7 @@ func (r *PostgresTrainingRepository) FindAll() ([]Training, error) {
|
||||||
|
|
||||||
trainings, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (Training, error) {
|
trainings, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (Training, error) {
|
||||||
var training Training
|
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 {
|
if scanErr != nil {
|
||||||
return Training{}, scanErr
|
return Training{}, scanErr
|
||||||
}
|
}
|
||||||
|
|
@ -217,9 +217,9 @@ func (r *PostgresTrainingRepository) Update(training *Training) error {
|
||||||
|
|
||||||
_, err = tx.Exec(ctx, `
|
_, err = tx.Exec(ctx, `
|
||||||
UPDATE training.trainings
|
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
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Reference in a new issue