Skip to content

feat: add instance_profile config field for EC2 Image Builder#203

Merged
l50 merged 2 commits into
mainfrom
feat/instance-profile-config
May 15, 2026
Merged

feat: add instance_profile config field for EC2 Image Builder#203
l50 merged 2 commits into
mainfrom
feat/instance-profile-config

Conversation

@mkultraWasHere
Copy link
Copy Markdown
Contributor

Summary

  • Add InstanceProfile field to Config struct with mapstructure:"instance_profile" tag
  • Wire ami build to fall back to cfg.InstanceProfile via getFlagString (flag > config > empty)
  • Add viper default and dreadgoad.yaml entry for instance_profile
  • Add TestConfigInstanceProfile (struct field + mapstructure tag validation) and TestGetFlagString (4-case precedence table) in new cmd/ami_test.go

Test plan

  • go test ./internal/config/ — all pass
  • go test ./cmd/ — all pass (including new TestGetFlagString)

🤖 Generated with Claude Code

Wire InstanceProfile through Config struct, viper defaults, and
dreadgoad.yaml so `ami build` falls back to the configured IAM
instance profile when no --instance-profile flag is passed.

Add tests for the Config field (including mapstructure tag validation)
and getFlagString precedence logic in a new cmd/ami_test.go.
…ition

gofmt requires all fields in a struct to be aligned when any field
name widens the column. Re-align MaxRetries through Ludus fields.
Copy link
Copy Markdown

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

Adds configuration support for an EC2 Image Builder IAM instance profile and wires ami build to use it as a fallback when the CLI flag is not provided.

Changes:

  • Adds InstanceProfile to CLI config with Viper defaulting.
  • Updates ami build instance profile precedence to use flag then config.
  • Adds sample config entry and unit tests for the new config field/helper behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dreadgoad.yaml Adds top-level instance_profile config entry.
cli/internal/config/defaults.go Adds default empty value for instance_profile.
cli/internal/config/config.go Adds InstanceProfile field to Config.
cli/internal/config/config_test.go Adds tests for the new config field and tag.
cli/cmd/ami.go Wires ami build to fall back to configured instance profile.
cli/cmd/ami_test.go Adds table tests for getFlagString precedence.
Comments suppressed due to low confidence (1)

dreadgoad.yaml:5

  • The CLI-generated default config is hardcoded separately in cli/cmd/config_cmd.go and is not updated with this new key, so dreadgoad config init will still create a config that omits the documented instance_profile option. Please keep the checked-in sample and generated default config in sync so users discover the new setting regardless of how they initialize configuration.
instance_profile: WarpgateImageBuilderInstanceProfile  # IAM instance profile for EC2 Image Builder

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dreadgoad.yaml
env: staging
provider: aws # Provider: aws, proxmox, ludus
# region: us-west-2 # Override AWS region (default: from inventory)
instance_profile: WarpgateImageBuilderInstanceProfile # IAM instance profile for EC2 Image Builder
Env string `mapstructure:"env"`
Provider string `mapstructure:"provider"`
Region string `mapstructure:"region"`
InstanceProfile string `mapstructure:"instance_profile"`
Comment thread cli/cmd/ami.go
instanceType: getFlagStringOpt(cmd, "instance-type"),
profile: getFlagStringOpt(cmd, "profile"),
instanceProfile: getFlagStringOpt(cmd, "instance-profile"),
instanceProfile: getFlagString(cmd, "instance-profile", cfg.InstanceProfile, ""),
@l50 l50 merged commit e83cc77 into main May 15, 2026
9 checks passed
@l50 l50 deleted the feat/instance-profile-config branch May 15, 2026 20:48
l50 pushed a commit that referenced this pull request May 15, 2026
- Add `InstanceProfile` field to `Config` struct with `mapstructure:"instance_profile"` tag
- Wire `ami build` to fall back to `cfg.InstanceProfile` via `getFlagString` (flag > config > empty)
- Add viper default and `dreadgoad.yaml` entry for `instance_profile`
- Add `TestConfigInstanceProfile` (struct field + mapstructure tag validation) and `TestGetFlagString` (4-case precedence table) in new `cmd/ami_test.go`

- [x] `go test ./internal/config/` — all pass
- [x] `go test ./cmd/` — all pass (including new `TestGetFlagString`)
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