Skip to content

Commit 07b7dcd

Browse files
committed
impr: doc, repositories descriptions and names
1 parent 5fadcf1 commit 07b7dcd

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,22 @@ The recipes avoid reinventing the wheel for common stuff, like deploying a conta
1818

1919
## Load into OCI registry
2020

21-
The following example focus on how to download the `debug` recipe then load it into an OCI registry.
21+
### From Docker Hub
22+
23+
You can [find the recipes images on our Docker Hub](https://hub.docker.com/u/ctferio?page=1&search=recipes).
24+
25+
Then, simply copy it where you need!
26+
```bash
27+
oras cp <image_from_docker_hub> <image_to_your_registry>
28+
```
29+
30+
Of course, you can directly use it for simplicity.
31+
32+
That's all :stuck_out_tongue_winking_eye::muscle:
33+
34+
### From GitHub release assets
35+
36+
The following example focus on how to download the `debug` recipe then load it into an OCI registry, from a GitHub release asset.
2237
All commands should **run in the same terminal**.
2338

2439
Requirements:
@@ -46,5 +61,3 @@ Requirements:
4661
export REGISTRY="localhost:5000"
4762
oras cp --from-oci-layout "./${DIR}:${LATEST}" "${REGISTRY}/debug:${LATEST}"
4863
```
49-
50-
That's it 😉

cmd/generator/main.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,17 @@ func run(ctx context.Context) (err error) {
8282
dir := filepath.Join(eco, e.Name())
8383
fmt.Printf("[+] Building %s@%s\n", dir, ver)
8484

85+
// Into which compressed archive
8586
into := filepath.Join(dist, fmt.Sprintf("%s_%s_%s.oci.tar.gz", eco, e.Name(), ver))
86-
dhRepoName := fmt.Sprintf("recipes_%s_%s", eco, e.Name())
87+
88+
// Transform into a Docker-compliant name
89+
sub := e.Name()
90+
sub = strings.ToLower(sub)
91+
sub = strings.NewReplacer(
92+
".", "-",
93+
).Replace(sub)
94+
dhRepoName := fmt.Sprintf("recipes_%s_%s", eco, sub)
95+
8796
if err := build(ctx, dir, into, dhRepoName, ver); err != nil {
8897
return errors.Wrapf(err, "failed to build %s", dir)
8998
}
@@ -295,7 +304,7 @@ func compress(path, target string) error {
295304

296305
func dhubPush(ctx context.Context, dir, repoName, version string) error {
297306
// Create the repository if does not exist already
298-
if err := dhClient.UpsertRepo(ctx, repoName); err != nil {
307+
if err := dhClient.UpsertRepo(ctx, dir, repoName); err != nil {
299308
return errors.Wrapf(err, "upserting ctferio/%s", repoName)
300309
}
301310

@@ -342,15 +351,15 @@ func Login(ctx context.Context, username, password string) (*DockerHubClient, er
342351
return &DockerHubClient{token: out.Token}, nil
343352
}
344353

345-
func (c *DockerHubClient) UpsertRepo(ctx context.Context, name string) error {
354+
func (c *DockerHubClient) UpsertRepo(ctx context.Context, dir, name string) error {
346355
exist, err := c.repoExists(ctx, name)
347356
if err != nil {
348357
return err
349358
}
350359
if exist {
351360
return nil
352361
}
353-
return c.createRepo(ctx, name, "Generated from Recipes...") // TODO generate description to target URL
362+
return c.createRepo(ctx, name, fmt.Sprintf("Generated from https://github.com/ctfer-io/recipes/blob/main/%s", dir))
354363
}
355364

356365
func (c *DockerHubClient) repoExists(ctx context.Context, name string) (bool, error) {

0 commit comments

Comments
 (0)