Skip to content

Commit

Permalink
ユーザーエージェントをカスタマイズするためのSAKURACLOUD_APPEND_USER_AGENT環境変数の導入 (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamamoto-febc authored Oct 6, 2022
1 parent 51c03a6 commit df3d206
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/sakuracloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"runtime"
"sync"

Expand Down Expand Up @@ -63,7 +64,7 @@ func (sc *SakuraCloud) APIClient() iaas.APICaller {
version.Version,
runtime.GOOS,
runtime.GOARCH,
api.UserAgent,
os.Getenv("SAKURACLOUD_APPEND_USER_AGENT"),
),
},
})
Expand All @@ -89,5 +90,8 @@ func (sc *SakuraCloud) Validate(ctx context.Context) error {
if authStatus.Permission != types.Permissions.Create && authStatus.Permission != types.Permissions.Arrange {
return fmt.Errorf("required permissions have not been assigned. assigned permission: %s", authStatus.Permission)
}
if len(os.Getenv("SAKURACLOUD_APPEND_USER_AGENT")) > 1024 {
return fmt.Errorf("SAKURACLOUD_APPEND_USER_AGENT is too long: max=1024")
}
return nil
}

0 comments on commit df3d206

Please sign in to comment.