Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove magic strings from Source types #57

Closed

Commits on Jan 12, 2024

  1. Add Source data structures

    The source variants, with all sub-fields, have been added to the
    `Source` struct. Note that this code does not yet work, and will not
    compile.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    4cfa108 View commit details
    Browse the repository at this point in the history
  2. Add GetRef and SetRef methods to Source

    These are basic getters and setters for the `Ref` subfields on various
    `Source` variants. Because any one of these variants could be non-nil,
    we first have to determine which is in use. Not all Source vaiants have
    a `.Ref` field, so those cases need to be handled as well.
    
    These methods each return an additional `bool` value depending on
    whether or not the `.Ref` field exists in the Source variant.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    5a22b1c View commit details
    Browse the repository at this point in the history
  3. Switch on embedded union variant

    Change switch on scheme to union variant in `source2LLBGetter`
    (`source.go`).
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    91022b6 View commit details
    Browse the repository at this point in the history
  4. Implement switching logic on Source variants

    Continue implementing the necessary switches. This code compiles.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    c804300 View commit details
    Browse the repository at this point in the history
  5. Remove KeepGitDir field from Source.

    This field is now found on `Source.Git`.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    f0036cf View commit details
    Browse the repository at this point in the history
  6. Rename fields on some Source variants

    Also, remove `Source.Source` and `SourceAnotherSource`.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    a51da27 View commit details
    Browse the repository at this point in the history
  7. Implement source.processArgs

    * Remove source.GetRef and source.SetRef
    * Add source.processArgs and use it where necessary
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    945ff2f View commit details
    Browse the repository at this point in the history
  8. Add SourceLocal (local Source variant)

    It's often convenient to use files and directories from the local
    filesystem as a source. This commit essentially exposes `llb.Local(...)`
    to the user via the spec.
    
    This implementation may be incomplete, and should be reviewed.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    d0f6817 View commit details
    Browse the repository at this point in the history
  9. Add validation functions

    Validate that a source does not have multiple variants defined, and that
    it has at least one variant defined.
    
    If there's a more elegant implementation, feel free to suggest it.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    f31c8d0 View commit details
    Browse the repository at this point in the history
  10. Allow Cmd subfield on docker image sources only

    It may be necessary in the future to allow specification of commands on
    `Build` and `Context` source variants. For now, it is only possible for
    Docker images.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    851331c View commit details
    Browse the repository at this point in the history
  11. Remove dead code

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    320f146 View commit details
    Browse the repository at this point in the history
  12. Remove JSON schema extension

    The format has changed, and this check is no longer correct.
    
    This commit also re-runs the `go generate` command and commits the
    changes.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    e649cad View commit details
    Browse the repository at this point in the history
  13. Match some tests fixtures to new spec format

    Note: Only some of the tests will run properly. The logic for
    `SourceBuild` needs to be re-tooled in order to run one of the tests
    properly. I will come back later to edit the rest of the test fixtures.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    30aa0b8 View commit details
    Browse the repository at this point in the history
  14. Retool SourceBuild

    `SourceBuild` needs a base state of some sort, in which the specified
    Dockerfile will be executed. This implementation allows the base state
    to be made up of a local path, a build context, or another source.
    
    This may not be final, and it's likely that there are mistakes in here.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    5a723c7 View commit details
    Browse the repository at this point in the history
  15. Fix more yaml fixtures

    The tests are still not completing successfully, so more troubleshooting
    is needed.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    19aefe6 View commit details
    Browse the repository at this point in the history
  16. All tests but one are passing

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    b3570a2 View commit details
    Browse the repository at this point in the history
  17. Redesign SourceBuild struct

    After discussion with Brian, this is the correct struct layout for this.
    The context string is a path which will be used as the `.` context for
    the dockerfile build.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    b33b3af View commit details
    Browse the repository at this point in the history
  18. Save progress

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    7b6a875 View commit details
    Browse the repository at this point in the history
  19. save

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    b84de6f View commit details
    Browse the repository at this point in the history
  20. Fix local source

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    1612df8 View commit details
    Browse the repository at this point in the history
  21. Run go generate

    To pass the linter
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    fa813ed View commit details
    Browse the repository at this point in the history
  22. Update comment for autogenerated docs

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    74db6e1 View commit details
    Browse the repository at this point in the history
  23. Update patching test to reflect new spec format

    Because of the patching PR.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    ac0bffb View commit details
    Browse the repository at this point in the history
  24. Fix frontend test fixture

    We can no longer reference other sources. Instead, we can specify a
    `local` source with the current directory in order to build the
    frontend.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    1076923 View commit details
    Browse the repository at this point in the history
  25. Fix runc test fixture

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    f068072 View commit details
    Browse the repository at this point in the history
  26. Fix example spec files and accompanying docs

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    991772e View commit details
    Browse the repository at this point in the history
  27. Remove unused empty file

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    8b795d1 View commit details
    Browse the repository at this point in the history
  28. Clean up validation function

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    007524c View commit details
    Browse the repository at this point in the history
  29. Remove dead code

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    44084e4 View commit details
    Browse the repository at this point in the history
  30. Remove local source type

    Additionally, ensure that the defaults are filled correctly for the
    `context` source type (which made the `local` type redundant).
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    9554d2b View commit details
    Browse the repository at this point in the history
  31. Remove unused function

    We're no longer using the schemes
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    4519995 View commit details
    Browse the repository at this point in the history
  32. Run go generate

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    e40bf10 View commit details
    Browse the repository at this point in the history
  33. Use strings for DockerFile/Inline on build sources

    Use them instead of pointers. Also, validate them up-front in the
    `validate` function, so that they do not need to be checked later.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    8380747 View commit details
    Browse the repository at this point in the history
  34. Add error to default case

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    a3ddd8a View commit details
    Browse the repository at this point in the history
  35. Allow Build Source type to use any Source as the context

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    140a9a9 View commit details
    Browse the repository at this point in the history
  36. Address linter errors

    Also, validate sources recursively.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    1a864c1 View commit details
    Browse the repository at this point in the history
  37. Remove Path field from SourceContext

    Also:
    - update `processArgs` to do substitutions inline.
    - update `fillDefaults` to set the default Source.Path to `"."` when the
      Source type is Context.
    
    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    d76f447 View commit details
    Browse the repository at this point in the history
  38. Make yaml specs conform to Git source type layout

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    c2a8230 View commit details
    Browse the repository at this point in the history
  39. Remove unused default cases from switch statements

    Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
    pmengelbert committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    b3a2642 View commit details
    Browse the repository at this point in the history