Skip to content

API: define better type (enum) and remove archive.Changes from the API #45235

@thaJeztah

Description

@thaJeztah

For a follow-up, we must look into this signature.
#44964 (comment)

When working on the CLI I was wondering why pkg/archive was imported in some location where I wouldn't expect it, and I stumbled upon this code; https://github.com/docker/cli/blob/14482589df194a86b2ee07df643ba3277b40df7d/cli/command/container/formatter_diff.go#L56-L67

func (d *diffContext) Type() string {
	var kind string
	switch d.c.Kind {
	case archive.ChangeModify:
		kind = "C"
	case archive.ChangeAdd:
		kind = "A"
	case archive.ChangeDelete:
		kind = "D"
	}
	return kind
}

It turns out that the Client returns its own type for this, but that type does not have the enum values;

func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.ContainerChangeResponseItem, error) {

type ContainerChangeResponseItem struct {

We should consider to either

  • add the enums to the API types
  • have the backend return the correct type
  • have a utility to convert the type
  • (possibly alias one for the other if needed)

Originally posted by @thaJeztah in #44964 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions