Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion deployer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8

ENV LANG en_US.UTF-8

Check warning on line 16 in deployer.Dockerfile

View workflow job for this annotation

GitHub Actions / build-deployer

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# configure git a bit
RUN git config --global advice.detachedHead false && \
Expand All @@ -30,7 +30,7 @@
ARG NODE_BUILD_VERSION=5.3.8

# install mise
RUN curl https://mise.run | MISE_VERSION=v2024.8.6 sh && \
RUN curl https://mise.run | MISE_VERSION=v2025.11.6 sh && \
echo -e "\n\nexport PATH=\"$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH\"" >> ~/.bash_profile

ENV MISE_PYTHON_COMPILE=false
Expand Down
2 changes: 1 addition & 1 deletion internal/command/launch/plan_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func RunPlan(ctx context.Context, step string) error {

func runPropose(ctx context.Context) error {
if flag.GetString(ctx, "manifest-path") == "" {
ctx = logger.NewContext(context.Background(), logger.New(os.Stderr, logger.FromContext(ctx).Level(), iostreams.IsTerminalWriter(os.Stdout)))
ctx = logger.NewContext(ctx, logger.New(os.Stderr, logger.FromContext(ctx).Level(), iostreams.IsTerminalWriter(os.Stdout)))
}

RunPlan(ctx, "propose")
Expand Down
30 changes: 24 additions & 6 deletions internal/command/mpg/mpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ type MPGService struct {
}

// NewMPGService creates a new MPGService with default dependencies
func NewMPGService(ctx context.Context) *MPGService {
func NewMPGService(ctx context.Context) (*MPGService, error) {
uiexClient := uiexutil.ClientFromContext(ctx)
if uiexClient == nil {
return nil, fmt.Errorf("uiex client not found in context")
}
return &MPGService{
uiexClient: uiexutil.ClientFromContext(ctx),
uiexClient: uiexClient,
regionProvider: &DefaultRegionProvider{},
}
}, nil
}

// NewMPGServiceWithDependencies creates a new MPGService with custom dependencies
Expand Down Expand Up @@ -122,7 +126,10 @@ func ClusterFromFlagOrSelect(ctx context.Context, orgSlug string) (*uiex.Managed

// GetAvailableMPGRegions returns the list of regions available for Managed Postgres
func GetAvailableMPGRegions(ctx context.Context, orgSlug string) ([]fly.Region, error) {
service := NewMPGService(ctx)
service, err := NewMPGService(ctx)
if err != nil {
return nil, err
}
return service.GetAvailableMPGRegions(ctx, orgSlug)
}

Expand All @@ -134,6 +141,11 @@ func (s *MPGService) GetAvailableMPGRegions(ctx context.Context, orgSlug string)
return nil, err
}

// Check if uiexClient is initialized
if s.uiexClient == nil {
return nil, fmt.Errorf("uiex client is not initialized")
}

// Try to get available MPG regions from API
mpgRegionsResponse, err := s.uiexClient.ListMPGRegions(ctx, orgSlug)
if err != nil {
Expand All @@ -145,7 +157,10 @@ func (s *MPGService) GetAvailableMPGRegions(ctx context.Context, orgSlug string)

// IsValidMPGRegion checks if a region code is valid for Managed Postgres
func IsValidMPGRegion(ctx context.Context, orgSlug string, regionCode string) (bool, error) {
service := NewMPGService(ctx)
service, err := NewMPGService(ctx)
if err != nil {
return false, err
}
return service.IsValidMPGRegion(ctx, orgSlug, regionCode)
}

Expand All @@ -166,7 +181,10 @@ func (s *MPGService) IsValidMPGRegion(ctx context.Context, orgSlug string, regio

// GetAvailableMPGRegionCodes returns just the region codes for error messages
func GetAvailableMPGRegionCodes(ctx context.Context, orgSlug string) ([]string, error) {
service := NewMPGService(ctx)
service, err := NewMPGService(ctx)
if err != nil {
return nil, err
}
return service.GetAvailableMPGRegionCodes(ctx, orgSlug)
}

Expand Down
11 changes: 11 additions & 0 deletions test/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,18 @@ func TestLaunchRails8(t *testing.T) {
func TestLaunchDjangoBasic(t *testing.T) {
deploy := testDeployer(t,
withFixtureApp("django-basic"),
withOverwrittenConfig(func(d *testlib.DeployTestRun) map[string]any {
return map[string]any{
"app": "dummy-app-name",
"region": d.PrimaryRegion(),
"env": map[string]string{
"TEST_ID": d.ID(),
},
}
}),
createRandomApp,
testlib.WithTrigger("launch"),
testlib.WithCopyConfig,
testlib.WithoutCustomize,
testlib.WithouExtensions,
testlib.DeployNow,
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/django-basic/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
app = "{{apps.0}}"
primary_region = '{{region}}'

[deploy]
release_command = "sleep 2"

[env]
TEST_ID = "{{test.id}}"

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
11 changes: 11 additions & 0 deletions test/testlib/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ type DeployTestRun struct {

region string

trigger string

noCustomize bool
skipExtensions bool
copyConfig bool
Expand Down Expand Up @@ -175,6 +177,12 @@ func WithCopyConfig(d *DeployTestRun) {
d.copyConfig = true
}

func WithTrigger(trigger string) func(*DeployTestRun) {
return func(d *DeployTestRun) {
d.trigger = trigger
}
}

func OptOutGithubActions(d *DeployTestRun) {
d.optOutGha = true
}
Expand Down Expand Up @@ -230,6 +238,9 @@ func (d *DeployTestRun) Start(ctx context.Context) error {
if d.copyConfig {
env = append(env, "DEPLOY_COPY_CONFIG=1")
}
if d.trigger != "" {
env = append(env, fmt.Sprintf("DEPLOY_TRIGGER=%s", d.trigger))
}
if d.optOutGha {
env = append(env, "OPT_OUT_GITHUB_ACTIONS=1")
}
Expand Down
Loading