Skip to content

Commit

Permalink
add uuid to transport name
Browse files Browse the repository at this point in the history
  • Loading branch information
kaovilai committed May 23, 2022
1 parent 31f16e3 commit ad7d3c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/image/udistribution/docker_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/containers/image/v5/docker/policyconfiguration"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/transports"
"github.com/distribution/distribution/v3/uuid"

// "github.com/containers/image/v5/transports"
"github.com/containers/image/v5/types"
Expand All @@ -27,6 +28,7 @@ import (
type udistributionTransport struct {
*client.Client
name string
uuid string
}

// Create new transport and register.
Expand All @@ -35,6 +37,7 @@ func NewTransport(client *client.Client, name string) *udistributionTransport {
t := udistributionTransport{
Client: client,
name: name,
uuid: uuid.Generate().String(),
}
if transports.Get(t.Name()) == nil {
transports.Register(t)
Expand All @@ -52,6 +55,7 @@ func NewTransportFromNewConfig(config string, env []string) (*udistributionTrans
t := udistributionTransport{
Client: c,
name: c.GetApp().Config.Storage.Type(),
uuid: uuid.Generate().String(),
}
if transports.Get(t.Name()) == nil {
transports.Register(t)
Expand All @@ -64,7 +68,7 @@ func (u udistributionTransport) Deregister() {
}

func (t udistributionTransport) Name() string {
return constants.TransportPrefix + t.name
return constants.TransportPrefix + t.name + ":" + t.uuid
}

// ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an ImageReference.
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/udistribution/docker_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
testTransport = types.ImageTransport(testUdistributionTransport)
}
func TestTransportName(t *testing.T) {
assert.Equal(t, constants.TransportPrefix+testUdistributionTransport.name, testTransport.Name())
assert.Equal(t, constants.TransportPrefix+testUdistributionTransport.name+":"+testUdistributionTransport.uuid, testTransport.Name())
}

func TestTransportParseReference(t *testing.T) {
Expand Down

0 comments on commit ad7d3c7

Please sign in to comment.