superfly/flyctl

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

fliepeltje opened this issue · 2 comments

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.

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.

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.