Repository: superfly/flyctl
Pull request #3400 (2024-03-25 09:29:19)

Bump github.com/superfly/fly-go from 0.1.3 to 0.1.4
Bumps [github.com/superfly/fly-go](https://github.com/superfly/fly-go) from 0.1.3 to 0.1.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/superfly/fly-go/releases">github.com/superfly/fly-go's releases</a>.</em></p>
<blockquote>
<h2>v0.1.4</h2>
<h2>What's Changed</h2>
<ul>
<li>Restart policy becomes a pointer by <a href="https://github.com/rugwirobaker"><code>@​rugwirobaker</code></a> in <a href="https://redirect.github.com/superfly/fly-go/pull/27">superfly/fly-go#27</a></li>
<li>Change GitHub Actions OS sizing by <a href="https://github.com/benbjohnson"><code>@​benbjohnson</code></a> in <a href="https://redirect.github.com/superfly/fly-go/pull/28">superfly/fly-go#28</a></li>
<li>Bump github.com/PuerkitoBio/rehttp from 1.3.0 to 1.4.0 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/superfly/fly-go/pull/24">superfly/fly-go#24</a></li>
<li>Bump github.com/superfly/macaroon from 0.2.10 to 0.2.12 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/superfly/fly-go/pull/23">superfly/fly-go#23</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/rugwirobaker"><code>@​rugwirobaker</code></a> made their first contribution in <a href="https://redirect.github.com/superfly/fly-go/pull/27">superfly/fly-go#27</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/superfly/fly-go/compare/v0.1.3...v0.1.4">https://github.com/superfly/fly-go/compare/v0.1.3...v0.1.4</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/superfly/fly-go/commit/cc398257f0c97d400e9438ac9b5c7f993261bc73"><code>cc39825</code></a> Bump github.com/superfly/macaroon from 0.2.10 to 0.2.12 (<a href="https://redirect.github.com/superfly/fly-go/issues/23">#23</a>)</li>
<li><a href="https://github.com/superfly/fly-go/commit/4f75e110dd7394a7559fd77289a95589bdb7b0d8"><code>4f75e11</code></a> Bump github.com/PuerkitoBio/rehttp from 1.3.0 to 1.4.0 (<a href="https://redirect.github.com/superfly/fly-go/issues/24">#24</a>)</li>
<li><a href="https://github.com/superfly/fly-go/commit/c5cfb7523ebc321847ec679f3662336290e8498f"><code>c5cfb75</code></a> Change GitHub Actions OS sizing (<a href="https://redirect.github.com/superfly/fly-go/issues/28">#28</a>)</li>
<li><a href="https://github.com/superfly/fly-go/commit/22afb660c5146ecf0a67b1c6495e1e39f6b2bc07"><code>22afb66</code></a> Restart policy becomes a pointer (<a href="https://redirect.github.com/superfly/fly-go/issues/27">#27</a>)</li>
<li>See full diff in <a href="https://github.com/superfly/fly-go/compare/v0.1.3...v0.1.4">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/superfly/fly-go&package-manager=go_modules&previous-version=0.1.3&new-version=0.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/flypg/launcher.go b/flypg/launcher.go
index d9bc2b002..206a4a843 100644
--- a/flypg/launcher.go
+++ b/flypg/launcher.go
@@ -340,7 +340,7 @@ func (l *Launcher) getPostgresConfig(config *CreateClusterInput) *fly.MachineCon
 	}
 
 	// Restart policy
-	machineConfig.Restart.Policy = fly.MachineRestartPolicyAlways
+	machineConfig.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyAlways}
 
 	if config.ScaleToZero {
 		machineConfig.Restart.Policy = fly.MachineRestartPolicyOnFailure
diff --git a/go.mod b/go.mod
index 5e9d79c84..034977fb5 100644
--- a/go.mod
+++ b/go.mod
@@ -55,10 +55,10 @@ require (
 	github.com/spf13/pflag v1.0.5
 	github.com/spf13/viper v1.18.2
 	github.com/stretchr/testify v1.9.0
-	github.com/superfly/fly-go v0.1.3
+	github.com/superfly/fly-go v0.1.4
 	github.com/superfly/graphql v0.2.4
 	github.com/superfly/lfsc-go v0.1.1
-	github.com/superfly/macaroon v0.2.10
+	github.com/superfly/macaroon v0.2.12
 	github.com/superfly/tokenizer v0.0.2
 	github.com/vektah/gqlparser v1.3.1
 	github.com/vektah/gqlparser/v2 v2.5.11
diff --git a/go.sum b/go.sum
index 706122d10..e9f1aa6a8 100644
--- a/go.sum
+++ b/go.sum
@@ -609,16 +609,16 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
 github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
 github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
-github.com/superfly/fly-go v0.1.3 h1:lKx8hozCTtKTb4ceoXDmrFrAOu0C4eiVm9gehuYpBz0=
-github.com/superfly/fly-go v0.1.3/go.mod h1:5WiuvjaHg5zzdCxhV5mPElADEqIAKbLMhVI18vM+OeY=
+github.com/superfly/fly-go v0.1.4 h1:CDvBjfZVrdREAUX5zy1VkkZAlCb7SMRL2fxpncbiq0o=
+github.com/superfly/fly-go v0.1.4/go.mod h1:MUKMuc5Tg+qmDmAi5jBMKcuitw4SNhrZ60fS4jqIZpQ=
 github.com/superfly/graphql v0.2.4 h1:Av8hSk4x8WvKJ6MTnEwrLknSVSGPc7DWpgT3z/kt3PU=
 github.com/superfly/graphql v0.2.4/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
 github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=
 github.com/superfly/lfsc-go v0.1.1/go.mod h1:zVb0VENz/Il8Nmvvd4XAsX2bWhQ+sr0nK8vv9PeezcE=
 github.com/superfly/ltx v0.3.12 h1:Z7z1sc4g34/jUi3XO84+zBlIsbaoh2RJ3b4zTQpBK/M=
 github.com/superfly/ltx v0.3.12/go.mod h1:ly+Dq7UVacQVEI5/b0r6j+PSNy9ibwx1yikcWAaSkhE=
-github.com/superfly/macaroon v0.2.10 h1:73M8sGVU3PE+XeedAdWBF1ezhUvID0DswOu2bRp7NSA=
-github.com/superfly/macaroon v0.2.10/go.mod h1:Kt6/EdSYfFjR4GIe+erMwcJgU8iMu1noYVceQ5dNdKo=
+github.com/superfly/macaroon v0.2.12 h1:fxIHs4Cd8J8uTXqGgYcAylFltjvMeIU1JBTyL3q70gc=
+github.com/superfly/macaroon v0.2.12/go.mod h1:Kt6/EdSYfFjR4GIe+erMwcJgU8iMu1noYVceQ5dNdKo=
 github.com/superfly/tokenizer v0.0.2 h1:gBREpm08sPWUHsqKHKHFy/AIKwrqpg+VBD/wtJ6x5Jk=
 github.com/superfly/tokenizer v0.0.2/go.mod h1:jO8bIWFsfcBghh7I6cFJHmJb5E3RQr0v4F0Rnev3Yj4=
 github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
diff --git a/internal/appconfig/machines.go b/internal/appconfig/machines.go
index 5f6da6fd5..4fc42b257 100644
--- a/internal/appconfig/machines.go
+++ b/internal/appconfig/machines.go
@@ -31,7 +31,7 @@ func (c *Config) ToReleaseMachineConfig() (*fly.MachineConfig, error) {
 			Cmd:        releaseCmd,
 			SwapSizeMB: c.SwapSizeMB,
 		},
-		Restart: fly.MachineRestart{
+		Restart: &fly.MachineRestart{
 			Policy: fly.MachineRestartPolicyNo,
 		},
 		AutoDestroy: true,
@@ -72,7 +72,7 @@ func (c *Config) ToConsoleMachineConfig() (*fly.MachineConfig, error) {
 			Exec:       []string{"/bin/sleep", "inf"},
 			SwapSizeMB: c.SwapSizeMB,
 		},
-		Restart: fly.MachineRestart{
+		Restart: &fly.MachineRestart{
 			Policy: fly.MachineRestartPolicyNo,
 		},
 		AutoDestroy: true,
diff --git a/internal/command/machine/run.go b/internal/command/machine/run.go
index a524c33da..a5b637281 100644
--- a/internal/command/machine/run.go
+++ b/internal/command/machine/run.go
@@ -715,24 +715,24 @@ func determineMachineConfig(
 	// default restart policy to always unless otherwise specified
 	switch flag.GetString(ctx, "restart") {
 	case "no":
-		machineConf.Restart.Policy = fly.MachineRestartPolicyNo
+		machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}
 	case "on-fail":
-		machineConf.Restart.Policy = fly.MachineRestartPolicyOnFailure
+		machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyOnFailure}
 	case "always":
-		machineConf.Restart.Policy = fly.MachineRestartPolicyAlways
+		machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyAlways}
 	case "":
 		if flag.IsSpecified(ctx, "restart") {
 			// An empty policy was explicitly requested.
-			machineConf.Restart.Policy = ""
+			machineConf.Restart = nil
 		} else if machineConf.AutoDestroy {
 			// Autodestroy only works when the restart policy is set to no, so unless otherwise specified, we set the restart policy to no.
-			machineConf.Restart.Policy = fly.MachineRestartPolicyNo
+			machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}
 		} else if !input.updating {
 			// This is a new machine; apply the default.
 			if machineConf.Schedule != "" {
-				machineConf.Restart.Policy = fly.MachineRestartPolicyOnFailure
+				machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyOnFailure}
 			} else {
-				machineConf.Restart.Policy = fly.MachineRestartPolicyAlways
+				machineConf.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyAlways}
 			}
 		}
 	default:
diff --git a/internal/command/postgres/barman.go b/internal/command/postgres/barman.go
index 16a5d56f5..634df1f82 100644
--- a/internal/command/postgres/barman.go
+++ b/internal/command/postgres/barman.go
@@ -188,7 +188,7 @@ func runBarmanCreate(ctx context.Context) error {
 	}
 
 	// Restart policy
-	machineConfig.Restart.Policy = fly.MachineRestartPolicyAlways
+	machineConfig.Restart = &fly.MachineRestart{Policy: fly.MachineRestartPolicyAlways}
 
 	imageRepo := "flyio/postgres-flex"
 
diff --git a/internal/command/postgres/import.go b/internal/command/postgres/import.go
index ffd0e1686..db687e4bb 100644
--- a/internal/command/postgres/import.go
+++ b/internal/command/postgres/import.go
@@ -156,7 +156,7 @@ func runImport(ctx context.Context) error {
 		DNS: &fly.DNSConfig{
 			SkipRegistration: true,
 		},
-		Restart: fly.MachineRestart{
+		Restart: &fly.MachineRestart{
 			Policy: fly.MachineRestartPolicyNo,
 		},
 		AutoDestroy: true,
diff --git a/internal/machine/wait.go b/internal/machine/wait.go
index 80800385f..d5abb1e0a 100644
--- a/internal/machine/wait.go
+++ b/internal/machine/wait.go
@@ -53,7 +53,7 @@ func WaitForStartOrStop(ctx context.Context, machine *fly.Machine, action string
 			}
 		default:
 			var flapsErr *flaps.FlapsError
-			if strings.Contains(err.Error(), "machine failed to reach desired state") && machine.Config.Restart.Policy == fly.MachineRestartPolicyNo {
+			if strings.Contains(err.Error(), "machine failed to reach desired state") && machine.Config.Restart != nil && machine.Config.Restart.Policy == fly.MachineRestartPolicyNo {
 				return fmt.Errorf("machine failed to reach desired start state, and restart policy was set to %s restart", machine.Config.Restart.Policy)
 			}
 			if errors.As(err, &flapsErr) && flapsErr.ResponseStatusCode == http.StatusBadRequest {


Test patch:
diff --git a/internal/appconfig/machines_test.go b/internal/appconfig/machines_test.go
index 2915a6687..eb5dd3303 100644
--- a/internal/appconfig/machines_test.go
+++ b/internal/appconfig/machines_test.go
@@ -61,7 +61,7 @@ func TestToMachineConfig(t *testing.T) {
 		Guest:       &fly.MachineGuest{CPUs: 3},
 		Schedule:    "24/7",
 		AutoDestroy: true,
-		Restart:     fly.MachineRestart{Policy: "poke"},
+		Restart:     &fly.MachineRestart{Policy: "poke"},
 		DNS:         &fly.DNSConfig{SkipRegistration: true},
 		Env:         map[string]string{"removed": "by-update"},
 		Mounts:      []fly.MachineMount{{Name: "removed", Path: "/by/update"}},
@@ -75,7 +75,7 @@ func TestToMachineConfig(t *testing.T) {
 	assert.Equal(t, &fly.MachineGuest{CPUs: 3}, got.Guest)
 	assert.Equal(t, "24/7", got.Schedule)
 	assert.Equal(t, true, got.AutoDestroy)
-	assert.Equal(t, fly.MachineRestart{Policy: "poke"}, got.Restart)
+	assert.Equal(t, &fly.MachineRestart{Policy: "poke"}, got.Restart)
 	assert.Equal(t, &fly.DNSConfig{SkipRegistration: true}, got.DNS)
 	assert.Equal(t, "propagated", got.Metadata["retain"])
 	assert.Empty(t, got.Init.Cmd)
@@ -159,7 +159,7 @@ func TestToReleaseMachineConfig(t *testing.T) {
 			"fly_flyctl_version":   buildinfo.Version().String(),
 		},
 		AutoDestroy: true,
-		Restart:     fly.MachineRestart{Policy: fly.MachineRestartPolicyNo},
+		Restart:     &fly.MachineRestart{Policy: fly.MachineRestartPolicyNo},
 		DNS:         &fly.DNSConfig{SkipRegistration: true},
 		StopConfig: &fly.StopConfig{
 			Timeout: fly.MustParseDuration("10s"),
@@ -192,7 +192,7 @@ func TestToConsoleMachineConfig(t *testing.T) {
 			"fly_flyctl_version":   buildinfo.Version().String(),
 		},
 		AutoDestroy: true,
-		Restart: fly.MachineRestart{
+		Restart: &fly.MachineRestart{
 			Policy: fly.MachineRestartPolicyNo,
 		},
 		DNS: &fly.DNSConfig{SkipRegistration: true},
diff --git a/internal/command/deploy/machines_launchinput_test.go b/internal/command/deploy/machines_launchinput_test.go
index 2ad21c15b..bd94b4df2 100644
--- a/internal/command/deploy/machines_launchinput_test.go
+++ b/internal/command/deploy/machines_launchinput_test.go
@@ -333,7 +333,7 @@ func Test_launchInputForUpdate_keepUnmanagedFields(t *testing.T) {
 		Config: &fly.MachineConfig{
 			Schedule:    "24/7",
 			AutoDestroy: true,
-			Restart: fly.MachineRestart{
+			Restart: &fly.MachineRestart{
 				Policy: fly.MachineRestartPolicyNo,
 			},
 			Guest: &fly.MachineGuest{
@@ -353,7 +353,7 @@ func Test_launchInputForUpdate_keepUnmanagedFields(t *testing.T) {
 	assert.Equal(t, "ord", li.Region)
 	assert.Equal(t, "24/7", li.Config.Schedule)
 	assert.Equal(t, true, li.Config.AutoDestroy)
-	assert.Equal(t, fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}, li.Config.Restart)
+	assert.Equal(t, &fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}, li.Config.Restart)
 	assert.Equal(t, &fly.MachineGuest{CPUKind: "other"}, li.Config.Guest)
 	assert.Equal(t, &fly.DNSConfig{SkipRegistration: true}, li.Config.DNS)
 	assert.Equal(t, []fly.MachineProcess{{CmdOverride: []string{"foo"}}}, li.Config.Processes)
@@ -363,7 +363,7 @@ func Test_launchInputForUpdate_keepUnmanagedFields(t *testing.T) {
 	assert.Equal(t, "ord", li.Region)
 	assert.Equal(t, "24/7", li.Config.Schedule)
 	assert.Equal(t, true, li.Config.AutoDestroy)
-	assert.Equal(t, fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}, li.Config.Restart)
+	assert.Equal(t, &fly.MachineRestart{Policy: fly.MachineRestartPolicyNo}, li.Config.Restart)
 	assert.Equal(t, &fly.MachineGuest{CPUKind: "other"}, li.Config.Guest)
 	assert.Equal(t, &fly.DNSConfig{SkipRegistration: true}, li.Config.DNS)
 	assert.Equal(t, []fly.MachineProcess{{CmdOverride: []string{"foo"}}}, li.Config.Processes)
diff --git a/internal/command/deploy/machines_test.go b/internal/command/deploy/machines_test.go
index 56a3fdd2e..4c17523c9 100644
--- a/internal/command/deploy/machines_test.go
+++ b/internal/command/deploy/machines_test.go
@@ -55,7 +55,6 @@ func Test_resolveUpdatedMachineConfig_Basic(t *testing.T) {
 			},
 		},
 	}, li)
-
 }
 
 // Test any LaunchMachineInput field that must not be set on a machine
@@ -67,11 +66,13 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
 			"PRIMARY_REGION": "scl",
 			"OTHER":          "value",
 		},
-		Metrics: []*appconfig.Metrics{{
-			MachineMetrics: &fly.MachineMetrics{
-				Port: 9000,
-				Path: "/prometheus",
-			}},
+		Metrics: []*appconfig.Metrics{
+			{
+				MachineMetrics: &fly.MachineMetrics{
+					Port: 9000,
+					Path: "/prometheus",
+				},
+			},
 		},
 		Deploy: &appconfig.Deploy{
 			ReleaseCommand: "touch sky",
@@ -168,7 +169,7 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
 				"fly_release_version":  "0",
 				"fly_flyctl_version":   buildinfo.Version().String(),
 			},
-			Restart: fly.MachineRestart{
+			Restart: &fly.MachineRestart{
 				Policy: fly.MachineRestartPolicyNo,
 			},
 			AutoDestroy: true,
@@ -186,7 +187,7 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
 				"PRIMARY_REGION": "different-region",
 			},
 			AutoDestroy: false,
-			Restart: fly.MachineRestart{
+			Restart: &fly.MachineRestart{
 				Policy: fly.MachineRestartPolicyOnFailure,
 			},
 			Init: fly.MachineInit{
@@ -216,7 +217,7 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
 			Init: fly.MachineInit{
 				Cmd: []string{"touch", "sky"},
 			},
-			Restart: fly.MachineRestart{
+			Restart: &fly.MachineRestart{
 				Policy: fly.MachineRestartPolicyNo,
 			},
 			AutoDestroy: true,