superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.39k stars 234 forks source link

`--attach` generates a toml with an odd structure #3801

Open fliepeltje opened 1 month ago

fliepeltje commented 1 month ago

Describe the bug

When I use the --attach flag, this is the fly.toml that I get in my fly/apps/<app-name>/fly.toml

[experimental]
  [experimental.attached]
    [experimental.attached.secrets]
      [experimental.attached.secrets.export]
        SANDWICH_CHAT_URL = 'http://${FLYCAST_URL}/sandwich-chat'

The relevant section of the original fly.toml for the attached app looks like this:

[experimental.attached.secrets.export]
  SANDWICH_CHAT_URL = "http://${FLYCAST_URL}/sandwich-chat"

Functionally this of course works, but it looks a bit weird.

rubys commented 1 month ago

I agree it looks weird, but that appears to be the default serialization for toml so I would not be inclined to change it. Essentially, we unmarshal the toml into go structs, make a few changes (like assigning a name), and then marshal the result.

The root cause seems to be that omitempty doesn't omit the containing structs as they aren't empty.

I considered removing this information as it no longer relevant; but at the time didn't pursue that.

fliepeltje commented 1 month ago

One reason it kind of is a problem: the attached app is also a github repo; if you want to sync with remote, you will need to stash the changes which is not very nice DX and really unintuitive; I think ideallythe cloned repo would be identical to what you get from github, but I realize that also gets problematic with the app name.