@@ -130,7 +130,7 @@ import (
130
130
func main () {
131
131
// construct client pointing to your registry
132
132
client , err := reggie.NewClient (" http://localhost:5000" ,
133
- reggie.WithDefaultName (" my/repo " ),
133
+ reggie.WithDefaultName (" myorg/myrepo " ),
134
134
reggie.WithDebug (true ))
135
135
if err != nil {
136
136
panic (err)
@@ -152,8 +152,8 @@ func main() {
152
152
blobDigest := godigest.FromBytes (blob).String ()
153
153
154
154
// upload the first chunk
155
- req = client.NewRequest (reggie.PATCH , resp.GetRelativeLocation ())
156
- req. SetHeader (" Content-Type" , " application/octet-stream" ).
155
+ req = client.NewRequest (reggie.PATCH , resp.GetRelativeLocation ()).
156
+ SetHeader (" Content-Type" , " application/octet-stream" ).
157
157
SetHeader (" Content-Length" , fmt.Sprintf (" %d " , len (blobChunk1))).
158
158
SetHeader (" Content-Range" , blobChunk1Range).
159
159
SetBody (blobChunk1)
@@ -163,8 +163,8 @@ func main() {
163
163
}
164
164
165
165
// upload the final chunk and close the session
166
- req = client.NewRequest (reggie.PUT , resp.GetRelativeLocation ())
167
- req. SetHeader (" Content-Length" , fmt.Sprintf (" %d " , len (blobChunk2))).
166
+ req = client.NewRequest (reggie.PUT , resp.GetRelativeLocation ()).
167
+ SetHeader (" Content-Length" , fmt.Sprintf (" %d " , len (blobChunk2))).
168
168
SetHeader (" Content-Range" , blobChunk2Range).
169
169
SetHeader (" Content-Type" , " application/octet-stream" ).
170
170
SetQueryParam (" digest" , blobDigest).
@@ -184,21 +184,15 @@ func main() {
184
184
fmt.Printf (" Blob content:\n %s \n " , resp.String ())
185
185
186
186
// upload the manifest (referencing the uploaded blob)
187
- ref := " test "
187
+ ref := " mytag "
188
188
manifest := []byte (fmt.Sprintf (
189
- ` {
190
- "mediaType": "application/vnd.oci.image.manifest.v1+json",
191
- "config": {
192
- "digest": "%s",
193
- "mediaType": "application/vnd.oci.image.config.v1+json",
194
- "size": %d
195
- },
196
- "layers": [],
197
- "schemaVersion": 2
198
- }` , blobDigest, len (blob)))
189
+ " { \" mediaType\" : \" application/vnd.oci.image.manifest.v1+json\" , \" config\" : { \" digest\" : \" %s \" , " +
190
+ " \" mediaType\" : \" application/vnd.oci.image.config.v1+json\" ," +" \" size\" : %d }, \" layers\" : [], " +
191
+ " \" schemaVersion\" : 2 }" ,
192
+ blobDigest, len (blob)))
199
193
req = client.NewRequest (reggie.PUT , " /v2/<name>/manifests/<reference>" ,
200
- reggie.WithReference (ref))
201
- req. SetHeader (" Content-Type" , " application/vnd.oci.image.manifest.v1+json" ).
194
+ reggie.WithReference (ref)).
195
+ SetHeader (" Content-Type" , " application/vnd.oci.image.manifest.v1+json" ).
202
196
SetBody (manifest)
203
197
resp, err = client.Do (req)
204
198
if err != nil {
@@ -207,13 +201,12 @@ func main() {
207
201
208
202
// validate the uploaded manifest content
209
203
req = client.NewRequest (reggie.GET , " /v2/<name>/manifests/<reference>" ,
210
- reggie.WithReference (ref))
211
- req. SetHeader (" Accept" , " application/vnd.oci.image.manifest.v1+json" )
204
+ reggie.WithReference (ref)).
205
+ SetHeader (" Accept" , " application/vnd.oci.image.manifest.v1+json" )
212
206
resp, err = client.Do (req)
213
207
if err != nil {
214
208
panic (err)
215
209
}
216
210
fmt.Printf (" Manifest content:\n %s \n " , resp.String ())
217
211
}
218
-
219
212
```
0 commit comments