Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0b3832b
refactor: モジュール名を DevOpsBot から sakura-DevOpsBot に変更
blancnoir256 Dec 28, 2025
68bd67d
fix: 修正されたパッケージ名を sakura-DevOpsBot に更新
blancnoir256 Jan 1, 2026
2b9f644
feat: Sakuraサーバー設定を追加し、Conoha設定を削除
blancnoir256 Jan 1, 2026
2b02b19
del さくらではtokenを使用しないため
blancnoir256 Jan 1, 2026
9a76369
add コメント
blancnoir256 Jan 6, 2026
e980189
feat: Sakuraサーバー設定を更新し、API URLパスを追加
blancnoir256 Jan 6, 2026
c30c7df
feat: サーバー応答の構造体を更新し、Sakura APIへのリクエストを修正
blancnoir256 Jan 6, 2026
748b42b
feat: Sakura APIリクエストのURLパスを修正し、サーバー情報を取得するように変更
blancnoir256 Jan 12, 2026
53b50e1
feat: Sakura APIのURLパスを更新し、サーバー情報取得のためのエンドポイントを修正
blancnoir256 Jan 12, 2026
4fa048b
feat: restartCommandの引数を修正し、Sakura APIへのリクエストを更新
blancnoir256 Jan 12, 2026
d1b3ed5
feat: 不要な型定義を削除
blancnoir256 Jan 12, 2026
55ef900
feat: golang.org/x/syncの依存関係を削除
blancnoir256 Jan 12, 2026
150d9a0
feat: DockerfileのCGO_ENABLED環境変数の設定を修正
blancnoir256 Jan 12, 2026
5b18eb0
feat: IMAGE_NAMEをsakura-dev-ops-botに変更
blancnoir256 Jan 12, 2026
04c4057
feat: サーバー応答の型を修正し、数値フィールドをint64に変更
blancnoir256 Jan 18, 2026
a1408c3
feat: ログ出力にCPUコア数を追加し、フォーマットを修正
blancnoir256 Jan 18, 2026
17ac82c
feat: Params構造体を追加し、APIリクエストにページネーションを実装
blancnoir256 Jan 18, 2026
6efd0b3
feat: サーバーAPIのURLパスの変数名を修正
blancnoir256 Jan 18, 2026
c048472
feat: サーバーAPIのURLパスの変数名を修正
blancnoir256 Jan 18, 2026
4954d3e
fix: エラーメッセージの文法を修正
blancnoir256 Jan 18, 2026
1aae5d0
feat: ServersAPIURLPathのコメントを追加し、先頭にスラッシュが必要であることを明記
blancnoir256 Jan 18, 2026
1e18812
feat: APIトークンが設定されていない場合のエラーメッセージを追加
blancnoir256 Jan 18, 2026
f81389e
fix: APIトークンのチェック条件を修正し、ログメッセージのフォーマットを改善
blancnoir256 Jan 18, 2026
6a050f9
Update pkg/server/hosts.go
blancnoir256 Jan 18, 2026
f5a0e21
fix: パラメータ構造体のフィールド名を修正
blancnoir256 Jan 18, 2026
2418f89
fix: トークンのチェックで空白を除去する処理を追加
blancnoir256 Jan 18, 2026
7c21e71
fix: ログメッセージのスペルミスを修正
blancnoir256 Jan 18, 2026
7222a01
fix: エラーメッセージに無効なサーバーIDを含めるように修正
blancnoir256 Jan 18, 2026
4d960f3
fix: ログメッセージのフォーマットを修正
blancnoir256 Jan 18, 2026
03649b4
fix: サーバーAPI URLパスの先頭にスラッシュを追加する処理を追加
blancnoir256 Jan 18, 2026
078f2ca
Initial plan
Copilot Jan 18, 2026
228c59a
fix: remove sensitive information from restart request logs
Copilot Jan 18, 2026
3ab9426
refactor: log server ID instead of full URL for better security
Copilot Jan 18, 2026
f8eeccb
fix: correct URL path prefix check logic
Copilot Jan 18, 2026
dfd7d3f
Merge pull request #2 from traPtitech/copilot/sub-pr-1
blancnoir256 Jan 18, 2026
e36c6e3
Initial plan
Copilot Jan 18, 2026
e2c35c9
feat: implement full pagination to fetch all server pages
Copilot Jan 18, 2026
0c54004
fix: use defer for response body close to ensure cleanup
Copilot Jan 18, 2026
d83107a
fix: close response body immediately and add max page limit
Copilot Jan 18, 2026
5c73793
fix: check status code before reading body and ensure cleanup
Copilot Jan 18, 2026
d8ff8fc
Merge pull request #3 from traPtitech/copilot/sub-pr-1
blancnoir256 Jan 18, 2026
9e58d2d
fix: reduce max pages limit to prevent excessive resource usage
blancnoir256 Jan 18, 2026
16ade77
fix: change prefix length and plan code types to improve data handling
blancnoir256 Jan 18, 2026
f419952
fix: enhance server output formatting with tabwriter for better reada…
blancnoir256 Jan 18, 2026
b006dae
fix: update project name and commands to reflect sakura branding
blancnoir256 Jan 19, 2026
b7227ab
fix: update GitHub Actions workflow to use latest action versions and…
blancnoir256 Jan 19, 2026
ebeb6e7
fix: update GitHub Actions to use latest action versions for consistency
blancnoir256 Jan 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
41 changes: 21 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ on:
- '**'

env:
IMAGE_NAME: dev-ops-bot
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"

Expand All @@ -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 }}
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM golang:1-alpine AS builder

ENV CGO_ENABLED 0
ENV CGO_ENABLED=0

WORKDIR /work

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ 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
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())
Expand Down
4 changes: 2 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package cmd
import (
"github.com/spf13/cobra"

"github.com/traPtitech/DevOpsBot/pkg/server"
"github.com/traPtitech/sakura-DevOpsBot/pkg/server"
)

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()
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/traPtitech/DevOpsBot
module github.com/traPtitech/sakura-DevOpsBot

go 1.22

Expand All @@ -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 (
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/traPtitech/DevOpsBot/cmd"
"github.com/traPtitech/sakura-DevOpsBot/cmd"
)

func main() {
Expand Down
9 changes: 5 additions & 4 deletions pkg/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/bot/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 4 additions & 4 deletions pkg/bot/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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, "")
Expand Down
11 changes: 6 additions & 5 deletions pkg/bot/slack/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/"
Expand Down
9 changes: 5 additions & 4 deletions pkg/bot/slack/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions pkg/bot/traq/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions pkg/bot/traq/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 9 additions & 14 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ 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"`
// ServersAPIURLPath must start with "/"
ServersAPIURLPath string `mapstructure:"serversAPIURLPath" yaml:"serversAPIURLPath"`
BearerToken string `mapstructure:"bearerToken" yaml:"bearerToken"`
} `mapstructure:"sakura" yaml:"sakura"`
}

func init() {
Expand Down Expand Up @@ -143,11 +140,9 @@ 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")
viper.SetDefault("servers.sakura.serversAPIURLPath", "/vps/api/v7/servers")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これって指定させる意味ありますか? (変わり得る?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変わらないと思います。
これはconohaがそうなっていたため継承しているだけです。
デフォルト値を設定しているためconfigで書かなくても良いとは思います。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定数で固定しちゃうのが良い気がします

viper.SetDefault("servers.sakura.bearerToken", "")
}

func init() {
Expand Down
Loading