Skip to content

enhancement: Refactor notes for the capabilities work #14

Description

@nabil1440

Blocker: no. Do not fix these items separately. Include them in the capability refactor.

Defect

  • internal/utils contains unrelated code. internal/utils/version.go and internal/version have similar names but different functions.
  • The commands are package-level *cobra.Command variables, and init() registers them. This makes tests difficult.
  • The command logic and the output (color.*) are in the same functions.
  • RunCompose connects directly to os.Stdin, os.Stdout and os.Stderr. Thus, other code cannot capture the output.
  • The exec calls and the HTTP calls do not use context.Context. Thus, other code cannot cancel them.
  • cmd/base.go and cmd/global.go contain the fixed path /home/fly. FindComposeFile uses $HOME. Thus, the configuration has two sources.
  • --domain is a persistent root flag. base, sites, status and version accept it, but they ignore it.
  • The root check compares cmd.Name() with "update".
  • The code uses yaml.v2 only to get the service names. yaml.v2 gets no more updates.
  • The directory checks in status belong in the monitoring capability.
  • Small items:
    • startAllSites and stopAllSites contain the same code.
    • cmd/base.go:24-25 contains code that cannot run.
    • interface{} can be any.
    • cmd/root.go contains scaffold comments.
    • The CLI does not show CommitHash and BuildDate. Use rootCmd.Version.

Cost

  • The control plane needs operations that return results and errors. The current structure does not supply them.
  • An agent that operates for a long time needs cancellation and timeouts. The current calls do not have them.
  • Two configuration sources can give different paths on the same server.
  • The agent will operate as a service. The current root check does not support a privilege model for a service.

Benefit of the fix

  • Each capability gets operations that it can test, cancel and connect to the control plane.
  • One configuration source gives the same paths everywhere.
  • docker compose config --services can replace yaml.v2. This command also reads override files and environment variables.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions