From 0b3832b039c6319a3fbd1a737a039873e5c0eadf Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 28 Dec 2025 17:59:04 +0900 Subject: [PATCH 01/45] =?UTF-8?q?refactor:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=90=8D=E3=82=92=20DevOpsBot=20=E3=81=8B?= =?UTF-8?q?=E3=82=89=20sakura-DevOpsBot=20=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/root.go | 4 ++-- cmd/server.go | 2 +- go.mod | 2 +- main.go | 2 +- pkg/bot/bot.go | 9 +++++---- pkg/bot/command.go | 6 +++--- pkg/bot/help.go | 6 +++--- pkg/bot/slack/bot.go | 11 ++++++----- pkg/bot/slack/context.go | 9 +++++---- pkg/bot/traq/bot.go | 7 ++++--- pkg/bot/traq/context.go | 9 +++++---- pkg/server/hosts.go | 2 +- pkg/server/restart.go | 2 +- pkg/server/token.go | 2 +- 14 files changed, 39 insertions(+), 34 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 148387f..eb7e9a8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/cobra" - "github.com/traPtitech/DevOpsBot/pkg/bot" - "github.com/traPtitech/DevOpsBot/pkg/utils" + "github.com/traPtitech/sakura-DevOpsBot/pkg/bot" + "github.com/traPtitech/sakura-DevOpsBot/pkg/utils" ) // rootCmd represents the base command when called without any subcommands diff --git a/cmd/server.go b/cmd/server.go index 2203237..02d46e6 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/traPtitech/DevOpsBot/pkg/server" + "github.com/traPtitech/sakura-DevOpsBot/pkg/server" ) var serverCmd = &cobra.Command{ diff --git a/go.mod b/go.mod index 4bd1c40..9eda765 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/traPtitech/DevOpsBot +module github.com/traPtitech/sakura-DevOpsBot go 1.22 diff --git a/main.go b/main.go index b0099a1..ccf0114 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/traPtitech/DevOpsBot/cmd" + "github.com/traPtitech/sakura-DevOpsBot/cmd" ) func main() { diff --git a/pkg/bot/bot.go b/pkg/bot/bot.go index 987c3f3..0110d7f 100644 --- a/pkg/bot/bot.go +++ b/pkg/bot/bot.go @@ -3,13 +3,14 @@ package bot import ( "context" "fmt" - "github.com/traPtitech/DevOpsBot/pkg/bot/slack" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" + + "github.com/traPtitech/sakura-DevOpsBot/pkg/bot/slack" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" "go.uber.org/zap" - "github.com/traPtitech/DevOpsBot/pkg/bot/traq" + "github.com/traPtitech/sakura-DevOpsBot/pkg/bot/traq" ) func Run(ctx context.Context) error { diff --git a/pkg/bot/command.go b/pkg/bot/command.go index 03c77b6..5b5febe 100644 --- a/pkg/bot/command.go +++ b/pkg/bot/command.go @@ -11,9 +11,9 @@ import ( "github.com/samber/lo" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" - "github.com/traPtitech/DevOpsBot/pkg/utils" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" + "github.com/traPtitech/sakura-DevOpsBot/pkg/utils" ) var ( diff --git a/pkg/bot/help.go b/pkg/bot/help.go index 9db79d1..f61e96b 100644 --- a/pkg/bot/help.go +++ b/pkg/bot/help.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" - "github.com/traPtitech/DevOpsBot/pkg/utils" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" + "github.com/traPtitech/sakura-DevOpsBot/pkg/utils" ) var _ domain.Command = (*HelpCommand)(nil) diff --git a/pkg/bot/slack/bot.go b/pkg/bot/slack/bot.go index 3c88848..379acc3 100644 --- a/pkg/bot/slack/bot.go +++ b/pkg/bot/slack/bot.go @@ -3,17 +3,18 @@ package slack import ( "context" "fmt" + "log/slog" + "regexp" + "strings" + "github.com/kballard/go-shellquote" "github.com/samber/lo" "github.com/slack-go/slack" "github.com/slack-go/slack/slackevents" "github.com/slack-go/slack/socketmode" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" "go.uber.org/zap" - "log/slog" - "regexp" - "strings" ) const slashPrefix = "/" diff --git a/pkg/bot/slack/context.go b/pkg/bot/slack/context.go index 58205f8..9a190d4 100644 --- a/pkg/bot/slack/context.go +++ b/pkg/bot/slack/context.go @@ -2,12 +2,13 @@ package slack import ( "context" + "strings" + "github.com/slack-go/slack" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" - "github.com/traPtitech/DevOpsBot/pkg/utils" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" + "github.com/traPtitech/sakura-DevOpsBot/pkg/utils" "go.uber.org/zap" - "strings" ) type slackContext struct { diff --git a/pkg/bot/traq/bot.go b/pkg/bot/traq/bot.go index 04cdaba..9318c9b 100644 --- a/pkg/bot/traq/bot.go +++ b/pkg/bot/traq/bot.go @@ -3,15 +3,16 @@ package traq import ( "context" "fmt" + "strings" + "github.com/kballard/go-shellquote" "github.com/samber/lo" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" "github.com/traPtitech/go-traq" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" traqwsbot "github.com/traPtitech/traq-ws-bot" "github.com/traPtitech/traq-ws-bot/payload" "go.uber.org/zap" - "strings" ) type traqBot struct { diff --git a/pkg/bot/traq/context.go b/pkg/bot/traq/context.go index 163d8ff..bafa612 100644 --- a/pkg/bot/traq/context.go +++ b/pkg/bot/traq/context.go @@ -2,15 +2,16 @@ package traq import ( "context" - "github.com/traPtitech/DevOpsBot/pkg/config" - "github.com/traPtitech/DevOpsBot/pkg/domain" + "strings" + + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/domain" "github.com/traPtitech/traq-ws-bot/payload" "go.uber.org/zap" - "strings" "github.com/traPtitech/go-traq" - "github.com/traPtitech/DevOpsBot/pkg/utils" + "github.com/traPtitech/sakura-DevOpsBot/pkg/utils" ) type traqContext struct { diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 6080abc..53e3e98 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -10,7 +10,7 @@ import ( "sync" "github.com/dghubble/sling" - "github.com/traPtitech/DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" "golang.org/x/sync/errgroup" ) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index fa2cd22..ae43dc5 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -8,7 +8,7 @@ import ( "github.com/dghubble/sling" "github.com/samber/lo" - "github.com/traPtitech/DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" ) type restartCommand struct { diff --git a/pkg/server/token.go b/pkg/server/token.go index d365b56..3c46a74 100644 --- a/pkg/server/token.go +++ b/pkg/server/token.go @@ -7,7 +7,7 @@ import ( "net/http" "github.com/dghubble/sling" - "github.com/traPtitech/DevOpsBot/pkg/config" + "github.com/traPtitech/sakura-DevOpsBot/pkg/config" ) func getConohaAPIToken() (string, error) { From 68bd67d9f43a8b0fa894ee2b8c5ab565c5500dc1 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:27:23 +0900 Subject: [PATCH 02/45] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E5=90=8D=E3=82=92=20sakura-DevOpsBot=20=E3=81=AB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 96b7f24..198b841 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ARG TARGETARCH ENV GOOS=$TARGETOS ENV GOARCH=$TARGETARCH RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ - go build -o /dev-ops-bot -ldflags="-s -w -X github.com/traPtitech/DevOpsBot/pkg/utils.version=$VERSION" . + go build -o /dev-ops-bot -ldflags="-s -w -X github.com/traPtitech/sakura-DevOpsBot/pkg/utils.version=$VERSION" . FROM alpine:3 From 2b9f644808aed093c8897c129161775dfc09b297 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:28:20 +0900 Subject: [PATCH 03/45] =?UTF-8?q?feat:=20Sakura=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E8=A8=AD=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=80=81Conoha=E8=A8=AD=E5=AE=9A=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 48c4a69..22f6329 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -102,15 +102,10 @@ type CommandConfig struct { } type ServersConfig struct { - Conoha struct { - Origin struct { - Identity string `mapstructure:"identity" yaml:"identity"` - Compute string `mapstructure:"compute" yaml:"compute"` - } `mapstructure:"origin" yaml:"origin"` - Username string `mapstructure:"username" yaml:"username"` - Password string `mapstructure:"password" yaml:"password"` - TenantID string `mapstructure:"tenantID" yaml:"tenantID"` - } `mapstructure:"conoha" yaml:"conoha"` + Sakura struct { + Origin string `mapstructure:"origin" yaml:"origin"` + BearerToken string `mapstructure:"bearertoken" yaml:"bearertoken"` + } `mapstructure:"sakura" yaml:"sakura"` } func init() { @@ -143,11 +138,8 @@ func init() { viper.SetDefault("templates", nil) viper.SetDefault("commands", nil) - viper.SetDefault("servers.conoha.origin.identity", "https://identity.tyo1.conoha.io/") - viper.SetDefault("servers.conoha.origin.compute", "https://compute.tyo1.conoha.io/") - viper.SetDefault("servers.conoha.username", "") - viper.SetDefault("servers.conoha.password", "") - viper.SetDefault("servers.conoha.tenantID", "") + viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp/vps/api/v7/") + viper.SetDefault("servers.sakura.bearertoken", "") } func init() { From 2b02b192ee0af0becd19ac8a50245a655722414e Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:29:00 +0900 Subject: [PATCH 04/45] =?UTF-8?q?del=20=E3=81=95=E3=81=8F=E3=82=89?= =?UTF-8?q?=E3=81=A7=E3=81=AFtoken=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=9F=E3=82=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/token.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/server/token.go b/pkg/server/token.go index 3c46a74..c3871af 100644 --- a/pkg/server/token.go +++ b/pkg/server/token.go @@ -1,5 +1,6 @@ package server +/* import ( "encoding/json" "fmt" @@ -70,3 +71,4 @@ func getConohaAPIToken() (string, error) { return responseJson.Access.Token.Id, nil } +*/ \ No newline at end of file From 9a7636972882a24d79fe3f596f9f5cf9870c467a Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:03:43 +0900 Subject: [PATCH 05/45] =?UTF-8?q?add=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index 068d912..6c64cb9 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -9,6 +9,7 @@ type ServersCommand struct { Commands map[string]command } +// CLIにコマンドを登録 func Compile() (*ServersCommand, error) { cmd := &ServersCommand{} cmd.Commands = make(map[string]command) From e98018936385f51db4b9dda722aa7cc2af65444f Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:04:12 +0900 Subject: [PATCH 06/45] =?UTF-8?q?feat:=20Sakura=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E8=A8=AD=E5=AE=9A=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97?= =?UTF-8?q?=E3=80=81API=20URL=E3=83=91=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 22f6329..fa6bca1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -104,7 +104,8 @@ type CommandConfig struct { type ServersConfig struct { Sakura struct { Origin string `mapstructure:"origin" yaml:"origin"` - BearerToken string `mapstructure:"bearertoken" yaml:"bearertoken"` + ApiURLPath string `mapstructure:"apiURLPath" yaml:"apiURLPath"` + BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"` } `mapstructure:"sakura" yaml:"sakura"` } @@ -138,8 +139,9 @@ func init() { viper.SetDefault("templates", nil) viper.SetDefault("commands", nil) - viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp/vps/api/v7/") - viper.SetDefault("servers.sakura.bearertoken", "") + viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp/") + viper.SetDefault("servers.sakura.apiURLPath", "vps/api/v7/") + viper.SetDefault("servers.sakura.bearerToken", "") } func init() { From c30c7dfdbfd4b35d2dfacc88e2921714ef028e54 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:39:45 +0900 Subject: [PATCH 07/45] =?UTF-8?q?feat:=20=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E5=BF=9C=E7=AD=94=E3=81=AE=E6=A7=8B=E9=80=A0=E4=BD=93?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81Sakura=20API?= =?UTF-8?q?=E3=81=B8=E3=81=AE=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 169 +++++++++++++++++++++++--------------------- 1 file changed, 88 insertions(+), 81 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 53e3e98..0026dc9 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -7,63 +7,92 @@ import ( "log" "net/http" "sort" - "sync" "github.com/dghubble/sling" "github.com/traPtitech/sakura-DevOpsBot/pkg/config" - "golang.org/x/sync/errgroup" ) type hostsCommand struct { } type serversResponse struct { - Servers []struct { - ID string `json:"id"` - Links []struct { - Href string `json:"href"` - Rel string `json:"rel"` - } `json:"links"` - Name string `json:"name"` - } `json:"servers"` + Results []serverResponse `json:"results"` + Count string `json:"count"` + Next *string `json:"next,omitempty"` + Previous *string `json:"previous,omitempty"` } type serverResponse struct { - Server struct { - ID string `json:"id"` - Status string `json:"status"` - OSEXTSRVATTRHost string `json:"OS-EXT-SRV-ATTR:host"` - Metadata struct { - InstanceNameTag string `json:"instance_name_tag"` - } `json:"metadata"` - } `json:"server"` + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + ServiceType string `json:"service_type"` + ServiceStatus string `json:"service_status"` + CPUCores string `json:"cpu_cores"` + MemoryMiB string `json:"memory_mebibytes"` + Storage []struct { + Port string `json:"port"` + Type string `json:"type"` + SizeGiB string `json:"size_gibibytes"` + } `json:"storage"` + Zone struct { + Code string `json:"code"` + Name string `json:"name"` + } `json:"zone"` + Options []string `json:"options"` + Version string `json:"version"` + Ipv4 struct { + Address string `json:"address"` + Netmask string `json:"netmask"` + Gateway string `json:"gateway"` + NameServers []string `json:"nameservers"` + HostName string `json:"hostname"` + PTR string `json:"ptr"` + } `json:"ipv4"` + Ipv6 struct { + Address *string `json:"address,omitempty"` + PrefixLen *string `json:"prefixlen,omitempty"` + Gateway *string `json:"gateway,omitempty"` + NameServers []string `json:"nameservers"` + HostName *string `json:"hostname,omitempty"` + PTR *string `json:"ptr,omitempty"` + } `json:"ipv6"` + Contract struct { + PlanCode string `json:"plan_code"` + PlanName string `json:"plan_name"` + ServiceCode string `json:"service_code"` + } `json:"contract"` + PowerStatus string `json:"power_status"` + MigrationStatus *string `json:"migration_status,omitempty"` } type resultData struct { - ID string - Host string - Name string + ID string + Zone string + Name string + Ipv4 string + Ipv6 string + CpuCores string + MemoryMiB string + Storage []struct { + Size string + Type string + } } func (sc *hostsCommand) Execute(args []string) error { - token, err := getConohaAPIToken() - if err != nil { - return fmt.Errorf("failed to get conoha api token: %w", err) - } - req, err := sling.New(). - Base(config.C.Servers.Conoha.Origin.Compute). - Get(fmt.Sprintf("v2/%s/servers", config.C.Servers.Conoha.TenantID)). - Set("Accept", "application/json"). - Set("X-Auth-Token", token). + Base(config.C.Servers.Sakura.Origin). + Get(config.C.Servers.Sakura.ApiURLPath). + Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). Request() if err != nil { - return fmt.Errorf("failed to create restart request: %w", err) + return fmt.Errorf("failed to create hosts request: %w", err) } resp, err := http.DefaultClient.Do(req) if err != nil { - return fmt.Errorf("failed to post restart request: %w", err) + return fmt.Errorf("failed to get hosts: %w", err) } defer resp.Body.Close() @@ -83,62 +112,40 @@ func (sc *hostsCommand) Execute(args []string) error { servers := []resultData{} - eg := errgroup.Group{} - mu := sync.Mutex{} - for _, server := range response.Servers { - eg.Go(func() error { - req, err := sling.New(). - Base(config.C.Servers.Conoha.Origin.Compute). - Get(fmt.Sprintf("v2/%s/servers/%s", config.C.Servers.Conoha.TenantID, server.ID)). - Set("Accept", "application/json"). - Set("X-Auth-Token", token). - Request() - if err != nil { - return fmt.Errorf("failed to create restart request: %w", err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return fmt.Errorf("failed to post restart request: %w", err) - } - defer resp.Body.Close() - - respBody, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("failed to read response body: %w", err) - } - - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("invalid status code: %s (expected: 200)", resp.Status) - } - - var response serverResponse - if err := json.Unmarshal(respBody, &response); err != nil { - return fmt.Errorf("failed to unmarshal response body: %w", err) - } - - mu.Lock() - servers = append(servers, resultData{ - ID: response.Server.ID, - Host: response.Server.OSEXTSRVATTRHost, - Name: response.Server.Metadata.InstanceNameTag, - }) - mu.Unlock() - - return nil - }) - } - - if err := eg.Wait(); err != nil { - return fmt.Errorf("error in goroutines: %w", err) + for _, server := range response.Results { + serverData := resultData{ + ID: server.ID, + Zone: server.Zone.Name, + Name: server.Name, + Ipv4: server.Ipv4.Address, + CpuCores: server.CPUCores, + MemoryMiB: server.MemoryMiB, + } + if server.Ipv6.Address != nil { + serverData.Ipv6 = *server.Ipv6.Address + } else { + serverData.Ipv6 = "null" + } + for _, storage := range server.Storage { + serverData.Storage = append(serverData.Storage, struct { + Size string + Type string + }{storage.SizeGiB, storage.Type}) + } + servers = append(servers, serverData) } sort.Slice(servers, func(i, j int) bool { return servers[i].Name < servers[j].Name }) + log.Printf("Server Name :\t Server ID, \t Zone Name, \t ipv4 address, \t ipv6 address, \t Memory size, \t Storage size(Storage type)") for _, server := range servers { - log.Printf("%s: %s\n", server.Name, server.Host) + logMsg := fmt.Sprintf("%s :\t %s, \t %s, \t %s, \t %s, \t %sMiB", server.Name, server.ID, server.Zone, server.Ipv4, server.Ipv6, server.MemoryMiB) + for _, storage := range server.Storage { + logMsg += fmt.Sprintf(", \t %sGiB(%s)", storage.Size, storage.Type) + } + log.Printf(logMsg) } return nil From 748b42bf1b144df046bb0139d467566c7e1ebf3c Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:18:30 +0900 Subject: [PATCH 08/45] =?UTF-8?q?feat:=20Sakura=20API=E3=83=AA=E3=82=AF?= =?UTF-8?q?=E3=82=A8=E3=82=B9=E3=83=88=E3=81=AEURL=E3=83=91=E3=82=B9?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=80=81=E3=82=B5=E3=83=BC?= =?UTF-8?q?=E3=83=90=E3=83=BC=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 0026dc9..842ebce 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -83,7 +83,7 @@ type resultData struct { func (sc *hostsCommand) Execute(args []string) error { req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). - Get(config.C.Servers.Sakura.ApiURLPath). + Get(config.C.Servers.Sakura.ApiURLPath + "servers"). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). Request() if err != nil { From 53b50e17036db2ae78e700d010d8c9eeeb9f6f7f Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:29:32 +0900 Subject: [PATCH 09/45] =?UTF-8?q?feat:=20Sakura=20API=E3=81=AEURL=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=83=90=E3=83=BC=E6=83=85=E5=A0=B1=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE=E3=82=A8=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 6 +++--- pkg/server/hosts.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index fa6bca1..14c9a79 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -104,7 +104,7 @@ type CommandConfig struct { type ServersConfig struct { Sakura struct { Origin string `mapstructure:"origin" yaml:"origin"` - ApiURLPath string `mapstructure:"apiURLPath" yaml:"apiURLPath"` + ServersApiURLPath string `mapstructure:"serversApiURLPath" yaml:"serversApiURLPath"` BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"` } `mapstructure:"sakura" yaml:"sakura"` } @@ -139,8 +139,8 @@ func init() { viper.SetDefault("templates", nil) viper.SetDefault("commands", nil) - viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp/") - viper.SetDefault("servers.sakura.apiURLPath", "vps/api/v7/") + viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp") + viper.SetDefault("servers.sakura.serversApiURLPath", "/vps/api/v7/servers") viper.SetDefault("servers.sakura.bearerToken", "") } diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 842ebce..2f9bb34 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -83,7 +83,7 @@ type resultData struct { func (sc *hostsCommand) Execute(args []string) error { req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). - Get(config.C.Servers.Sakura.ApiURLPath + "servers"). + Get(config.C.Servers.Sakura.ServersApiURLPath). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). Request() if err != nil { From 4fa048be775d96c588c0753dea4e10d188157556 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:42:22 +0900 Subject: [PATCH 10/45] =?UTF-8?q?feat:=20restartCommand=E3=81=AE=E5=BC=95?= =?UTF-8?q?=E6=95=B0=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=80=81Sakura=20?= =?UTF-8?q?API=E3=81=B8=E3=81=AE=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/restart.go | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index ae43dc5..9887b40 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -5,9 +5,9 @@ import ( "io" "log" "net/http" + "strconv" "github.com/dghubble/sling" - "github.com/samber/lo" "github.com/traPtitech/sakura-DevOpsBot/pkg/config" ) @@ -17,35 +17,19 @@ type restartCommand struct { type m map[string]any func (sc *restartCommand) Execute(args []string) error { - if len(args) < 1 { + if len(args) != 1 { return fmt.Errorf("invalid arguments, expected server id") } - serverID := args[0] - args = args[1:] - - if len(args) < 1 { - return fmt.Errorf("invalid arguments, expected restart type (SOFT or HARD)") - } - - // args == [SOFT|HARD] - restartType := args[0] - - if !lo.Contains([]string{"SOFT", "HARD"}, restartType) { - return fmt.Errorf("unknown restart type: %s", restartType) - } - - token, err := getConohaAPIToken() + serverID, err := strconv.Atoi(args[0]) if err != nil { - return fmt.Errorf("failed to get conoha api token: %w", err) + return fmt.Errorf("invalid arguments, server id is must be integer") } req, err := sling.New(). - Base(config.C.Servers.Conoha.Origin.Compute). - Post(fmt.Sprintf("v2/%s/servers/%s/action", config.C.Servers.Conoha.TenantID, serverID)). - BodyJSON(m{"reboot": m{"type": args[0]}}). - Set("Accept", "application/json"). - Set("X-Auth-Token", token). + Base(config.C.Servers.Sakura.Origin). + Post(fmt.Sprintf("%s/%d/force-reboot", config.C.Servers.Sakura.ServersApiURLPath, serverID)). + Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). Request() if err != nil { return fmt.Errorf("failed to create restart request: %w", err) @@ -65,13 +49,12 @@ func (sc *restartCommand) Execute(args []string) error { logStr := fmt.Sprintf(`Request - URL: %s -- RestartType: %s Response - Header: %+v - Body: %s - Status: %s (Expected: 202) -`, req.URL.String(), restartType, resp.Header, string(respBody), resp.Status) +`, req.URL.String(), resp.Header, string(respBody), resp.Status) log.Println(logStr) if resp.StatusCode != http.StatusAccepted { From d1b3ed5ad7a5f47dbddf821b3b1ea71622c0e259 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:43:09 +0900 Subject: [PATCH 11/45] =?UTF-8?q?feat:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E7=BE=A9=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/restart.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 9887b40..621fb09 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -14,8 +14,6 @@ import ( type restartCommand struct { } -type m map[string]any - func (sc *restartCommand) Execute(args []string) error { if len(args) != 1 { return fmt.Errorf("invalid arguments, expected server id") From 55ef900cd78c3a0a7530cd214d693629bedebc81 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:43:27 +0900 Subject: [PATCH 12/45] =?UTF-8?q?feat:=20golang.org/x/sync=E3=81=AE?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 1 - go.sum | 2 -- 2 files changed, 3 deletions(-) diff --git a/go.mod b/go.mod index 9eda765..320f147 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/traPtitech/go-traq v0.0.0-20240725071454-97c7b85dc879 github.com/traPtitech/traq-ws-bot v1.2.1 go.uber.org/zap v1.27.0 - golang.org/x/sync v0.7.0 ) require ( diff --git a/go.sum b/go.sum index e71319e..c2cdfeb 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,6 @@ golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2 golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= From 150d9a08a9c0c905101f94f5efd034c109b0c3fd Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 23:53:23 +0900 Subject: [PATCH 13/45] =?UTF-8?q?feat:=20Dockerfile=E3=81=AECGO=5FENABLED?= =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 198b841..6eb9bc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM golang:1-alpine AS builder -ENV CGO_ENABLED 0 +ENV CGO_ENABLED=0 WORKDIR /work From 5b18eb008cf01e885f2262d080efcced439520c1 Mon Sep 17 00:00:00 2001 From: bn256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 12 Jan 2026 23:53:30 +0900 Subject: [PATCH 14/45] =?UTF-8?q?feat:=20IMAGE=5FNAME=E3=82=92sakura-dev-o?= =?UTF-8?q?ps-bot=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2ce103..219ebff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: - '**' env: - IMAGE_NAME: dev-ops-bot + IMAGE_NAME: sakura-dev-ops-bot jobs: goreleaser: From 04c4057a8a0ea9a15fb507d6ca4fdbc6e948bd5a Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:05:09 +0900 Subject: [PATCH 15/45] =?UTF-8?q?feat:=20=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E5=BF=9C=E7=AD=94=E3=81=AE=E5=9E=8B=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=80=81=E6=95=B0=E5=80=A4=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=83=89=E3=82=92int64=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 2f9bb34..01e4db4 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -17,23 +17,23 @@ type hostsCommand struct { type serversResponse struct { Results []serverResponse `json:"results"` - Count string `json:"count"` + Count int64 `json:"count"` Next *string `json:"next,omitempty"` Previous *string `json:"previous,omitempty"` } type serverResponse struct { - ID string `json:"id"` + ID int64 `json:"id"` Name string `json:"name"` Description string `json:"description"` ServiceType string `json:"service_type"` ServiceStatus string `json:"service_status"` - CPUCores string `json:"cpu_cores"` - MemoryMiB string `json:"memory_mebibytes"` + CPUCores int64 `json:"cpu_cores"` + MemoryMiB int64 `json:"memory_mebibytes"` Storage []struct { - Port string `json:"port"` + Port int64 `json:"port"` Type string `json:"type"` - SizeGiB string `json:"size_gibibytes"` + SizeGiB int64 `json:"size_gibibytes"` } `json:"storage"` Zone struct { Code string `json:"code"` @@ -67,15 +67,15 @@ type serverResponse struct { } type resultData struct { - ID string + ID int64 Zone string Name string Ipv4 string Ipv6 string - CpuCores string - MemoryMiB string + CpuCores int64 + MemoryMiB int64 Storage []struct { - Size string + Size int64 Type string } } @@ -128,7 +128,7 @@ func (sc *hostsCommand) Execute(args []string) error { } for _, storage := range server.Storage { serverData.Storage = append(serverData.Storage, struct { - Size string + Size int64 Type string }{storage.SizeGiB, storage.Type}) } From a1408c37580f938e0e1a93966a20dbedbb642791 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:08:09 +0900 Subject: [PATCH 16/45] =?UTF-8?q?feat:=20=E3=83=AD=E3=82=B0=E5=87=BA?= =?UTF-8?q?=E5=8A=9B=E3=81=ABCPU=E3=82=B3=E3=82=A2=E6=95=B0=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81=E3=83=95=E3=82=A9=E3=83=BC?= =?UTF-8?q?=E3=83=9E=E3=83=83=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 01e4db4..be31aa2 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -139,11 +139,11 @@ func (sc *hostsCommand) Execute(args []string) error { return servers[i].Name < servers[j].Name }) - log.Printf("Server Name :\t Server ID, \t Zone Name, \t ipv4 address, \t ipv6 address, \t Memory size, \t Storage size(Storage type)") + log.Printf("Server Name :\t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory size, \t Storage size(Storage type)") for _, server := range servers { - logMsg := fmt.Sprintf("%s :\t %s, \t %s, \t %s, \t %s, \t %sMiB", server.Name, server.ID, server.Zone, server.Ipv4, server.Ipv6, server.MemoryMiB) + logMsg := fmt.Sprintf("%s :\t %d, \t %s, \t %d, \t %s, \t %s, \t %dMiB", server.Name, server.ID, server.Zone, server.CpuCores, server.Ipv4, server.Ipv6, server.MemoryMiB) for _, storage := range server.Storage { - logMsg += fmt.Sprintf(", \t %sGiB(%s)", storage.Size, storage.Type) + logMsg += fmt.Sprintf(", \t %dGiB(%s)", storage.Size, storage.Type) } log.Printf(logMsg) } From 17ac82c533230936d8193614fa683bcc45ad5c9b Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:34:58 +0900 Subject: [PATCH 17/45] =?UTF-8?q?feat:=20Params=E6=A7=8B=E9=80=A0=E4=BD=93?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81API=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88=E3=81=AB=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=8D=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index be31aa2..4e81b1f 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -15,6 +15,19 @@ import ( type hostsCommand struct { } +type Params struct { + Page int64 `json:"page,omitempty"` + Per_page int64 `json:"per_page,omitempty"` + Id string `json:"id,omitempty"` + Switch int64 `json:"switch,omitempty"` + Zone_code string `json:"zone_code,omitempty"` + Service_type string `json:"service_type,omitempty"` + Ipv4_address string `json:"ipv4_address,omitempty"` + Monitoring_resource_id string `json:"monitoring_resource_id,omitempty"` + Sort string `json:"sort,omitempty"` + Search string `json:"search,omitempty"` +} + type serversResponse struct { Results []serverResponse `json:"results"` Count int64 `json:"count"` @@ -81,10 +94,12 @@ type resultData struct { } func (sc *hostsCommand) Execute(args []string) error { + datasPerPage := 100 req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). Get(config.C.Servers.Sakura.ServersApiURLPath). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). + QueryStruct(&Params{Per_page: int64(datasPerPage)}). Request() if err != nil { return fmt.Errorf("failed to create hosts request: %w", err) @@ -147,6 +162,9 @@ func (sc *hostsCommand) Execute(args []string) error { } log.Printf(logMsg) } + if response.Count > int64(datasPerPage) { + log.Printf("Nod all results are displayed. Total count: %d", response.Count) + } return nil } From 6efd0b3f828f729f7180f0bbcff491d909204152 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:37:40 +0900 Subject: [PATCH 18/45] =?UTF-8?q?feat:=20=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BCAPI=E3=81=AEURL=E3=83=91=E3=82=B9=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 4 ++-- pkg/server/hosts.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 14c9a79..67c2c5e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -104,7 +104,7 @@ type CommandConfig struct { type ServersConfig struct { Sakura struct { Origin string `mapstructure:"origin" yaml:"origin"` - ServersApiURLPath string `mapstructure:"serversApiURLPath" yaml:"serversApiURLPath"` + ServersAPIURLPath string `mapstructure:"serversAPIURLPath" yaml:"serversAPIURLPath"` BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"` } `mapstructure:"sakura" yaml:"sakura"` } @@ -140,7 +140,7 @@ func init() { viper.SetDefault("commands", nil) viper.SetDefault("servers.sakura.origin", "https://secure.sakura.ad.jp") - viper.SetDefault("servers.sakura.serversApiURLPath", "/vps/api/v7/servers") + viper.SetDefault("servers.sakura.serversAPIURLPath", "/vps/api/v7/servers") viper.SetDefault("servers.sakura.bearerToken", "") } diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 4e81b1f..910333f 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -97,7 +97,7 @@ func (sc *hostsCommand) Execute(args []string) error { datasPerPage := 100 req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). - Get(config.C.Servers.Sakura.ServersApiURLPath). + Get(config.C.Servers.Sakura.ServersAPIURLPath). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). QueryStruct(&Params{Per_page: int64(datasPerPage)}). Request() From c048472a033d2c0daabe6734efbe168fa9897718 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:38:42 +0900 Subject: [PATCH 19/45] =?UTF-8?q?feat:=20=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BCAPI=E3=81=AEURL=E3=83=91=E3=82=B9=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3=20=E4=B8=80?= =?UTF-8?q?=E3=81=A4=E5=89=8D=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=81=AB=E6=BC=8F?= =?UTF-8?q?=E3=82=8C=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/restart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 621fb09..199e966 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -26,7 +26,7 @@ func (sc *restartCommand) Execute(args []string) error { req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). - Post(fmt.Sprintf("%s/%d/force-reboot", config.C.Servers.Sakura.ServersApiURLPath, serverID)). + Post(fmt.Sprintf("%s/%d/force-reboot", config.C.Servers.Sakura.ServersAPIURLPath, serverID)). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). Request() if err != nil { From 4954d3e0c5bafe31ec5361e2eac7ac08dc9baa4e Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:39:13 +0900 Subject: [PATCH 20/45] =?UTF-8?q?fix:=20=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E6=96=87?= =?UTF-8?q?=E6=B3=95=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/restart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 199e966..e02fcbe 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -21,7 +21,7 @@ func (sc *restartCommand) Execute(args []string) error { serverID, err := strconv.Atoi(args[0]) if err != nil { - return fmt.Errorf("invalid arguments, server id is must be integer") + return fmt.Errorf("invalid arguments, server id must be an integer") } req, err := sling.New(). From 1aae5d04e7505852ae305719368d3adddb7c1c5e Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:46:20 +0900 Subject: [PATCH 21/45] =?UTF-8?q?feat:=20ServersAPIURLPath=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=97=E3=80=81=E5=85=88=E9=A0=AD=E3=81=AB=E3=82=B9=E3=83=A9?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=81=8C=E5=BF=85=E8=A6=81=E3=81=A7?= =?UTF-8?q?=E3=81=82=E3=82=8B=E3=81=93=E3=81=A8=E3=82=92=E6=98=8E=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 67c2c5e..057f9bb 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -103,9 +103,10 @@ type CommandConfig struct { type ServersConfig struct { Sakura struct { - Origin string `mapstructure:"origin" yaml:"origin"` - ServersAPIURLPath string `mapstructure:"serversAPIURLPath" yaml:"serversAPIURLPath"` - BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"` + Origin string `mapstructure:"origin" yaml:"origin"` + // ServersAPIURLPath must start with "/" + ServersAPIURLPath string `mapstructure:"serversAPIURLPath" yaml:"serversAPIURLPath"` + BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"` } `mapstructure:"sakura" yaml:"sakura"` } From 1e18812fa1cca16abb9dc074b1dbff638726054f Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:46:25 +0900 Subject: [PATCH 22/45] =?UTF-8?q?feat:=20API=E3=83=88=E3=83=BC=E3=82=AF?= =?UTF-8?q?=E3=83=B3=E3=81=8C=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AE=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 4 ++++ pkg/server/restart.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 910333f..35d0951 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -94,6 +94,10 @@ type resultData struct { } func (sc *hostsCommand) Execute(args []string) error { + if (len(config.C.Servers.Sakura.BearerToken) == 0){ + return fmt.Errorf("API token has not been set yet") + } + datasPerPage := 100 req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). diff --git a/pkg/server/restart.go b/pkg/server/restart.go index e02fcbe..59bc4df 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -24,6 +24,10 @@ func (sc *restartCommand) Execute(args []string) error { return fmt.Errorf("invalid arguments, server id must be an integer") } + if len(config.C.Servers.Sakura.BearerToken) == 0 { + return fmt.Errorf("API token has not been set yet") + } + req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). Post(fmt.Sprintf("%s/%d/force-reboot", config.C.Servers.Sakura.ServersAPIURLPath, serverID)). From f81389e902f861b1fe775ccb924d8dd86536a348 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 16:49:06 +0900 Subject: [PATCH 23/45] =?UTF-8?q?fix:=20API=E3=83=88=E3=83=BC=E3=82=AF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=80=81=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88=E3=82=92?= =?UTF-8?q?=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 35d0951..98247dd 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -94,7 +94,7 @@ type resultData struct { } func (sc *hostsCommand) Execute(args []string) error { - if (len(config.C.Servers.Sakura.BearerToken) == 0){ + if len(config.C.Servers.Sakura.BearerToken) == 0 { return fmt.Errorf("API token has not been set yet") } @@ -158,11 +158,11 @@ func (sc *hostsCommand) Execute(args []string) error { return servers[i].Name < servers[j].Name }) - log.Printf("Server Name :\t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory size, \t Storage size(Storage type)") + log.Printf("Server Name :\t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory Size (MiB), \t Storage Size (GiB) / type") for _, server := range servers { logMsg := fmt.Sprintf("%s :\t %d, \t %s, \t %d, \t %s, \t %s, \t %dMiB", server.Name, server.ID, server.Zone, server.CpuCores, server.Ipv4, server.Ipv6, server.MemoryMiB) for _, storage := range server.Storage { - logMsg += fmt.Sprintf(", \t %dGiB(%s)", storage.Size, storage.Type) + logMsg += fmt.Sprintf(", \t %dGiB / %s", storage.Size, storage.Type) } log.Printf(logMsg) } From 6a050f966ab0879447cbf40f5c80b2bdbb7e3b71 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:00:31 +0900 Subject: [PATCH 24/45] Update pkg/server/hosts.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/server/hosts.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 98247dd..d8bfd20 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -15,17 +15,17 @@ import ( type hostsCommand struct { } -type Params struct { - Page int64 `json:"page,omitempty"` - Per_page int64 `json:"per_page,omitempty"` - Id string `json:"id,omitempty"` - Switch int64 `json:"switch,omitempty"` - Zone_code string `json:"zone_code,omitempty"` - Service_type string `json:"service_type,omitempty"` - Ipv4_address string `json:"ipv4_address,omitempty"` - Monitoring_resource_id string `json:"monitoring_resource_id,omitempty"` - Sort string `json:"sort,omitempty"` - Search string `json:"search,omitempty"` +type params struct { + Page int64 `json:"page,omitempty"` + PerPage int64 `json:"per_page,omitempty"` + ID string `json:"id,omitempty"` + Switch int64 `json:"switch,omitempty"` + ZoneCode string `json:"zone_code,omitempty"` + ServiceType string `json:"service_type,omitempty"` + IPv4Address string `json:"ipv4_address,omitempty"` + MonitoringResourceID string `json:"monitoring_resource_id,omitempty"` + Sort string `json:"sort,omitempty"` + Search string `json:"search,omitempty"` } type serversResponse struct { From f5a0e21a00f1b7ba4a6a9ac5a69975065cff6a72 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:01:36 +0900 Subject: [PATCH 25/45] =?UTF-8?q?fix:=20=E3=83=91=E3=83=A9=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E6=A7=8B=E9=80=A0=E4=BD=93=E3=81=AE=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E5=90=8D=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index d8bfd20..70c4eb8 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -103,7 +103,7 @@ func (sc *hostsCommand) Execute(args []string) error { Base(config.C.Servers.Sakura.Origin). Get(config.C.Servers.Sakura.ServersAPIURLPath). Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). - QueryStruct(&Params{Per_page: int64(datasPerPage)}). + QueryStruct(¶ms{PerPage: int64(datasPerPage)}). Request() if err != nil { return fmt.Errorf("failed to create hosts request: %w", err) From 2418f899372693071d89096beca2bd45aa744494 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:03:48 +0900 Subject: [PATCH 26/45] =?UTF-8?q?fix:=20=E3=83=88=E3=83=BC=E3=82=AF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=A7?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=E3=82=92=E9=99=A4=E5=8E=BB=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 21 +++++++++++---------- pkg/server/restart.go | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 70c4eb8..4c21365 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "sort" + "strings" "github.com/dghubble/sling" "github.com/traPtitech/sakura-DevOpsBot/pkg/config" @@ -16,16 +17,16 @@ type hostsCommand struct { } type params struct { - Page int64 `json:"page,omitempty"` - PerPage int64 `json:"per_page,omitempty"` - ID string `json:"id,omitempty"` - Switch int64 `json:"switch,omitempty"` - ZoneCode string `json:"zone_code,omitempty"` - ServiceType string `json:"service_type,omitempty"` - IPv4Address string `json:"ipv4_address,omitempty"` + Page int64 `json:"page,omitempty"` + PerPage int64 `json:"per_page,omitempty"` + ID string `json:"id,omitempty"` + Switch int64 `json:"switch,omitempty"` + ZoneCode string `json:"zone_code,omitempty"` + ServiceType string `json:"service_type,omitempty"` + IPv4Address string `json:"ipv4_address,omitempty"` MonitoringResourceID string `json:"monitoring_resource_id,omitempty"` - Sort string `json:"sort,omitempty"` - Search string `json:"search,omitempty"` + Sort string `json:"sort,omitempty"` + Search string `json:"search,omitempty"` } type serversResponse struct { @@ -94,7 +95,7 @@ type resultData struct { } func (sc *hostsCommand) Execute(args []string) error { - if len(config.C.Servers.Sakura.BearerToken) == 0 { + if len(strings.TrimSpace(config.C.Servers.Sakura.BearerToken)) == 0 { return fmt.Errorf("API token has not been set yet") } diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 59bc4df..6bf8d72 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -6,6 +6,7 @@ import ( "log" "net/http" "strconv" + "strings" "github.com/dghubble/sling" "github.com/traPtitech/sakura-DevOpsBot/pkg/config" @@ -24,7 +25,7 @@ func (sc *restartCommand) Execute(args []string) error { return fmt.Errorf("invalid arguments, server id must be an integer") } - if len(config.C.Servers.Sakura.BearerToken) == 0 { + if len(strings.TrimSpace(config.C.Servers.Sakura.BearerToken)) == 0 { return fmt.Errorf("API token has not been set yet") } From 7c21e713c13a3d0b821a3ed12a87090937f60e38 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:04:09 +0900 Subject: [PATCH 27/45] =?UTF-8?q?fix:=20=E3=83=AD=E3=82=B0=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E3=82=B9=E3=83=9A?= =?UTF-8?q?=E3=83=AB=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 4c21365..7d1759d 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -168,7 +168,7 @@ func (sc *hostsCommand) Execute(args []string) error { log.Printf(logMsg) } if response.Count > int64(datasPerPage) { - log.Printf("Nod all results are displayed. Total count: %d", response.Count) + log.Printf("Not all results are displayed. Total count: %d", response.Count) } return nil From 7222a01dede63eb2dc311c31ee90110eb66379f0 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:10:36 +0900 Subject: [PATCH 28/45] =?UTF-8?q?fix:=20=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AB=E7=84=A1?= =?UTF-8?q?=E5=8A=B9=E3=81=AA=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BCID?= =?UTF-8?q?=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/restart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 6bf8d72..c69616b 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -22,7 +22,7 @@ func (sc *restartCommand) Execute(args []string) error { serverID, err := strconv.Atoi(args[0]) if err != nil { - return fmt.Errorf("invalid arguments, server id must be an integer") + return fmt.Errorf("invalid arguments, server id must be an integer: %q", args[0]) } if len(strings.TrimSpace(config.C.Servers.Sakura.BearerToken)) == 0 { From 4d960f3d938667d2dbc2c79252990e7f0427a883 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:11:23 +0900 Subject: [PATCH 29/45] =?UTF-8?q?fix:=20=E3=83=AD=E3=82=B0=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 7d1759d..9d9d754 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -159,9 +159,9 @@ func (sc *hostsCommand) Execute(args []string) error { return servers[i].Name < servers[j].Name }) - log.Printf("Server Name :\t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory Size (MiB), \t Storage Size (GiB) / type") + log.Printf("Server Name, \t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory Size (MiB), \t Storage Size (GiB) / type") for _, server := range servers { - logMsg := fmt.Sprintf("%s :\t %d, \t %s, \t %d, \t %s, \t %s, \t %dMiB", server.Name, server.ID, server.Zone, server.CpuCores, server.Ipv4, server.Ipv6, server.MemoryMiB) + logMsg := fmt.Sprintf("%s, \t %d, \t %s, \t %d, \t %s, \t %s, \t %dMiB", server.Name, server.ID, server.Zone, server.CpuCores, server.Ipv4, server.Ipv6, server.MemoryMiB) for _, storage := range server.Storage { logMsg += fmt.Sprintf(", \t %dGiB / %s", storage.Size, storage.Type) } From 03649b47d80c345e85c66bf978ed19462d4b2f71 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:17:14 +0900 Subject: [PATCH 30/45] =?UTF-8?q?fix:=20=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BCAPI=20URL=E3=83=91=E3=82=B9=E3=81=AE=E5=85=88=E9=A0=AD?= =?UTF-8?q?=E3=81=AB=E3=82=B9=E3=83=A9=E3=83=83=E3=82=B7=E3=83=A5=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/server/hosts.go | 4 ++++ pkg/server/restart.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 9d9d754..d304138 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -99,6 +99,10 @@ func (sc *hostsCommand) Execute(args []string) error { return fmt.Errorf("API token has not been set yet") } + if strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { + config.C.Servers.Sakura.ServersAPIURLPath = "/" + config.C.Servers.Sakura.ServersAPIURLPath + } + datasPerPage := 100 req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). diff --git a/pkg/server/restart.go b/pkg/server/restart.go index c69616b..ae76f02 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -29,6 +29,10 @@ func (sc *restartCommand) Execute(args []string) error { return fmt.Errorf("API token has not been set yet") } + if strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { + config.C.Servers.Sakura.ServersAPIURLPath = "/" + config.C.Servers.Sakura.ServersAPIURLPath + } + req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). Post(fmt.Sprintf("%s/%d/force-reboot", config.C.Servers.Sakura.ServersAPIURLPath, serverID)). From 078f2ca06cc5964219b220a5df54b6f3b7d2591f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:20:38 +0000 Subject: [PATCH 31/45] Initial plan From 228c59a4470a31a82ddd4bcd8d0c78f4db1fdcab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:23:25 +0000 Subject: [PATCH 32/45] fix: remove sensitive information from restart request logs Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/restart.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index ae76f02..7d7c695 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -2,7 +2,6 @@ package server import ( "fmt" - "io" "log" "net/http" "strconv" @@ -49,24 +48,11 @@ func (sc *restartCommand) Execute(args []string) error { } defer resp.Body.Close() - respBody, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("failed to read response body: %w", err) - } - - logStr := fmt.Sprintf(`Request -- URL: %s - -Response -- Header: %+v -- Body: %s -- Status: %s (Expected: 202) -`, req.URL.String(), resp.Header, string(respBody), resp.Status) - log.Println(logStr) - if resp.StatusCode != http.StatusAccepted { return fmt.Errorf("incorrect status code: %s", resp.Status) } + log.Printf("Server restart requested successfully: URL=%s, Status=%s", req.URL.String(), resp.Status) + return nil } From 3ab9426f25fad972df8b3db6b861e05e088e2e24 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:24:11 +0000 Subject: [PATCH 33/45] refactor: log server ID instead of full URL for better security Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/restart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/restart.go b/pkg/server/restart.go index 7d7c695..d878265 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -52,7 +52,7 @@ func (sc *restartCommand) Execute(args []string) error { return fmt.Errorf("incorrect status code: %s", resp.Status) } - log.Printf("Server restart requested successfully: URL=%s, Status=%s", req.URL.String(), resp.Status) + log.Printf("Server restart requested successfully: ServerID=%d, Status=%s", serverID, resp.Status) return nil } From f8eeccb26b3078bbe6d4e926904b5db3b073bab0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:26:14 +0000 Subject: [PATCH 34/45] fix: correct URL path prefix check logic Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/hosts.go | 2 +- pkg/server/restart.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index d304138..1b4e957 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -99,7 +99,7 @@ func (sc *hostsCommand) Execute(args []string) error { return fmt.Errorf("API token has not been set yet") } - if strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { + if !strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { config.C.Servers.Sakura.ServersAPIURLPath = "/" + config.C.Servers.Sakura.ServersAPIURLPath } diff --git a/pkg/server/restart.go b/pkg/server/restart.go index d878265..28c853b 100644 --- a/pkg/server/restart.go +++ b/pkg/server/restart.go @@ -28,7 +28,7 @@ func (sc *restartCommand) Execute(args []string) error { return fmt.Errorf("API token has not been set yet") } - if strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { + if !strings.HasPrefix(config.C.Servers.Sakura.ServersAPIURLPath, "/") { config.C.Servers.Sakura.ServersAPIURLPath = "/" + config.C.Servers.Sakura.ServersAPIURLPath } From e36c6e305ffd8a2065523d538828db772021823e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:40:17 +0000 Subject: [PATCH 35/45] Initial plan From e2c35c9ed5576123e29546f85fe45c3da84b8ac2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:42:49 +0000 Subject: [PATCH 36/45] feat: implement full pagination to fetch all server pages Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/hosts.go | 106 ++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 1b4e957..9f0c4fa 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -104,59 +104,69 @@ func (sc *hostsCommand) Execute(args []string) error { } datasPerPage := 100 - req, err := sling.New(). - Base(config.C.Servers.Sakura.Origin). - Get(config.C.Servers.Sakura.ServersAPIURLPath). - Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). - QueryStruct(¶ms{PerPage: int64(datasPerPage)}). - Request() - if err != nil { - return fmt.Errorf("failed to create hosts request: %w", err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return fmt.Errorf("failed to get hosts: %w", err) - } - defer resp.Body.Close() - - respBody, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("failed to read response body: %w", err) - } + servers := []resultData{} + page := 1 + + // Fetch all pages of results + for { + req, err := sling.New(). + Base(config.C.Servers.Sakura.Origin). + Get(config.C.Servers.Sakura.ServersAPIURLPath). + Add("Authorization", "Bearer "+config.C.Servers.Sakura.BearerToken). + QueryStruct(¶ms{PerPage: int64(datasPerPage), Page: int64(page)}). + Request() + if err != nil { + return fmt.Errorf("failed to create hosts request: %w", err) + } - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("invalid status code: %s (expected: 200)", resp.Status) - } + resp, err := http.DefaultClient.Do(req) + if err != nil { + return fmt.Errorf("failed to get hosts: %w", err) + } - var response serversResponse - if err := json.Unmarshal(respBody, &response); err != nil { - return fmt.Errorf("failed to unmarshal response body: %w", err) - } + respBody, err := io.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + return fmt.Errorf("failed to read response body: %w", err) + } - servers := []resultData{} + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("invalid status code: %s (expected: 200)", resp.Status) + } - for _, server := range response.Results { - serverData := resultData{ - ID: server.ID, - Zone: server.Zone.Name, - Name: server.Name, - Ipv4: server.Ipv4.Address, - CpuCores: server.CPUCores, - MemoryMiB: server.MemoryMiB, + var response serversResponse + if err := json.Unmarshal(respBody, &response); err != nil { + return fmt.Errorf("failed to unmarshal response body: %w", err) } - if server.Ipv6.Address != nil { - serverData.Ipv6 = *server.Ipv6.Address - } else { - serverData.Ipv6 = "null" + + for _, server := range response.Results { + serverData := resultData{ + ID: server.ID, + Zone: server.Zone.Name, + Name: server.Name, + Ipv4: server.Ipv4.Address, + CpuCores: server.CPUCores, + MemoryMiB: server.MemoryMiB, + } + if server.Ipv6.Address != nil { + serverData.Ipv6 = *server.Ipv6.Address + } else { + serverData.Ipv6 = "null" + } + for _, storage := range server.Storage { + serverData.Storage = append(serverData.Storage, struct { + Size int64 + Type string + }{storage.SizeGiB, storage.Type}) + } + servers = append(servers, serverData) } - for _, storage := range server.Storage { - serverData.Storage = append(serverData.Storage, struct { - Size int64 - Type string - }{storage.SizeGiB, storage.Type}) + + // Check if there are more pages + if response.Next == nil { + break } - servers = append(servers, serverData) + page++ } sort.Slice(servers, func(i, j int) bool { @@ -171,9 +181,7 @@ func (sc *hostsCommand) Execute(args []string) error { } log.Printf(logMsg) } - if response.Count > int64(datasPerPage) { - log.Printf("Not all results are displayed. Total count: %d", response.Count) - } + log.Printf("Total servers: %d", len(servers)) return nil } From 0c540042c400df392e08e753ff69a736ce16bdc7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:43:27 +0000 Subject: [PATCH 37/45] fix: use defer for response body close to ensure cleanup Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 9f0c4fa..70e54ca 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -123,9 +123,9 @@ func (sc *hostsCommand) Execute(args []string) error { if err != nil { return fmt.Errorf("failed to get hosts: %w", err) } + defer resp.Body.Close() respBody, err := io.ReadAll(resp.Body) - resp.Body.Close() if err != nil { return fmt.Errorf("failed to read response body: %w", err) } From d83107a1c951d852adbb83077aea57747bcef720 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:44:17 +0000 Subject: [PATCH 38/45] fix: close response body immediately and add max page limit Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/hosts.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 70e54ca..d8f4c1f 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -106,9 +106,10 @@ func (sc *hostsCommand) Execute(args []string) error { datasPerPage := 100 servers := []resultData{} page := 1 + maxPages := 1000 // Prevent infinite loops // Fetch all pages of results - for { + for page <= maxPages { req, err := sling.New(). Base(config.C.Servers.Sakura.Origin). Get(config.C.Servers.Sakura.ServersAPIURLPath). @@ -123,9 +124,9 @@ func (sc *hostsCommand) Execute(args []string) error { if err != nil { return fmt.Errorf("failed to get hosts: %w", err) } - defer resp.Body.Close() respBody, err := io.ReadAll(resp.Body) + resp.Body.Close() if err != nil { return fmt.Errorf("failed to read response body: %w", err) } From 5c73793fa778feb7a45fcfdd7161ed9e3fcc5a2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:44:56 +0000 Subject: [PATCH 39/45] fix: check status code before reading body and ensure cleanup Co-authored-by: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> --- pkg/server/hosts.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index d8f4c1f..18744f5 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -125,16 +125,17 @@ func (sc *hostsCommand) Execute(args []string) error { return fmt.Errorf("failed to get hosts: %w", err) } + if resp.StatusCode != http.StatusOK { + resp.Body.Close() + return fmt.Errorf("invalid status code: %s (expected: 200)", resp.Status) + } + respBody, err := io.ReadAll(resp.Body) resp.Body.Close() if err != nil { return fmt.Errorf("failed to read response body: %w", err) } - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("invalid status code: %s (expected: 200)", resp.Status) - } - var response serversResponse if err := json.Unmarshal(respBody, &response); err != nil { return fmt.Errorf("failed to unmarshal response body: %w", err) From 9e58d2df114960b5508d8758a95c5b4d17eff7e2 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:40:05 +0900 Subject: [PATCH 40/45] fix: reduce max pages limit to prevent excessive resource usage --- pkg/server/hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 18744f5..1498b65 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -106,7 +106,7 @@ func (sc *hostsCommand) Execute(args []string) error { datasPerPage := 100 servers := []resultData{} page := 1 - maxPages := 1000 // Prevent infinite loops + maxPages := 10 // Fetch all pages of results for page <= maxPages { From 16ade77ca81760064403db50f1d0f90c5bd1b008 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 01:27:19 +0900 Subject: [PATCH 41/45] fix: change prefix length and plan code types to improve data handling --- pkg/server/hosts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 1498b65..94bc7b4 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -65,14 +65,14 @@ type serverResponse struct { } `json:"ipv4"` Ipv6 struct { Address *string `json:"address,omitempty"` - PrefixLen *string `json:"prefixlen,omitempty"` + PrefixLen *int64 `json:"prefixlen,omitempty"` Gateway *string `json:"gateway,omitempty"` NameServers []string `json:"nameservers"` HostName *string `json:"hostname,omitempty"` PTR *string `json:"ptr,omitempty"` } `json:"ipv6"` Contract struct { - PlanCode string `json:"plan_code"` + PlanCode int64 `json:"plan_code"` PlanName string `json:"plan_name"` ServiceCode string `json:"service_code"` } `json:"contract"` From f41995225cec942439e6d5859792a4f939526481 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 01:34:22 +0900 Subject: [PATCH 42/45] fix: enhance server output formatting with tabwriter for better readability --- pkg/server/hosts.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/pkg/server/hosts.go b/pkg/server/hosts.go index 94bc7b4..c56bb86 100644 --- a/pkg/server/hosts.go +++ b/pkg/server/hosts.go @@ -6,8 +6,10 @@ import ( "io" "log" "net/http" + "os" "sort" "strings" + "text/tabwriter" "github.com/dghubble/sling" "github.com/traPtitech/sakura-DevOpsBot/pkg/config" @@ -175,14 +177,34 @@ func (sc *hostsCommand) Execute(args []string) error { return servers[i].Name < servers[j].Name }) - log.Printf("Server Name, \t Server ID, \t Zone Name, \t cpu cores, \t ipv4 address, \t ipv6 address, \t Memory Size (MiB), \t Storage Size (GiB) / type") + // Create tabwriter for aligned output + // Parameters: output, minwidth, tabwidth, padding, padchar, flags + w := tabwriter.NewWriter(os.Stderr, 0, 4, 2, ' ', 0) + fmt.Fprintln(w, "Server Name\tServer ID\tZone Name\tCPU Cores\tIPv4 Address\tIPv6 Address\tMemory (MiB)\tStorage") + fmt.Fprintln(w, "-----------\t---------\t---------\t---------\t------------\t------------\t------------\t-------") + for _, server := range servers { - logMsg := fmt.Sprintf("%s, \t %d, \t %s, \t %d, \t %s, \t %s, \t %dMiB", server.Name, server.ID, server.Zone, server.CpuCores, server.Ipv4, server.Ipv6, server.MemoryMiB) - for _, storage := range server.Storage { - logMsg += fmt.Sprintf(", \t %dGiB / %s", storage.Size, storage.Type) + storageInfo := "" + for i, storage := range server.Storage { + if i > 0 { + storageInfo += ", " + } + storageInfo += fmt.Sprintf("%dGiB/%s", storage.Size, storage.Type) } - log.Printf(logMsg) + + fmt.Fprintf(w, "%s\t%d\t%s\t%d\t%s\t%s\t%d\t%s\n", + server.Name, + server.ID, + server.Zone, + server.CpuCores, + server.Ipv4, + server.Ipv6, + server.MemoryMiB, + storageInfo, + ) } + + w.Flush() log.Printf("Total servers: %d", len(servers)) return nil From b006daee252d69801277b2aa16e7b6fcba7dcb2c Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:49:21 +0900 Subject: [PATCH 43/45] fix: update project name and commands to reflect sakura branding --- .goreleaser.yml | 6 +++--- cmd/root.go | 4 ++-- cmd/server.go | 2 +- pkg/bot/help.go | 2 +- pkg/server/server.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b00e99c..824b09f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,16 +1,16 @@ # .goreleaser.yml -project_name: DevOpsBot +project_name: sakura-DevOpsBot before: hooks: - go mod download builds: - - binary: devops-bot + - binary: sakura-devops-bot env: - CGO_ENABLED=0 ldflags: - -s - -w - - -X github.com/traPtitech/DevOpsBot/pkg/utils.version={{.Version}} + - -X github.com/traPtitech/sakura-DevOpsBot/pkg/utils.version={{.Version}} goos: - darwin - linux diff --git a/cmd/root.go b/cmd/root.go index eb7e9a8..68cd6b6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,11 +12,11 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "DevOpsBot", + Use: "sakura-DevOpsBot", Short: "A ChatOps bot for executing arbitrary shell commands.", SilenceUsage: true, PreRun: func(cmd *cobra.Command, args []string) { - fmt.Printf("DevOpsBot v%s initializing\n", utils.Version()) + fmt.Printf("sakura-DevOpsBot v%s initializing\n", utils.Version()) }, RunE: func(cmd *cobra.Command, args []string) error { return bot.Run(cmd.Context()) diff --git a/cmd/server.go b/cmd/server.go index 02d46e6..60f360a 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -8,7 +8,7 @@ import ( var serverCmd = &cobra.Command{ Use: "server", - Short: "ConoHa server manipulation", + Short: "Sakura server manipulation", SilenceUsage: true, // Do not display command usage when RunE returns error RunE: func(cmd *cobra.Command, args []string) error { s, err := server.Compile() diff --git a/pkg/bot/help.go b/pkg/bot/help.go index f61e96b..f51d2f7 100644 --- a/pkg/bot/help.go +++ b/pkg/bot/help.go @@ -21,7 +21,7 @@ func (h *HelpCommand) Execute(ctx domain.Context) error { // Root usage if len(args) == 0 { - lines = append(lines, fmt.Sprintf("## DevOpsBot v%s", utils.Version())) + lines = append(lines, fmt.Sprintf("## sakura-DevOpsBot v%s", utils.Version())) lines = append(lines, "") lines = append(lines, h.root.HelpMessage(0, true)...) lines = append(lines, "") diff --git a/pkg/server/server.go b/pkg/server/server.go index 6c64cb9..b041a68 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -15,7 +15,7 @@ func Compile() (*ServersCommand, error) { cmd.Commands = make(map[string]command) cmd.Commands["restart"] = &restartCommand{} - cmd.Commands["hosts"] = &hostsCommand{} + cmd.Commands["info"] = &hostsCommand{} return cmd, nil } From b7227ab84986e7ea0aedf3ce04e7abf7b2c669d6 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 23:44:01 +0900 Subject: [PATCH 44/45] fix: update GitHub Actions workflow to use latest action versions and improve environment variable handling --- .github/workflows/release.yml | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 219ebff..542f27a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,16 +9,21 @@ on: env: IMAGE_NAME: sakura-dev-ops-bot + REGISTRY: ghcr.io jobs: goreleaser: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: "./go.mod" @@ -34,37 +39,33 @@ jobs: name: Build Docker Image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set IMAGE_TAG env - run: echo "IMAGE_TAG=$(echo ${GITHUB_REF:11})" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v6 + + - name: Extract version from tag + id: version + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v3 - with: - platforms: all + - name: Set up Docker Buildx - id: buildx uses: docker/setup-buildx-action@v3 - - name: Show available platforms - run: echo ${{ steps.buildx.outputs.platforms }} - - name: Get lowercased owner name - run: echo "REPO_OWNER=${GITHUB_REPOSITORY_OWNER@L}" >> $GITHUB_ENV - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io - username: ${{ env.REPO_OWNER }} + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . push: true platforms: linux/amd64,linux/arm64 - build-args: | - VERSION=${{ env.IMAGE_TAG }} + build-args: VERSION=${{ steps.version.outputs.tag }} tags: | - ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:latest - ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} + ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} From ebeb6e7148c504922eb4acc0e12881ce14164222 Mon Sep 17 00:00:00 2001 From: blancnoir256 <116483234+blancnoir256@users.noreply.github.com> Date: Mon, 19 Jan 2026 23:45:05 +0900 Subject: [PATCH 45/45] fix: update GitHub Actions to use latest action versions for consistency --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e59906b..1975cbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,8 @@ jobs: name: Mod runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version-file: "./go.mod" - run: go mod download @@ -20,8 +20,8 @@ jobs: env: CGO_ENABLED: "0" steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version-file: "./go.mod" - run: go build