Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion integration/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,5 @@ func TestSidecarContainerLog(t *testing.T) {

sort.Strings(lines)
assert.Equal(t, "line 1-3\nline 1-4", strings.Join(lines, "\n"))
assert.Len(t, strings.Split(replicas[1].Name, "."), 3)
assert.Len(t, strings.Split(replicas[1].Name, ":"), 2)
}
7 changes: 6 additions & 1 deletion pkg/buildclient/filesyncclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"strings"

"github.com/moby/buildkit/session/filesync"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -125,7 +126,11 @@ func prepareSyncedDirs(localDirs map[string]string, dirNames []string, followPat
}
f := filepath.Join(d, followPath)
if _, err := os.Stat(f); os.IsNotExist(err) {
err := os.MkdirAll(f, 0755)
if strings.Contains(f, "*") || strings.Contains(f, "?") {
err = nil
} else {
err = os.MkdirAll(f, 0755)
}
if err != nil {
return nil, err
}
Expand Down
17 changes: 13 additions & 4 deletions pkg/controller/appdefinition/acorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func toAcorns(appInstance *v1.AppInstance, tag name.Reference, pullSecrets *Pull
Labels: service.Labels,
Annotations: service.Annotations,
Image: service.Image,
Build: service.Build,
DeployArgs: service.ServiceArgs,
Environment: service.Environment,
Secrets: service.Secrets,
Expand Down Expand Up @@ -72,6 +73,11 @@ func toAcorn(appInstance *v1.AppInstance, tag name.Reference, pullSecrets *PullS
image = strings.TrimPrefix(acorn.Image, "sha256:")
}

originalImage := acorn.Image
if acorn.Build != nil && acorn.Build.OriginalImage != "" {
originalImage = acorn.Build.OriginalImage
}

// Ensure secret gets copied
pullSecrets.ForAcorn(acornName, image)

Expand All @@ -83,10 +89,13 @@ func toAcorn(appInstance *v1.AppInstance, tag name.Reference, pullSecrets *PullS

acornInstance := &v1.AppInstance{
ObjectMeta: metav1.ObjectMeta{
Name: name2.SafeHashConcatName(appInstance.Name, acornName),
Namespace: appInstance.Namespace,
Labels: labelMap,
Annotations: appInstanceScoped(acornName, appInstance.Status.AppSpec.Annotations, appInstance.Spec.Annotations, acorn.Annotations),
Name: name2.SafeHashConcatName(appInstance.Name, acornName),
Namespace: appInstance.Namespace,
Labels: labelMap,
Annotations: labels.Merge(appInstanceScoped(acornName, appInstance.Status.AppSpec.Annotations, appInstance.Spec.Annotations, acorn.Annotations),
map[string]string{
labels.AcornOriginalImage: originalImage,
}),
},
Spec: v1.AppInstanceSpec{
Region: appInstance.GetRegion(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/appdefinition/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/acorn-io/acorn/pkg/labels"
"github.com/acorn-io/acorn/pkg/pdb"
"github.com/acorn-io/acorn/pkg/ports"
"github.com/acorn-io/acorn/pkg/publicname"
"github.com/acorn-io/acorn/pkg/secrets"
"github.com/acorn-io/acorn/pkg/system"
"github.com/acorn-io/acorn/pkg/volume"
Expand Down Expand Up @@ -594,7 +595,7 @@ func toDeployment(req router.Request, appInstance *v1.AppInstance, tag name.Refe
return nil, err
}

podLabels := containerLabels(appInstance, container, name)
podLabels := containerLabels(appInstance, container, name, labels.AcornAppPublicName, publicname.Get(appInstance))
deploymentLabels := containerLabels(appInstance, container, name)
matchLabels := selectorMatchLabels(appInstance, name)

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/appdefinition/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

v1 "github.com/acorn-io/acorn/pkg/apis/internal.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/controller/appstatus"
"github.com/acorn-io/acorn/pkg/labels"
"github.com/acorn-io/acorn/pkg/publish"
"github.com/acorn-io/baaah/pkg/router"
Expand Down Expand Up @@ -139,7 +140,7 @@ func AppEndpointsStatus(req router.Request, _ router.Response) error {

eps := append(ingressEndpoints, serviceEndpoints...)

ingressTLSHosts, err := IngressTLSHosts(req.Ctx, req.Client, app)
ingressTLSHosts, err := appstatus.IngressTLSHosts(req.Ctx, req.Client, app)
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/appdefinition/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

v1 "github.com/acorn-io/acorn/pkg/apis/internal.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/labels"
"github.com/acorn-io/acorn/pkg/publicname"
"github.com/acorn-io/acorn/pkg/secrets"
"github.com/acorn-io/baaah/pkg/router"
"github.com/acorn-io/baaah/pkg/typed"
Expand Down Expand Up @@ -89,6 +90,7 @@ func toJob(req router.Request, appInstance *v1.AppInstance, pullSecrets *PullSec
ObjectMeta: metav1.ObjectMeta{
Labels: jobLabels(appInstance, container, name,
labels.AcornManaged, "true",
labels.AcornAppPublicName, publicname.Get(appInstance),
labels.AcornJobName, name,
labels.AcornContainerName, ""),
Annotations: labels.Merge(podAnnotations(appInstance, name, container), baseAnnotations),
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/appdefinition/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"strings"

v1 "github.com/acorn-io/acorn/pkg/apis/internal.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/labels"
"github.com/acorn-io/acorn/pkg/pdb"
"github.com/acorn-io/acorn/pkg/ports"
"github.com/acorn-io/acorn/pkg/publicname"
"github.com/acorn-io/acorn/pkg/system"
"github.com/acorn-io/acorn/pkg/tolerations"
"github.com/acorn-io/baaah/pkg/router"
Expand Down Expand Up @@ -48,7 +50,7 @@ func toRouter(appInstance *v1.AppInstance, routerName string, router v1.Router)

conf, confName := toNginxConf(routerName, router)

podLabels := routerLabels(appInstance, router, routerName)
podLabels := routerLabels(appInstance, router, routerName, labels.AcornAppPublicName, publicname.Get(appInstance))
deploymentLabels := routerLabels(appInstance, router, routerName)
matchLabels := routerSelectorMatchLabels(appInstance, routerName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ metadata:
"global2a": "value"
"allacornsa": "value"
"override2": "outervalue"
acorn.io/original-image: foo
spec:
# The labels and annotations in this spec should be a combination of the "inner" acorn's definition and the outer
# appInstance's scoped label and annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down Expand Up @@ -78,6 +79,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "twoimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ metadata:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/job-name": "oneimage"
"acorn.io/managed": "true"
spec:
template:
metadata:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-public-name": "app-name"
"acorn.io/app-name": "app-name"
"acorn.io/job-name": "oneimage"
"acorn.io/managed": "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ metadata:
labels:
acorn.io/app-name: app-name
acorn.io/app-namespace: app-namespace
acorn.io/app-public-name: "app-name"
acorn.io/managed: "true"
acorn.io/job-name: "oneimage"
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
"service-name.acorn.io/oneimage": "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down Expand Up @@ -79,6 +80,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "twoimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/appdefinition/testdata/cronjob/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/job-name": "oneimage"
"acorn.io/managed": "true"
spec:
Expand All @@ -15,6 +16,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/job-name": "oneimage"
"acorn.io/managed": "true"
spec:
Expand All @@ -23,6 +25,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/job-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ metadata:
labels:
acorn.io/app-name: app-name
acorn.io/app-namespace: app-namespace
"acorn.io/app-public-name": "app-name"
acorn.io/managed: "true"
acorn.io/job-name: "oneimage"
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "container-name"
"acorn.io/managed": "true"
annotations:
Expand Down Expand Up @@ -61,6 +62,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "web"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "container-name"
"acorn.io/managed": "true"
annotations:
Expand Down Expand Up @@ -63,6 +64,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "web"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
annotations:
Expand Down Expand Up @@ -90,6 +91,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "buildimage"
"acorn.io/managed": "true"
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "container-name"
"acorn.io/managed": "true"
allowed-global.io: test-global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
allowed-job.io: test-allowed-job-label
allowed.io: test-allowed-app-spec-label
permit.io: test-permit-app-spec-label
acorn.io/app-public-name: "app-name"
annotations:
admit-job.io: test-admit-job-ann
admit.io: test-admit-app-spec-ann
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/job-name": "job-name"
"acorn.io/managed": "true"
allowed-job.io: test-allowed-job-label
Expand All @@ -23,6 +24,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/job-name": "job-name"
"acorn.io/managed": "true"
allowed-job.io: test-allowed-job-label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "container-name"
"acorn.io/managed": "true"
appSpecLabel: test-app-spec-label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
acorn.io/app-namespace: app-namespace
acorn.io/app-name: app-name
acorn.io/app-public-name: "app-name"
acorn.io/job-name: job-name
acorn.io/managed: "true"
appSpecLabel: test-app-spec-label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/job-name": "job-name"
"acorn.io/managed": "true"
appSpecLabel: test-app-spec-label
Expand All @@ -21,6 +22,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
acorn.io/app-public-name: "app-name"
"acorn.io/job-name": "job-name"
"acorn.io/managed": "true"
appSpecLabel: test-app-spec-label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
"acorn.io/app-public-name": "app-name"
"acorn.io/container-name": "container-name"
"acorn.io/managed": "true"
annotations:
Expand Down
Loading