Skip to content

Commit f4ecdde

Browse files
committed
Exclude services
1 parent a254811 commit f4ecdde

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

cmd/scaling-instance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818

1919
func init() {
2020
flag.StringVarP(&app.ArgsS.Name, "name", "", "", "Apps or Service name")
21+
flag.BoolVarP(&app.ArgsS.IncludeServices, "include_service", "", false, "Autoscale the services")
2122
flag.IntVarP(&app.ArgsS.HostCountMin, "min_host_count:", "", 1, "Minimum host count")
2223
flag.IntVarP(&app.ArgsS.HostCountMax, "max_host_count", "", 3, "Maximum host count")
2324
flag.Float64VarP(&app.ArgsS.CpuUsageMin, "min_cpu_usage_upscale", "", 75.0, "Minimum CPU usage in % (for upscale event only)")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.6
44

55
require (
66
github.com/spf13/pflag v1.0.5
7-
github.com/upsun/lib-sun v0.3.11
7+
github.com/upsun/lib-sun v0.3.12
88
)
99

1010
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
1616
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
1717
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
1818
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
19-
github.com/upsun/lib-sun v0.3.11 h1:yhlZWWQeIXcm5PLcniV8cbA2Y7kQ/Fkf/0QDPpIi010=
20-
github.com/upsun/lib-sun v0.3.11/go.mod h1:8AtRNv0L+c9qCS/maO/OVFIn2VDi89LTkWwpB7YKTDE=
19+
github.com/upsun/lib-sun v0.3.12 h1:+npDh43Uy2BE450fcUjfBqkzvCeUimLaCpFXi+oKUh0=
20+
github.com/upsun/lib-sun v0.3.12/go.mod h1:8AtRNv0L+c9qCS/maO/OVFIn2VDi89LTkWwpB7YKTDE=
2121
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
2222
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2323
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=

internal/logic/scaling_resource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ func ScalingInstance(projectContext entity.ProjectGlobal) {
104104
usages[name] = usage
105105
}
106106

107+
if !app.ArgsS.IncludeServices {
108+
// Get Services
109+
log.Println("Dectect available services of project... (to exclude)")
110+
payload = []string{
111+
"--environment=" + projectContext.DefaultEnv,
112+
"--format=csv",
113+
"--columns=name",
114+
"--no-header",
115+
"--no-interaction",
116+
"--yes",
117+
}
118+
output, err = utils.CallCLIString(projectContext, "service:list", payload...)
119+
if err != nil {
120+
log.Fatalf("command execution failed: %s", err)
121+
}
122+
123+
// Parse output
124+
srvs := strings.Split(output, "\n")
125+
for _, srv := range srvs[:len(srvs)-1] {
126+
delete(usages, srv)
127+
}
128+
}
129+
107130
// Compute
108131
log.Println("Compute trend...")
109132

0 commit comments

Comments
 (0)