Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 15fc547

Browse files
tylerslatoncjellick
authored andcommitted
Remove targetNamespace option
Signed-off-by: tylerslaton <mtslaton1@gmail.com>
1 parent 45201d7 commit 15fc547

File tree

10 files changed

+22
-145
lines changed

10 files changed

+22
-145
lines changed

pkg/apis/internal.acorn.io/v1/appinstance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ type AppInstanceSpec struct {
9797
Secrets []SecretBinding `json:"secrets,omitempty"`
9898
Environment []NameValue `json:"environment,omitempty"`
9999
PublishMode PublishMode `json:"publishMode,omitempty"`
100-
TargetNamespace string `json:"targetNamespace,omitempty"`
101100
Links []ServiceBinding `json:"services,omitempty"`
102101
Publish []PortBinding `json:"ports,omitempty"`
103102
DeployArgs GenericMap `json:"deployArgs,omitempty"`

pkg/cli/run.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ More Usages:
129129
- Bind the acorn volume named "mydata" into the current app, replacing the volume named "data", See "acorn volumes --help for more info"
130130
acorn run --volume mydata:data .`
131131

132-
var hideRunFlags = []string{"dangerous", "memory", "target-namespace", "secret", "volume", "region", "publish-all",
132+
var hideRunFlags = []string{"dangerous", "memory", "secret", "volume", "region", "publish-all",
133133
"publish", "link", "label", "interval", "env", "compute-class", "annotation", "update", "replace"}
134134

135135
type Run struct {
@@ -160,7 +160,6 @@ func (s RunArgs) ToOpts() (client.AppRunOptions, error) {
160160
opts.Name = s.Name
161161
opts.Region = s.Region
162162
opts.Profiles = s.Profile
163-
opts.TargetNamespace = s.TargetNamespace
164163
opts.AutoUpgrade = s.AutoUpgrade
165164
opts.NotifyUpgrade = s.NotifyUpgrade
166165
opts.AutoUpgradeInterval = s.Interval

pkg/cli/update.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
var hideUpdateFlags = []string{"dangerous", "memory", "target-namespace", "secret", "volume", "region", "publish-all",
11+
var hideUpdateFlags = []string{"dangerous", "memory", "secret", "volume", "region", "publish-all",
1212
"publish", "link", "label", "interval", "env", "compute-class", "annotation"}
1313

1414
func NewUpdate(c CommandContext) *cobra.Command {
@@ -34,25 +34,24 @@ func NewUpdate(c CommandContext) *cobra.Command {
3434
}
3535

3636
type UpdateArgs struct {
37-
Region string `usage:"Region in which to deploy the app, immutable"`
38-
File string `short:"f" usage:"Name of the build file (default \"DIRECTORY/Acornfile\")"`
39-
Volume []string `usage:"Bind an existing volume (format existing:vol-name,field=value) (ex: pvc-name:app-data)" short:"v" split:"false"`
40-
Secret []string `usage:"Bind an existing secret (format existing:sec-name) (ex: sec-name:app-secret)" short:"s"`
41-
Link []string `usage:"Link external app as a service in the current app (format app-name:container-name)"`
42-
PublishAll *bool `usage:"Publish all (true) or none (false) of the defined ports of application" short:"P"`
43-
Publish []string `usage:"Publish port of application (format [public:]private) (ex 81:80)" short:"p"`
44-
Profile []string `usage:"Profile to assign default values"`
45-
Env []string `usage:"Environment variables to set on running containers" short:"e"`
46-
Label []string `usage:"Add labels to the app and the resources it creates (format [type:][name:]key=value) (ex k=v, containers:k=v)" short:"l"`
47-
Annotation []string `usage:"Add annotations to the app and the resources it creates (format [type:][name:]key=value) (ex k=v, containers:k=v)"`
48-
Dangerous bool `usage:"Automatically approve all privileges requested by the application"`
49-
Output string `usage:"Output API request without creating app (json, yaml)" short:"o"`
50-
TargetNamespace string `usage:"The name of the namespace to be created and deleted for the application resources"`
51-
NotifyUpgrade *bool `usage:"If true and the app is configured for auto-upgrades, you will be notified in the CLI when an upgrade is available and must confirm it"`
52-
AutoUpgrade *bool `usage:"Enabled automatic upgrades."`
53-
Interval string `usage:"If configured for auto-upgrade, this is the time interval at which to check for new releases (ex: 1h, 5m)"`
54-
Memory []string `usage:"Set memory for a workload in the format of workload=memory. Only specify an amount to set all workloads. (ex foo=512Mi or 512Mi)" short:"m"`
55-
ComputeClass []string `usage:"Set computeclass for a workload in the format of workload=computeclass. Specify a single computeclass to set all workloads. (ex foo=example-class or example-class)"`
37+
Region string `usage:"Region in which to deploy the app, immutable"`
38+
File string `short:"f" usage:"Name of the build file (default \"DIRECTORY/Acornfile\")"`
39+
Volume []string `usage:"Bind an existing volume (format existing:vol-name,field=value) (ex: pvc-name:app-data)" short:"v" split:"false"`
40+
Secret []string `usage:"Bind an existing secret (format existing:sec-name) (ex: sec-name:app-secret)" short:"s"`
41+
Link []string `usage:"Link external app as a service in the current app (format app-name:container-name)"`
42+
PublishAll *bool `usage:"Publish all (true) or none (false) of the defined ports of application" short:"P"`
43+
Publish []string `usage:"Publish port of application (format [public:]private) (ex 81:80)" short:"p"`
44+
Profile []string `usage:"Profile to assign default values"`
45+
Env []string `usage:"Environment variables to set on running containers" short:"e"`
46+
Label []string `usage:"Add labels to the app and the resources it creates (format [type:][name:]key=value) (ex k=v, containers:k=v)" short:"l"`
47+
Annotation []string `usage:"Add annotations to the app and the resources it creates (format [type:][name:]key=value) (ex k=v, containers:k=v)"`
48+
Dangerous bool `usage:"Automatically approve all privileges requested by the application"`
49+
Output string `usage:"Output API request without creating app (json, yaml)" short:"o"`
50+
NotifyUpgrade *bool `usage:"If true and the app is configured for auto-upgrades, you will be notified in the CLI when an upgrade is available and must confirm it"`
51+
AutoUpgrade *bool `usage:"Enabled automatic upgrades."`
52+
Interval string `usage:"If configured for auto-upgrade, this is the time interval at which to check for new releases (ex: 1h, 5m)"`
53+
Memory []string `usage:"Set memory for a workload in the format of workload=memory. Only specify an amount to set all workloads. (ex foo=512Mi or 512Mi)" short:"m"`
54+
ComputeClass []string `usage:"Set computeclass for a workload in the format of workload=computeclass. Specify a single computeclass to set all workloads. (ex foo=example-class or example-class)"`
5655
}
5756

5857
type Update struct {

pkg/client/app.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func ToApp(namespace, image string, opts *AppRunOptions) *apiv1.App {
6363
Environment: opts.Env,
6464
Labels: opts.Labels,
6565
Annotations: opts.Annotations,
66-
TargetNamespace: opts.TargetNamespace,
6766
AutoUpgrade: opts.AutoUpgrade,
6867
NotifyUpgrade: opts.NotifyUpgrade,
6968
AutoUpgradeInterval: opts.AutoUpgradeInterval,
@@ -154,9 +153,6 @@ func ToAppUpdate(ctx context.Context, c Client, name string, opts *AppUpdateOpti
154153
if opts.Permissions != nil {
155154
app.Spec.Permissions = opts.Permissions
156155
}
157-
if opts.TargetNamespace != "" {
158-
app.Spec.TargetNamespace = opts.TargetNamespace
159-
}
160156
if opts.AutoUpgrade != nil {
161157
app.Spec.AutoUpgrade = opts.AutoUpgrade
162158
}

pkg/client/client.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ type AppUpdateOptions struct {
102102
DeployArgs map[string]any
103103
Stop *bool
104104
Image string
105-
TargetNamespace string
106105
Replace bool // Replace is used to indicate whether the update should be a patch (replace=false: only change specified fields) or a full update (replace=true: reset unspecified fields to defaults)
107106
AutoUpgrade *bool
108107
NotifyUpgrade *bool
@@ -127,7 +126,6 @@ type AppRunOptions struct {
127126
Publish []v1.PortBinding
128127
Env []v1.NameValue
129128
Profiles []string
130-
TargetNamespace string
131129
DeployArgs map[string]any
132130
Stop *bool
133131
Permissions []v1.Permissions
@@ -152,7 +150,6 @@ func (a AppRunOptions) ToUpdate() AppUpdateOptions {
152150
Profiles: a.Profiles,
153151
Permissions: a.Permissions,
154152
Env: a.Env,
155-
TargetNamespace: a.TargetNamespace,
156153
AutoUpgrade: a.AutoUpgrade,
157154
NotifyUpgrade: a.NotifyUpgrade,
158155
AutoUpgradeInterval: a.AutoUpgradeInterval,
@@ -175,7 +172,6 @@ func (a AppUpdateOptions) ToRun() AppRunOptions {
175172
Profiles: a.Profiles,
176173
Permissions: a.Permissions,
177174
Env: a.Env,
178-
TargetNamespace: a.TargetNamespace,
179175
AutoUpgrade: a.AutoUpgrade,
180176
NotifyUpgrade: a.NotifyUpgrade,
181177
AutoUpgradeInterval: a.AutoUpgradeInterval,

pkg/controller/appdefinition/namespace.go

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package appdefinition
22

33
import (
4-
"fmt"
54
"strings"
65

76
"github.com/acorn-io/baaah/pkg/router"
@@ -10,7 +9,6 @@ import (
109
"github.com/acorn-io/runtime/pkg/labels"
1110
"github.com/rancher/wrangler/pkg/name"
1211
corev1 "k8s.io/api/core/v1"
13-
apierror "k8s.io/apimachinery/pkg/api/errors"
1412
kclient "sigs.k8s.io/controller-runtime/pkg/client"
1513
)
1614

@@ -23,46 +21,13 @@ func AssignNamespace(req router.Request, resp router.Response) (err error) {
2321
err = nil
2422
}()
2523

26-
if appInstance.Spec.TargetNamespace != "" {
27-
if err := ensureNamespaceOwned(req, appInstance); err != nil {
28-
return err
29-
}
30-
}
31-
32-
if appInstance.Spec.TargetNamespace == "" {
33-
parts := strings.Split(appInstance.Name, ".")
34-
appInstance.Status.Namespace = name.SafeConcatName(parts[len(parts)-1], appInstance.ShortID())
35-
} else {
36-
appInstance.Status.Namespace = appInstance.Spec.TargetNamespace
37-
}
24+
parts := strings.Split(appInstance.Name, ".")
25+
appInstance.Status.Namespace = name.SafeConcatName(parts[len(parts)-1], appInstance.ShortID())
3826

3927
resp.Objects(appInstance)
4028
return nil
4129
}
4230

43-
func ensureNamespaceOwned(req router.Request, appInstance *v1.AppInstance) error {
44-
ns := &corev1.Namespace{}
45-
err := req.Get(ns, "", appInstance.Spec.TargetNamespace)
46-
if apierror.IsNotFound(err) {
47-
return nil
48-
} else if err != nil {
49-
return err
50-
}
51-
52-
if ns.Labels[labels.AcornAppNamespace] != appInstance.Namespace ||
53-
ns.Labels[labels.AcornAppName] != appInstance.Name {
54-
err := fmt.Errorf("can not use namespace %s, existing namespace must have labels "+
55-
"acorn.io/app-namespace"+" and acorn.io/app-name (Apply Using: kubectl label namespaces %s acorn.io/app-name=%s; "+
56-
"kubectl label namespaces %s acorn.io/app-namespace=acorn) "+
57-
"Namespace will be deleted when the app is deleted",
58-
appInstance.Spec.TargetNamespace, appInstance.Spec.TargetNamespace, appInstance.Name,
59-
appInstance.Spec.TargetNamespace)
60-
appInstance.Status.Columns.Message = err.Error()
61-
return err
62-
}
63-
return nil
64-
}
65-
6631
func IgnoreTerminatingNamespace(h router.Handler) router.Handler {
6732
return router.HandlerFunc(func(req router.Request, resp router.Response) error {
6833
ns := &corev1.Namespace{}

pkg/controller/appdefinition/namespace_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ func TestAssignNamespace(t *testing.T) {
1616
tester.DefaultTest(t, scheme.Scheme, "testdata/assignnamespace", AssignNamespace)
1717
}
1818

19-
func TestAssignTargetNamespace(t *testing.T) {
20-
tester.DefaultTest(t, scheme.Scheme, "testdata/assigntargetnamespace", AssignNamespace)
21-
}
22-
2319
func TestLabelsAnnotationsBasic(t *testing.T) {
2420
tester.DefaultTest(t, scheme.Scheme, "testdata/propagation_basic", namespace.AddNamespace)
2521
}

pkg/controller/appdefinition/testdata/assigntargetnamespace/expected.golden

Lines changed: 0 additions & 59 deletions
This file was deleted.

pkg/controller/appdefinition/testdata/assigntargetnamespace/input.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

pkg/openapi/generated/openapi_generated.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)