Skip to content

Commit 44dc036

Browse files
authored
Merge pull request #214 from chmeliik/gomod-netrc
Document that private Go modules need .netrc
2 parents 442aad1 + f0b7a60 commit 44dc036

File tree

2 files changed

+59
-38
lines changed

2 files changed

+59
-38
lines changed

docs/modules/ROOT/pages/how-tos/configuring/creating-secrets.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ NOTE: One such task is the link:https://github.com/konflux-ci/build-definitions/
3030
. Optional: Under **Labels**, add a label to tag or provide more context for your secret.
3131
. Click **Add secret**.
3232

33+
=== Notable task input secrets
34+
35+
* xref:/how-tos/configuring/activation-keys-subscription.adoc#adding-activation-keys-to-the-workspace[activation-key]
36+
* xref:/how-tos/configuring/prefetching-dependencies.adoc#creating-the-netrc-secret[netrc]
37+
* xref:/how-tos/testing/build/snyk.adoc[snyk-secret]
38+
* xref:/how-tos/testing/integration/third-parties/testing-farm.adoc[testing-farm-secret]
39+
3340
== Creating registry pull secrets
3441

3542
Some container builds may use parent images from registries that require authentication, for example, `registry.redhat.io`. Until these credentials have been configured, the builds will continue to fail due to the system being unable to pull the required images.

docs/modules/ROOT/pages/how-tos/configuring/prefetching-dependencies.adoc

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ spec:
6868
* From the {ProductName} *Applications* view, go to *Activity > Latest commits*.
6969
//include::../partials/con_hermetic_verification.adoc[]
7070
71+
=== [[go-private]]Prefetching Go modules from private repos
72+
73+
To enable downloading modules from private repos, Go supports authentication via `.netrc`.
74+
You can create a netrc Secret for your pipeline as described xref:netrc[below].
75+
For more Go-specific `.netrc` details, see link:https://go.dev/doc/faq#git_https[the Go docs].
76+
7177
== [[pip]]Enabling prefetch builds for `pip`
7278
Cachi2 supports pip by parsing of `pip` requirements files, including but not limited to, `requirements.txt` files placed in the root of your repository. By generically parsing `pip` requirements files, Cachi2 downloads the specified dependencies.
7379

@@ -216,7 +222,7 @@ spec:
216222
* From the {ProductName} *Applications* view, go to *Activity > Latest commits*.
217223
//include::../partials/con_hermetic_verification.adoc[]
218224

219-
=== Prefetching `pip` dependencies from custom index servers
225+
=== [[custom-index-servers]]Prefetching `pip` dependencies from custom index servers
220226

221227
Cachi2 supports the link:https://pip.pypa.io/en/stable/cli/pip_install/#install-index-url[--index-url] option.
222228
You can add this option to your `requirements.txt` file(s), instructing Cachi2 to download packages from the specified
@@ -232,43 +238,8 @@ requests==2.32.2 \
232238
# ...other packages
233239
----
234240

235-
WARNING: Do not include credentials in the index url. If needed, provide authentication through a `.netrc` file (as described below).
236-
237-
To provide `.netrc` authentication for the index server:
238-
239-
. Create a key/value secret (see xref:/how-tos/configuring/creating-secrets.adoc[creating secrets for your builds]).
240-
Set `.netrc` as the key. Upload the content of your `.netrc` file as the value. For more details on netrc files,
241-
review the link:https://pip.pypa.io/en/stable/topics/authentication/#netrc-support[pip documentation for netrc support].
242-
243-
. In your `.tekton/` PipelineRun files, add the newly created secret to the `.spec.workspaces` section:
244-
245-
+
246-
[source,yaml]
247-
----
248-
spec:
249-
# ...
250-
workspaces:
251-
# ...
252-
- name: netrc
253-
secret:
254-
secretName: my-netrc # the name you assigned to the secret in step 1
255-
----
256-
257-
. In the `.spec.pipelineSpec.tasks` section, find the entry with `name: prefetch-dependencies`.
258-
Add the `netrc` workspace to the list of workspaces (if not present):
259-
260-
+
261-
[source,yaml]
262-
----
263-
tasks:
264-
# ...
265-
- name: prefetch-dependencies
266-
# ...
267-
workspaces:
268-
# ...
269-
- name: netrc
270-
workspace: netrc
271-
----
241+
WARNING: Do not include credentials in the index URL. If needed, provide authentication through a `.netrc` file (as described xref:netrc[below]).
242+
For more pip-specific details on netrc files, review the link:https://pip.pypa.io/en/stable/topics/authentication/#netrc-support[pip documentation for netrc support].
272243

273244
== [[npm]]Enabling prefetch builds for `npm`
274245
Cachi2 supports `npm` by fetching any dependencies you declare in your `package.json` and `package-lock.json` project files. The npm CLI manages the `package-lock.json` file automatically, and Cachi2 fetches any dependencies and enables your build to install them without network access.
@@ -499,6 +470,49 @@ In {ProductName}, from the *Applications* view, select the application build you
499470
* Select the *Logs* tab.
500471
* Alternatively, you can click *build-container*. When the right panel opens, select the *Logs* tab to see a partial view of the log for that build.
501472

473+
== [[netrc]]Creating the netrc secret
474+
475+
The `prefetch-dependencies` task supports link:https://everything.curl.dev/usingcurl/netrc.html[.netrc] files for authentication.
476+
For example, it is useful for:
477+
478+
* xref:custom-index-servers[pip packages from private index servers]
479+
* xref:go-private[Go modules from private repos]
480+
481+
To create a netrc Secret for use in your pipelines:
482+
483+
. Create the `.netrc` file locally. See the link:https://everything.curl.dev/usingcurl/netrc.html[.netrc] docs for more details on the file format.
484+
. Create a key/value secret (see xref:/how-tos/configuring/creating-secrets.adoc[creating secrets for your builds]).
485+
Set `.netrc` as the key. Upload the content of your `.netrc` file as the value.
486+
. In your `.tekton/` PipelineRun files, add the newly created secret to the `.spec.workspaces` section:
487+
488+
+
489+
[source,yaml]
490+
----
491+
spec:
492+
# ...
493+
workspaces:
494+
# ...
495+
- name: netrc
496+
secret:
497+
secretName: my-netrc # the name you assigned to the secret in step 2
498+
----
499+
500+
. In the `.spec.pipelineSpec.tasks` section, find the entry with `name: prefetch-dependencies`.
501+
Add the `netrc` workspace to the list of workspaces (if not present):
502+
503+
+
504+
[source,yaml]
505+
----
506+
tasks:
507+
# ...
508+
- name: prefetch-dependencies
509+
# ...
510+
workspaces:
511+
# ...
512+
- name: netrc
513+
workspace: netrc
514+
----
515+
502516
== Additional resources
503517

504518
* To troubleshoot any issues you might experience when you enable prefetch builds for `pip` or `pip` with source dependencies, see link:https://github.com/containerbuildsystem/cachi2/blob/main/docs/pip.md#troubleshooting[Troubleshooting].

0 commit comments

Comments
 (0)