@@ -68,8 +68,8 @@ type tagMap func(name.Reference, ...ociremote.Option) (name.Tag, error)
6868//
6969// There is only one destination:
7070// - Prime Registry
71- func Sync (ctx context.Context , username , password string ) error {
72- s , err := prepareSync (ctx , username , password )
71+ func Sync (ctx context.Context , primeUser , primePass , primeURL , dockerUser , dockerPass string ) error {
72+ s , err := prepareSync (ctx , primeUser , primePass , dockerUser , dockerPass )
7373 if err != nil {
7474 return err
7575 }
@@ -99,7 +99,7 @@ func Sync(ctx context.Context, username, password string) error {
9999 for repo , tags := range stagingImageTags {
100100 for _ , tag := range tags {
101101 s .repoImage = & repoImage {} // init/reset img/tag to be synced
102- if err := s .copy (ctx , StagingURL , repo , tag ); err != nil {
102+ if err := s .copy (ctx , StagingURL , repo , tag , primeURL ); err != nil {
103103 return err
104104 }
105105 if err := s .push (ctx ); err != nil {
@@ -115,7 +115,7 @@ func Sync(ctx context.Context, username, password string) error {
115115 for repo , tags := range dockerImageTags {
116116 for _ , tag := range tags {
117117 s .repoImage = & repoImage {}
118- if err := s .copy (ctx , DockerURL , repo , tag ); err != nil {
118+ if err := s .copy (ctx , DockerURL , repo , tag , primeURL ); err != nil {
119119 return err
120120 }
121121 if err := s .push (ctx ); err != nil {
@@ -131,7 +131,7 @@ func Sync(ctx context.Context, username, password string) error {
131131
132132// prepareSync checks if the prime credentials are provided and creates the synchronizer
133133// with all the oci,naming and remote options needed.
134- func prepareSync (ctx context.Context , username , password string ) (* synchronizer , error ) {
134+ func prepareSync (ctx context.Context , primeUser , primePass , dockerUser , dockerPass string ) (* synchronizer , error ) {
135135 // Use strict validation for pulling and pushing
136136 // These options control how image references (e.g., "myregistry/myimage:tag")
137137 // are parsed and validated by go-containerregistry's 'name' package.
@@ -146,15 +146,15 @@ func prepareSync(ctx context.Context, username, password string) (*synchronizer,
146146 // (needed for docker.io without login)
147147 tr := http .DefaultTransport .(* http.Transport ).Clone ()
148148 tr .TLSClientConfig = & tls.Config {
149- InsecureSkipVerify : true ,
149+ InsecureSkipVerify : false ,
150150 }
151151
152152 // applied to the puller and subsequently used by cosign's oci/remote
153153 // package when fetching signed entities.
154154 clientOpts := []remote.Option {
155155 remote .WithContext (ctx ),
156156 remote .WithUserAgent (uaString ),
157- remote .WithAuthFromKeychain ( authn .DefaultKeychain ),
157+ remote .WithAuth ( & authn.Basic { Username : dockerUser , Password : dockerPass } ),
158158 remote .WithTransport (tr ),
159159 }
160160
@@ -178,7 +178,7 @@ func prepareSync(ctx context.Context, username, password string) (*synchronizer,
178178 // prime (destination) registry. They use explicit basic authentication?
179179 remoteOpts := []remote.Option {
180180 remote .WithContext (ctx ),
181- remote .WithAuth (& authn.Basic {Username : username , Password : password }),
181+ remote .WithAuth (& authn.Basic {Username : primeUser , Password : primePass }),
182182 }
183183
184184 // Create a new remote pusher with the prime registry's specific authentication.
@@ -215,15 +215,15 @@ func loadSyncYamlFile(ctx context.Context, path string) (map[string][]string, er
215215
216216// copy calculates the proper reference for the given img/tag at source and destination.
217217// pulls in memory the signatures (if any) and the entity itself.
218- func (s * synchronizer ) copy (ctx context.Context , registry , repo , tag string ) error {
218+ func (s * synchronizer ) copy (ctx context.Context , registry , repo , tag , primeURL string ) error {
219219 logger .Log (ctx , slog .LevelInfo , "cosign check/copy to Prime" ,
220220 slog .String ("registry" , registry ),
221221 slog .String ("repository" , repo ),
222222 slog .String ("tag" , tag ))
223223
224224 // Build targets
225225 srcTarget := registry + repo + ":" + tag
226- dstTarget := PrimeURL + repo + ":" + tag
226+ dstTarget := primeURL + "/" + repo + ":" + tag
227227
228228 srcRef , err := name .ParseReference (srcTarget , s .nameOpts ... )
229229 if err != nil {
0 commit comments