MCPcopy
hub / github.com/moby/moby / encodePlatforms

Function encodePlatforms

client/utils.go:79–104  ·  view source on GitHub ↗

encodePlatforms marshals the given platform(s) to JSON format, to be used for query-parameters for filtering / selecting platforms.

(platform ...ocispec.Platform)

Source from the content-addressed store, hash-verified

77// encodePlatforms marshals the given platform(s) to JSON format, to
78// be used for query-parameters for filtering / selecting platforms.
79func encodePlatforms(platform ...ocispec.Platform) ([]string, error) {
80 if len(platform) == 0 {
81 return []string{}, nil
82 }
83 if len(platform) == 1 {
84 p, err := encodePlatform(&platform[0])
85 if err != nil {
86 return nil, err
87 }
88 return []string{p}, nil
89 }
90
91 seen := make(map[string]struct{}, len(platform))
92 out := make([]string, 0, len(platform))
93 for i := range platform {
94 p, err := encodePlatform(&platform[i])
95 if err != nil {
96 return nil, err
97 }
98 if _, ok := seen[p]; !ok {
99 out = append(out, p)
100 seen[p] = struct{}{}
101 }
102 }
103 return out, nil
104}
105
106// encodePlatform marshals the given platform to JSON format, to
107// be used for query-parameters for filtering / selecting platforms. It

Callers 4

ImageRemoveMethod · 0.85
TestEncodePlatformsFunction · 0.85
ImageLoadMethod · 0.85
ImageSaveMethod · 0.85

Calls 1

encodePlatformFunction · 0.85

Tested by 1

TestEncodePlatformsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…