@@ -31,26 +31,51 @@ var podModifyCmd = &cobra.Command{
31
31
if err != nil {
32
32
log .Fatalf ("getControllerAndDev: %s" , err )
33
33
}
34
- for _ , el := range dev .GetApplicationInstances () {
35
- app , err := ctrl .GetApplicationInstanceConfig (el )
34
+ for _ , appID := range dev .GetApplicationInstances () {
35
+ app , err := ctrl .GetApplicationInstanceConfig (appID )
36
36
if err != nil {
37
- log .Fatalf ("no app in cloud %s: %s" , el , err )
37
+ log .Fatalf ("no app in cloud %s: %s" , appID , err )
38
38
}
39
39
if app .Displayname == appName {
40
+ portPublishCombined := portPublish
41
+ if ! cmd .Flags ().Changed ("publish" ) {
42
+ portPublishCombined = []string {}
43
+ for _ , intf := range app .Interfaces {
44
+ for _ , acls := range intf .Acls {
45
+ lport := ""
46
+ var appPort uint32
47
+ for _ , match := range acls .Matches {
48
+ if match .Type == "lport" {
49
+ lport = match .Value
50
+ break
51
+ }
52
+ }
53
+ for _ , action := range acls .Actions {
54
+ if action .Portmap {
55
+ appPort = action .AppPort
56
+ break
57
+ }
58
+ }
59
+ if lport != "" && appPort != 0 {
60
+ portPublishCombined = append (portPublishCombined , fmt .Sprintf ("%s:%d" , lport , appPort ))
61
+ }
62
+ }
63
+ }
64
+ }
40
65
var opts []expect.ExpectationOption
41
66
if len (podNetworks ) > 0 {
42
67
for i , el := range podNetworks {
43
68
if i == 0 {
44
69
//allocate ports on first network
45
- opts = append (opts , expect .AddNetInstanceNameAndPortPublish (el , portPublish ))
70
+ opts = append (opts , expect .AddNetInstanceNameAndPortPublish (el , portPublishCombined ))
46
71
} else {
47
72
opts = append (opts , expect .AddNetInstanceNameAndPortPublish (el , nil ))
48
73
}
49
74
}
50
75
} else {
51
- opts = append (opts , expect .WithPortsPublish (portPublish ))
76
+ opts = append (opts , expect .WithPortsPublish (portPublishCombined ))
52
77
}
53
- opts = append (opts , expect .WithACL (acl ))
78
+ opts = append (opts , expect .WithACL (processAcls ( acl ) ))
54
79
opts = append (opts , expect .WithOldApp (appName ))
55
80
expectation := expect .AppExpectationFromURL (ctrl , dev , defaults .DefaultDummyExpect , appName , opts ... )
56
81
appInstanceConfig := expectation .Application ()
@@ -59,7 +84,11 @@ var podModifyCmd = &cobra.Command{
59
84
needPurge = true
60
85
} else {
61
86
for ind , el := range app .Interfaces {
62
- if el .NetworkId != appInstanceConfig .Interfaces [ind ].NetworkId {
87
+ equals , err := utils .CompareProtoMessages (el , appInstanceConfig .Interfaces [ind ])
88
+ if err != nil {
89
+ log .Fatalf ("CompareMessages: %v" , err )
90
+ }
91
+ if ! equals {
63
92
needPurge = true
64
93
break
65
94
}
@@ -89,5 +118,7 @@ func podModifyInit() {
89
118
podModifyCmd .Flags ().StringSliceVarP (& portPublish , "publish" , "p" , nil , "Ports to publish in format EXTERNAL_PORT:INTERNAL_PORT" )
90
119
podModifyCmd .Flags ().BoolVar (& aclOnlyHost , "only-host" , false , "Allow access only to host and external networks" )
91
120
podModifyCmd .Flags ().StringSliceVar (& podNetworks , "networks" , nil , "Networks to connect to app (ports will be mapped to first network)" )
92
- podModifyCmd .Flags ().StringSliceVar (& acl , "acl" , nil , "Allow access only to defined hosts/ips/subnets" )
121
+ podModifyCmd .Flags ().StringSliceVar (& acl , "acl" , nil , `Allow access only to defined hosts/ips/subnets
122
+ You can set acl for particular network in format '<network_name:acl>'
123
+ To remove acls you can set empty line '<network_name>:'` )
93
124
}
0 commit comments