Skip to content

Commit

Permalink
Exclude services
Browse files Browse the repository at this point in the history
  • Loading branch information
Theosakamg committed Oct 9, 2024
1 parent a254811 commit f4ecdde
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/scaling-instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (

func init() {
flag.StringVarP(&app.ArgsS.Name, "name", "", "", "Apps or Service name")
flag.BoolVarP(&app.ArgsS.IncludeServices, "include_service", "", false, "Autoscale the services")
flag.IntVarP(&app.ArgsS.HostCountMin, "min_host_count:", "", 1, "Minimum host count")
flag.IntVarP(&app.ArgsS.HostCountMax, "max_host_count", "", 3, "Maximum host count")
flag.Float64VarP(&app.ArgsS.CpuUsageMin, "min_cpu_usage_upscale", "", 75.0, "Minimum CPU usage in % (for upscale event only)")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.6

require (
github.com/spf13/pflag v1.0.5
github.com/upsun/lib-sun v0.3.11
github.com/upsun/lib-sun v0.3.12
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/upsun/lib-sun v0.3.11 h1:yhlZWWQeIXcm5PLcniV8cbA2Y7kQ/Fkf/0QDPpIi010=
github.com/upsun/lib-sun v0.3.11/go.mod h1:8AtRNv0L+c9qCS/maO/OVFIn2VDi89LTkWwpB7YKTDE=
github.com/upsun/lib-sun v0.3.12 h1:+npDh43Uy2BE450fcUjfBqkzvCeUimLaCpFXi+oKUh0=
github.com/upsun/lib-sun v0.3.12/go.mod h1:8AtRNv0L+c9qCS/maO/OVFIn2VDi89LTkWwpB7YKTDE=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand Down
23 changes: 23 additions & 0 deletions internal/logic/scaling_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ func ScalingInstance(projectContext entity.ProjectGlobal) {
usages[name] = usage
}

if !app.ArgsS.IncludeServices {
// Get Services
log.Println("Dectect available services of project... (to exclude)")
payload = []string{
"--environment=" + projectContext.DefaultEnv,
"--format=csv",
"--columns=name",
"--no-header",
"--no-interaction",
"--yes",
}
output, err = utils.CallCLIString(projectContext, "service:list", payload...)
if err != nil {
log.Fatalf("command execution failed: %s", err)
}

// Parse output
srvs := strings.Split(output, "\n")
for _, srv := range srvs[:len(srvs)-1] {
delete(usages, srv)
}
}

// Compute
log.Println("Compute trend...")

Expand Down

0 comments on commit f4ecdde

Please sign in to comment.