mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-20 02:17:44 +08:00

Removes gogo/protobuf from buildx and updates to a version of moby/buildkit where gogo is removed. This also changes how the proto files are generated. This is because newer versions of protobuf are more strict about name conflicts. If two files have the same name (even if they are relative paths) and are used in different protoc commands, they'll conflict in the registry. Since protobuf file generation doesn't work very well with `paths=source_relative`, this removes the `go:generate` expression and just relies on the dockerfile to perform the generation. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package moby_buildkit_v1_sourcepolicy //nolint:revive
|
|
|
|
import (
|
|
"github.com/moby/buildkit/util/gogo/proto"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// MarshalJSON implements json.Marshaler with custom marshaling for PolicyAction.
|
|
// It gives the string form of the enum value.
|
|
func (a PolicyAction) MarshalJSON() ([]byte, error) {
|
|
return proto.MarshalJSONEnum(PolicyAction_name, int32(a))
|
|
}
|
|
|
|
func (a *PolicyAction) UnmarshalJSON(data []byte) error {
|
|
val, err := proto.UnmarshalJSONEnum(PolicyAction_value, data, a.String())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, ok := PolicyAction_name[val]
|
|
if !ok {
|
|
return errors.Errorf("invalid PolicyAction value: %d", val)
|
|
}
|
|
*a = PolicyAction(val)
|
|
return nil
|
|
}
|
|
|
|
func (a AttrMatch) MarshalJSON() ([]byte, error) {
|
|
return proto.MarshalJSONEnum(AttrMatch_name, int32(a))
|
|
}
|
|
|
|
func (a *AttrMatch) UnmarshalJSON(data []byte) error {
|
|
val, err := proto.UnmarshalJSONEnum(AttrMatch_value, data, a.String())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, ok := AttrMatch_name[val]
|
|
if !ok {
|
|
return errors.Errorf("invalid AttrMatch value: %d", val)
|
|
}
|
|
*a = AttrMatch(val)
|
|
return nil
|
|
}
|
|
|
|
func (a MatchType) MarshalJSON() ([]byte, error) {
|
|
return proto.MarshalJSONEnum(MatchType_name, int32(a))
|
|
}
|
|
|
|
func (a *MatchType) UnmarshalJSON(data []byte) error {
|
|
val, err := proto.UnmarshalJSONEnum(MatchType_value, data, a.String())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, ok := AttrMatch_name[val]
|
|
if !ok {
|
|
return errors.Errorf("invalid MatchType value: %d", val)
|
|
}
|
|
*a = MatchType(val)
|
|
return nil
|
|
}
|