Skip to content

Add custom headers to profile#124

Merged
bearmini merged 8 commits intomasterfrom
add-custom-headers-to-profile
Jul 18, 2025
Merged

Add custom headers to profile#124
bearmini merged 8 commits intomasterfrom
add-custom-headers-to-profile

Conversation

@bearmini
Copy link
Collaborator

@bearmini bearmini commented Jul 9, 2025

Profile に headers を入れておくことで soracom-cli が API リクエストを送信する際に追加のヘッダーを設定できるようにしました。

自動生成されたファイルも更新されましたのでファイル変更数は多いですが、soracom/generated ディレクトリ以下の更新はすべて同じです。

@bearmini bearmini requested review from Copilot and j3tm0t0 July 9, 2025 05:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables users to specify custom HTTP headers in their profile, which the CLI will include on API requests. Key changes include:

  • Adding a headers field to the profile and a helper getProfileIfExist().
  • Passing the loaded profile into the API client and injecting its headers.
  • Bumping Go module/toolchain versions and the Docker base image.

Reviewed Changes

Copilot reviewed 5 out of 480 changed files in this pull request and generated no comments.

Show a summary per file
File Description
go.mod Updated Go version to 1.24.5 and bumped x/sys to v0.33.0
generators/cmd/templates/leaf.gotmpl Invoke getProfileIfExist() and pass Profile to client
generators/cmd/predefined/profiles.go Add Headers to profile struct and getProfileIfExist
generators/cmd/predefined/apiclient.go Store profile in client and inject headers into requests
build/Dockerfile Bump Golang base image to 1.24.5
Comments suppressed due to low confidence (4)

generators/cmd/predefined/profiles.go:36

  • Consider adding a doc comment above Headers to explain its purpose and usage in the profile configuration.
	Headers               map[string]string `json:"headers,omitempty"`

generators/cmd/predefined/profiles.go:73

  • [nitpick] The function name getProfileIfExist could be more grammatically consistent as getProfileIfExists or loadProfileOrNil.
func getProfileIfExist() *profile {

generators/cmd/predefined/apiclient.go:393

  • Add unit tests to verify that profile.Headers entries are correctly injected into outgoing HTTP requests.
	if ac.profile != nil {

generators/cmd/templates/leaf.gotmpl:121

  • The generated code now calls getProfileIfExist but may not import it; ensure the appropriate package import is added so the function resolves correctly.
    profile := getProfileIfExist()

Copy link
Contributor

@kazntree kazntree left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@bearmini bearmini merged commit 220fd3a into master Jul 18, 2025
1 check passed
@bearmini bearmini deleted the add-custom-headers-to-profile branch July 18, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants