Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.23.0 update #3

Merged
merged 27 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3932e05
refactor: default k8up retention is confusing
rocketeerbkw Sep 29, 2024
b47599e
Merge pull request #372 from uselagoon/clearer-k8up-prune-defaults
tobybellwood Oct 2, 2024
05887c3
refactor: add tests for `LAGOON_BACKUP_PROD_SCHEDULE` (#374)
rocketeerbkw Oct 3, 2024
dde6b68
build: copy required go components to reduce cache invalidation (#373)
shreddedbacon Oct 4, 2024
db3dd55
feat: allow documentation url to be changed (#369)
shreddedbacon Oct 4, 2024
50c4ebf
chore: expunge fastly api secrets templating (#367)
shreddedbacon Oct 4, 2024
ac5c193
chore: add featureflag to change default buildkit setting (#380)
shreddedbacon Oct 13, 2024
d039fc9
fix: check secret exists before trying to read or delete it (#384)
shreddedbacon Oct 21, 2024
b899eb6
feat: variable replacement support for lagoon.base.image label (#378)
bomoko Oct 21, 2024
8af640d
fix: lagoon.persistent.name override checks (#383)
shreddedbacon Oct 22, 2024
a714b9f
chore: fix name of feature to podspreadconstraints (#387)
shreddedbacon Oct 25, 2024
d93d6fb
fix: default fastly watch status to true if not provided in variable …
shreddedbacon Oct 25, 2024
f54ee2e
refactor: move pre-rollout tasks to before templating/rollouts (#377)
shreddedbacon Oct 28, 2024
95789b8
feat: new basic-single service type (#363)
shreddedbacon Oct 30, 2024
4e37875
feat: implement feature to fail builds on docker-compose yaml errors …
shreddedbacon Oct 30, 2024
5befa26
feat: add valkey service type
shreddedbacon Oct 21, 2024
72bcaf0
Merge pull request #385 from uselagoon/valkey-service-type
tobybellwood Nov 3, 2024
3668bc0
fix: add resources limits to linked container as required (#393)
shreddedbacon Dec 4, 2024
f4365cb
refactor: consolidate template functions (#401)
shreddedbacon Dec 15, 2024
e9f8dc4
fix: package name (#402)
shreddedbacon Dec 15, 2024
9b3412b
test: add polysite cronjob tests (#404)
shreddedbacon Dec 22, 2024
67bb279
chore: remove slow capabilities check
shreddedbacon Nov 25, 2024
f00995e
Merge pull request #396 from uselagoon/remove-capabilities-check
tobybellwood Dec 26, 2024
f914162
feat(fix): set runasuser podsecuritycontext for backup schedules
shreddedbacon Dec 15, 2024
a729ddc
Merge pull request #403 from uselagoon/backup-podsecuritycontext
tobybellwood Dec 29, 2024
c9226fe
Merge tag 'core-v2.22.0' into 2.22.0-update
MaxCWhitehead Feb 3, 2025
70e484d
Merge tag 'core-v2.23.0' into 2.23.0-update
MaxCWhitehead Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ RUN go install github.com/a8m/envsubst/cmd/[email protected]

WORKDIR /app

COPY . ./
COPY go.mod go.mod
COPY go.sum go.sum

COPY main.go main.go
COPY cmd/ cmd/
COPY internal/ internal/

ARG BUILD
ARG GO_VER
Expand Down Expand Up @@ -100,10 +105,9 @@ COPY legacy/build-deploy-docker-compose.sh /kubectl-build-deploy/build-deploy-do

COPY legacy/scripts /kubectl-build-deploy/scripts

COPY legacy/helmcharts /kubectl-build-deploy/helmcharts

ENV DBAAS_OPERATOR_HTTP=dbaas.lagoon.svc:5000
ENV DOCKER_HOST=docker-host.lagoon.svc
ENV LAGOON_FEATURE_FLAG_DEFAULT_DOCUMENTATION_URL=https://docs.lagoon.sh

RUN architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& curl -sSL https://github.com/uselagoon/lagoon-linter/releases/download/v0.8.0/lagoon-linter_0.8.0_linux_${architecture}.tar.gz \
Expand Down
7 changes: 1 addition & 6 deletions cmd/config_fastly.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ func FastlyConfigGeneration(debug bool, domain string) (lagoon.Fastly, error) {
if err != nil {
return lagoon.Fastly{}, fmt.Errorf("error reading fastly-cache-no-cache-id flag: %v", err)
}
fastlyAPISecretPrefix, err := rootCmd.PersistentFlags().GetString("fastly-api-secret-prefix")
if err != nil {
return lagoon.Fastly{}, fmt.Errorf("error reading fastly-api-secret-prefix flag: %v", err)
}
fastlyServiceID, err := rootCmd.PersistentFlags().GetString("fastly-service-id")
if err != nil {
return lagoon.Fastly{}, fmt.Errorf("error reading fastly-service-id flag: %v", err)
Expand All @@ -55,7 +51,6 @@ func FastlyConfigGeneration(debug bool, domain string) (lagoon.Fastly, error) {

fastlyCacheNoCahce = helpers.GetEnv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", fastlyCacheNoCahce, debug)
fastlyServiceID = helpers.GetEnv("ROUTE_FASTLY_SERVICE_ID", fastlyServiceID, debug)
fastlyAPISecretPrefix = helpers.GetEnv("FASTLY_API_SECRET_PREFIX", fastlyAPISecretPrefix, debug)

// get the project and environment variables
projectVariables = helpers.GetEnv("LAGOON_PROJECT_VARIABLES", projectVariables, debug)
Expand All @@ -70,7 +65,7 @@ func FastlyConfigGeneration(debug bool, domain string) (lagoon.Fastly, error) {

// generate the fastly configuration from the provided flags/variables
f := &lagoon.Fastly{}
err = lagoon.GenerateFastlyConfiguration(f, fastlyCacheNoCahce, fastlyServiceID, domain, fastlyAPISecretPrefix, lagoonEnvVars)
err = lagoon.GenerateFastlyConfiguration(f, fastlyCacheNoCahce, fastlyServiceID, domain, lagoonEnvVars)
if err != nil {
return lagoon.Fastly{}, err
}
Expand Down
51 changes: 4 additions & 47 deletions cmd/config_fastly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestGenerateFastlyConfig(t *testing.T) {
cacheNoCache string
serviceID string
domain string
secretPrefix string
}
tests := []struct {
name string
Expand All @@ -31,12 +30,10 @@ func TestGenerateFastlyConfig(t *testing.T) {
cacheNoCache: "",
serviceID: "",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "service-id",
APISecretName: "",
Watch: true,
ServiceID: "service-id",
Watch: true,
},
},
{
Expand All @@ -47,44 +44,10 @@ func TestGenerateFastlyConfig(t *testing.T) {
cacheNoCache: "",
serviceID: "",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "service-id",
APISecretName: "",
Watch: true,
},
},
{
name: "test3 check LAGOON_FASTLY_SERVICE_ID with secret",
args: args{
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true:secret","scope":"global"}]`,
envVars: `[]`,
cacheNoCache: "",
serviceID: "",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "service-id",
APISecretName: "fastly-api-secret",
Watch: true,
},
},
{
name: "test4 check LAGOON_FASTLY_SERVICE_IDS with secret",
args: args{
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:secret","scope":"global"}]`,
envVars: `[]`,
cacheNoCache: "",
serviceID: "",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "service-id",
APISecretName: "fastly-api-secret",
Watch: true,
ServiceID: "service-id",
Watch: true,
},
},
{
Expand All @@ -95,7 +58,6 @@ func TestGenerateFastlyConfig(t *testing.T) {
cacheNoCache: "",
serviceID: "dedicated-service-id",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "dedicated-service-id",
Expand All @@ -110,7 +72,6 @@ func TestGenerateFastlyConfig(t *testing.T) {
cacheNoCache: "",
serviceID: "dedicated-service-id",
domain: "example.com",
secretPrefix: "fastly-api-",
},
want: lagoon.Fastly{
ServiceID: "service-id",
Expand All @@ -130,10 +91,6 @@ func TestGenerateFastlyConfig(t *testing.T) {
if err != nil {
t.Errorf("%v", err)
}
err = os.Setenv("FASTLY_API_SECRET_PREFIX", tt.args.secretPrefix)
if err != nil {
t.Errorf("%v", err)
}
err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars)
if err != nil {
t.Errorf("%v", err)
Expand Down
62 changes: 59 additions & 3 deletions cmd/identify_imagebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"testing"

"github.com/andreyvit/diff"
"github.com/uselagoon/build-deploy-tool/internal/dbaasclient"
"github.com/uselagoon/build-deploy-tool/internal/generator"
"github.com/uselagoon/build-deploy-tool/internal/helpers"
Expand Down Expand Up @@ -752,6 +753,61 @@ func TestImageBuildConfigurationIdentification(t *testing.T) {
},
},
},
{
name: "test12 Force Pull Base Images with variable replacement",
args: testdata.GetSeedData(
testdata.TestData{
Namespace: "example-project-main",
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
LagoonYAML: "internal/testdata/basic/lagoon.forcebaseimagepull-2.yml",
ProjectVariables: []lagoon.EnvironmentVariable{
{
Name: "BASE_IMAGE_TAG",
Value: "my-tag",
Scope: "build",
},
{
Name: "BASE_IMAGE_REPO",
Value: "my-repo",
Scope: "build",
},
},
}, true),
want: imageBuild{
BuildKit: helpers.BoolPtr(true),
BuildArguments: map[string]string{
"BASE_IMAGE_TAG": "my-tag",
"BASE_IMAGE_REPO": "my-repo",
"LAGOON_BUILD_NAME": "lagoon-build-abcdefg",
"LAGOON_PROJECT": "example-project",
"LAGOON_ENVIRONMENT": "main",
"LAGOON_ENVIRONMENT_TYPE": "production",
"LAGOON_BUILD_TYPE": "branch",
"LAGOON_GIT_SOURCE_REPOSITORY": "ssh://[email protected]/lagoon-demo.git",
"LAGOON_KUBERNETES": "remote-cluster1",
"LAGOON_GIT_SHA": "abcdefg123456",
"LAGOON_GIT_BRANCH": "main",
"NODE_IMAGE": "example-project-main-node",
"LAGOON_SSH_PRIVATE_KEY": "-----BEGIN OPENSSH PRIVATE KEY-----\nthisisafakekey\n-----END OPENSSH PRIVATE KEY-----",
},
ForcePullImages: []string{
"registry.com/my-repo/imagename:my-tag",
},
Images: []imageBuilds{
{
Name: "node",
ImageBuild: generator.ImageBuild{
BuildImage: "harbor.example/example-project/main/node:latest",
Context: "internal/testdata/basic/docker",
DockerFile: "basic.dockerfile",
TemporaryImage: "example-project-main-node",
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -788,10 +844,10 @@ func TestImageBuildConfigurationIdentification(t *testing.T) {
t.Errorf("%v", err)
}

oJ, _ := json.Marshal(out)
wJ, _ := json.Marshal(tt.want)
oJ, _ := json.MarshalIndent(out, "", " ")
wJ, _ := json.MarshalIndent(tt.want, "", " ")
if string(oJ) != string(wJ) {
t.Errorf("returned output %v doesn't match want %v", string(oJ), string(wJ))
t.Errorf("ImageBuildConfigurationIdentification() = \n%v", diff.LineDiff(string(oJ), string(wJ)))
}
t.Cleanup(func() {
helpers.UnsetEnvVars(tt.vars)
Expand Down
2 changes: 1 addition & 1 deletion cmd/identify_lagoonservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/spf13/cobra"
generator "github.com/uselagoon/build-deploy-tool/internal/generator"
servicestemplates "github.com/uselagoon/build-deploy-tool/internal/templating/services"
servicestemplates "github.com/uselagoon/build-deploy-tool/internal/templating"
)

type identifyServices struct {
Expand Down
9 changes: 6 additions & 3 deletions cmd/template_autogen_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
generator "github.com/uselagoon/build-deploy-tool/internal/generator"
"github.com/uselagoon/build-deploy-tool/internal/helpers"
ingresstemplate "github.com/uselagoon/build-deploy-tool/internal/templating/ingress"
servicestemplates "github.com/uselagoon/build-deploy-tool/internal/templating"
)

var autogenRouteGeneration = &cobra.Command{
Expand All @@ -31,14 +31,17 @@ func AutogeneratedIngressGeneration(g generator.GeneratorInput) error {
return err
}
savedTemplates := g.SavedTemplatesPath

// generate the templates
for _, route := range lagoonBuild.AutogeneratedRoutes.Routes {
// autogenerated routes use the `servicename` as the name of the ingress resource, use `IngressName` in routev2 to handle this
if g.Debug {
fmt.Printf("Templating autogenerated ingress manifest for %s to %s\n", route.Domain, fmt.Sprintf("%s/%s.yaml", savedTemplates, route.LagoonService))
}
templateYAML, err := ingresstemplate.GenerateIngressTemplate(route, *lagoonBuild.BuildValues)
ingress, err := servicestemplates.GenerateIngressTemplate(route, *lagoonBuild.BuildValues)
if err != nil {
return fmt.Errorf("couldn't generate template: %v", err)
}
templateYAML, err := servicestemplates.TemplateIngress(ingress)
if err != nil {
return fmt.Errorf("couldn't generate template: %v", err)
}
Expand Down
50 changes: 27 additions & 23 deletions cmd/template_autogen_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,57 +187,61 @@ func TestAutogeneratedIngressGeneration(t *testing.T) {
want: "internal/testdata/node/autogen-templates/ingress-7",
},
{
name: "test10 autogenerated routes with fastly and specific secret",
name: "test11 autogenerated route development environment",
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
EnvironmentType: "development",
LagoonYAML: "internal/testdata/node/lagoon.yml",
ProjectVariables: []lagoon.EnvironmentVariable{
{
Name: "LAGOON_FASTLY_SERVICE_ID",
Value: "service-id:true:secretname",
Scope: "build",
},
{
Name: "LAGOON_FASTLY_AUTOGENERATED",
Value: "enabled",
Scope: "build",
},
},
}, true),
templatePath: "testoutput",
want: "internal/testdata/node/autogen-templates/ingress-8",
want: "internal/testdata/node/autogen-templates/ingress-9",
},
{
name: "test11 autogenerated route development environment",
name: "test12 autogenerated route development environment - no insecure redirect",
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
EnvironmentType: "development",
LagoonYAML: "internal/testdata/node/lagoon.yml",
LagoonYAML: "internal/testdata/node/lagoon.autogen-5.yml",
}, true),
templatePath: "testoutput",
want: "internal/testdata/node/autogen-templates/ingress-9",
want: "internal/testdata/node/autogen-templates/ingress-10",
},
{
name: "test12 autogenerated route development environment - no insecure redirect",
name: "test-development-service-type-override-a",
description: `this test should fail because the replacement type has no persistent label in the associated docker-compose file
realistically, this is not something that should be done on an already deployed service due to changing
service types not being properly supported`,
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
EnvironmentType: "development",
LagoonYAML: "internal/testdata/node/lagoon.autogen-5.yml",
LagoonYAML: "internal/testdata/node/lagoon.yml",
ProjectVariables: []lagoon.EnvironmentVariable{
{
Name: "LAGOON_SERVICE_TYPES",
Value: "node:node-persistent",
Scope: "build",
},
},
}, true),
templatePath: "testoutput",
want: "internal/testdata/node/autogen-templates/ingress-10",
emptyDir: true,
want: "",
wantErr: true,
},
{
name: "test13 autogenerated route development service type override",
name: "test-development-service-type-override-b",
description: `this test should pass because the replacement service type is just a basic type
realistically, this is not something that should be done on an already deployed service due to changing
service types not being properly supported`,
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
Expand All @@ -248,13 +252,13 @@ func TestAutogeneratedIngressGeneration(t *testing.T) {
ProjectVariables: []lagoon.EnvironmentVariable{
{
Name: "LAGOON_SERVICE_TYPES",
Value: "node:node-persistent",
Value: "node:basic",
Scope: "build",
},
},
}, true),
templatePath: "testoutput",
want: "internal/testdata/node/autogen-templates/ingress-11",
want: "internal/testdata/node/autogen-templates/test-development-service-type-override",
},
{
name: "test14 autogenerated route development no service type override",
Expand Down
Loading
Loading