Skip to content

Commit 06069be

Browse files
authored
Merge pull request #8 from vkareh/allow-apps-id-for-ingress
ingress: Allow using sub-domain identifier
2 parents 3fef73e + 29cd761 commit 06069be

4 files changed

Lines changed: 35 additions & 11 deletions

File tree

cmd/dlt/ingress/cmd.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
// Regular expression to used to make sure that the identifier given by the
3434
// user is safe and that it there is no risk of SQL injection:
35-
var ingressKeyRE = regexp.MustCompile(`^[a-z0-9]{4}$`)
35+
var ingressKeyRE = regexp.MustCompile(`^[a-z0-9]{3,5}$`)
3636

3737
var args struct {
3838
clusterKey string
@@ -44,7 +44,10 @@ var Cmd = &cobra.Command{
4444
Short: "Delete cluster ingress",
4545
Long: "Delete the additional non-default application router for a cluster.",
4646
Example: ` # Delete ingress with ID a1b2 from a cluster named 'mycluster'
47-
moactl delete ingress --cluster=mycluster a1b2`,
47+
moactl delete ingress --cluster=mycluster a1b2
48+
49+
# Delete secondary ingress using the sub-domain name
50+
moactl delete ingress --cluster=mycluster apps2`,
4851
Run: run,
4952
}
5053

@@ -157,6 +160,12 @@ func run(_ *cobra.Command, argv []string) {
157160

158161
var ingress *cmv1.Ingress
159162
for _, item := range ingresses {
163+
if ingressID == "apps" && item.Default() {
164+
ingress = item
165+
}
166+
if ingressID == "apps2" && !item.Default() {
167+
ingress = item
168+
}
160169
if item.ID() == ingressID {
161170
ingress = item
162171
}

cmd/edit/ingress/cmd.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434

3535
// Regular expression to used to make sure that the identifier given by the
3636
// user is safe and that it there is no risk of SQL injection:
37-
var ingressKeyRE = regexp.MustCompile(`^[a-z0-9]{3,4}$`)
37+
var ingressKeyRE = regexp.MustCompile(`^[a-z0-9]{3,5}$`)
3838

3939
var args struct {
4040
clusterKey string
@@ -47,11 +47,14 @@ var Cmd = &cobra.Command{
4747
Aliases: []string{"route"},
4848
Short: "Edit the additional cluster ingress",
4949
Long: "Edit the additional non-default application router for a cluster.",
50-
Example: ` # Make additional ingress private on a cluster named 'mycluster'
51-
moactl edit ingress --private --cluster=mycluster
50+
Example: ` # Make additional ingress with ID 'a1b2' private on a cluster named 'mycluster'
51+
moactl edit ingress --private --cluster=mycluster a1b2
5252
53-
# Update the router selectors for the additional ingress
54-
moactl edit ingress --label-match=foo=bar --cluster=mycluster`,
53+
# Update the router selectors for the additional ingress with ID 'a1b2'
54+
moactl edit ingress --label-match=foo=bar --cluster=mycluster a1b2
55+
56+
# Update the default ingress using the sub-domain identifier
57+
moactl edit ingress --private=false --cluster=mycluster apps`,
5558
Run: run,
5659
}
5760

@@ -210,6 +213,12 @@ func run(cmd *cobra.Command, argv []string) {
210213

211214
var ingress *cmv1.Ingress
212215
for _, item := range ingresses {
216+
if ingressID == "apps" && item.Default() {
217+
ingress = item
218+
}
219+
if ingressID == "apps2" && !item.Default() {
220+
ingress = item
221+
}
213222
if item.ID() == ingressID {
214223
ingress = item
215224
}

docs/moactl_delete_ingress.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ moactl delete ingress [flags]
1515
```
1616
# Delete ingress with ID a1b2 from a cluster named 'mycluster'
1717
moactl delete ingress --cluster=mycluster a1b2
18+
19+
# Delete secondary ingress using the sub-domain name
20+
moactl delete ingress --cluster=mycluster apps2
1821
```
1922

2023
### Options

docs/moactl_edit_ingress.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ moactl edit ingress [flags]
1313
### Examples
1414

1515
```
16-
# Make additional ingress private on a cluster named 'mycluster'
17-
moactl edit ingress --private --cluster=mycluster
16+
# Make additional ingress with ID 'a1b2' private on a cluster named 'mycluster'
17+
moactl edit ingress --private --cluster=mycluster a1b2
1818
19-
# Update the router selectors for the additional ingress
20-
moactl edit ingress --label-match=foo=bar --cluster=mycluster
19+
# Update the router selectors for the additional ingress with ID 'a1b2'
20+
moactl edit ingress --label-match=foo=bar --cluster=mycluster a1b2
21+
22+
# Update the default ingress using the sub-domain identifier
23+
moactl edit ingress --private=false --cluster=mycluster apps
2124
```
2225

2326
### Options

0 commit comments

Comments
 (0)