Skip to content

Commit 2f39e30

Browse files
committed
fix(marketplace): reconcile tap texts with no-install-on-connect
Removing on-connect auto-registration made several user-facing and doc texts wrong: they promised that tapping registers a repository's apps in the catalog and runs its charts. Tapping now installs nothing, so the texts told operators to wait for apps that never appear. Reword the `cozypkg tap`/`untap` help, the tap success output (now printing a `cozypkg add <name>` line per materialized PackageSource), the `cozypkg init` scaffold README, the packages-index trust model, the dashboard Repositories banner and per-repository empty state, and the stale re-registration code comments. No behaviour changes beyond the added `cozypkg add` hint in the tap output. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
1 parent 3fa534f commit 2f39e30

7 files changed

Lines changed: 61 additions & 49 deletions

File tree

‎cmd/cozypkg/cmd/add.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,13 @@ func installPackage(ctx context.Context, k8sClient client.Client, packageSourceN
529529
return fmt.Errorf("failed to create Package %s: %w", pkgName, err)
530530
}
531531
if !created {
532-
// The materializer auto-created the registration Package between the
533-
// List above and this Create, so this run did not take ownership of it
534-
// (its markers are not shed). Re-run so the reopen path pins it -- for a
535-
// non-default variant to apply the choice, and for the default variant so
536-
// a later privileged flip does not de-register this deliberate install.
537-
_, _ = fmt.Fprintf(os.Stderr, "Package %s was just auto-registered; re-run 'cozypkg add %s' to install variant %q as your own\n", pkgName, pkgName, variant)
532+
// A Package of this name appeared between the List above and this Create
533+
// (a concurrent add, or a tap-managed registration left by an older
534+
// Cozystack), so this run did not take ownership of it (its markers are
535+
// not shed). Re-run so the reopen path pins it -- for a non-default
536+
// variant to apply the choice, and for the default variant so a later
537+
// privileged flip does not de-register this deliberate install.
538+
_, _ = fmt.Fprintf(os.Stderr, "Package %s already exists; re-run 'cozypkg add %s' to install variant %q as your own\n", pkgName, pkgName, variant)
538539
continue
539540
}
540541

‎cmd/cozypkg/cmd/init.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ cozypkg validate .
157157
cozypkg push oci://<registry>/%s:<tag>
158158
`+"```"+`
159159
160-
## Connect (one command, on a Cozystack cluster)
160+
## Connect and install (on a Cozystack cluster)
161161
162162
`+"```bash"+`
163-
cozypkg tap oci://<registry>/%s:<tag>
163+
cozypkg tap oci://<registry>/%s:<tag> # connect the repository; installs nothing
164+
cozypkg add %s # install the app
164165
`+"```"+`
165-
`, psName, app, app, app, app, app),
166+
`, psName, app, app, app, app, app, psName),
166167
},
167168
}
168169
}

‎cmd/cozypkg/cmd/tap.go‎

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ func rewritePackageSourceForTap(ps *cozyv1alpha1.PackageSource, sourceName, sour
183183

184184
// clearMaterializedRevision removes the operator's materialized-revision
185185
// annotation from the tap's OCIRepository, so the next reconcile does not
186-
// short-circuit on the unchanged artifact revision and re-materializes (which
187-
// re-creates a registration removed out-of-band). A no-op when the source or the
188-
// annotation is absent.
186+
// short-circuit on the unchanged artifact revision and re-materializes its
187+
// PackageSources (recovering one removed out-of-band). A no-op when the source or
188+
// the annotation is absent.
189189
func clearMaterializedRevision(ctx context.Context, k8sClient client.Client, srcName string) error {
190190
reg := &sourcev1.OCIRepository{}
191191
if err := k8sClient.Get(ctx, client.ObjectKey{Name: srcName, Namespace: cozySystemNamespace}, reg); err != nil {
@@ -228,12 +228,11 @@ var tapCmd = &cobra.Command{
228228
creates a Flux OCIRepository pointing at the artifact and the PackageSource(s)
229229
the artifact carries, under the names the repository declares. A name that
230230
clashes with a core component (or another tap) is rejected, so an external
231-
package can never silently shadow an official one. The repository's applications
232-
register in the catalog automatically, unless the repository declares no default
233-
variant (then nothing is registered). A privileged install component of a
234-
registered app is not installed until the operator confirms it with 'cozypkg add
235-
--allow-privileged'. Tapping is idempotent. Creating cluster-scoped resources
236-
requires cluster-admin.
231+
package can never silently shadow an official one. Tapping installs nothing: it
232+
makes the repository's apps available as PackageSources. Install an app with
233+
'cozypkg add <name>'; a privileged install component is not installed until you
234+
confirm it with 'cozypkg add --allow-privileged'. Tapping is idempotent. Creating
235+
cluster-scoped resources requires cluster-admin.
237236
238237
With --secret the OCIRepository is given a pull-credential secretRef (the
239238
admin pre-creates the Secret in cozy-system), so a private repository taps in
@@ -243,8 +242,8 @@ Trust: tap validates the artifact's structure but does NOT verify its cosign
243242
signature. Signature verification is the community index's job at publication
244243
time ('cozypkg validate --require-signature' in the index CI gate, pinned to
245244
the entry's recorded identity), and can additionally be enforced at pull time
246-
via Flux OCIRepository verification. Tapping a third-party repository runs its
247-
charts in your management cluster: tap only sources you trust.`,
245+
via Flux OCIRepository verification. Installing an app from a tapped repository
246+
runs its charts in your management cluster: tap only sources you trust.`,
248247
Args: cobra.ExactArgs(1),
249248
RunE: func(cmd *cobra.Command, args []string) error {
250249
ctx := context.Background()
@@ -348,13 +347,10 @@ charts in your management cluster: tap only sources you trust.`,
348347
// Force a fresh materialization on this tap: clear the materialized-revision
349348
// annotation so the operator does not short-circuit on the unchanged
350349
// artifact revision. This makes a re-tap the supported recovery for a
351-
// registration Package (or PackageSource) removed out-of-band since the last
352-
// materialization -- e.g. garbage-collected when its PackageSource was
353-
// deleted. Note this re-registers ANY currently-absent app the artifact
354-
// declares, so a re-tap also undoes a `cozypkg del` of a tap-registered app;
355-
// the two are indistinguishable (both leave the registration absent), and
356-
// there is no per-app opt-out. A first tap has no such annotation, so this is
357-
// a no-op then.
350+
// PackageSource removed out-of-band since the last materialization. Tapping
351+
// no longer installs anything, so a re-tap does NOT re-install an app removed
352+
// with `cozypkg del`; re-install it with `cozypkg add`. A first tap has no
353+
// such annotation, so this is a no-op then.
358354
if err := clearMaterializedRevision(ctx, k8sClient, srcName); err != nil {
359355
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "warning: could not reset materialization state on OCIRepository/%s: %v\n", srcName, err)
360356
}
@@ -363,19 +359,25 @@ charts in your management cluster: tap only sources you trust.`,
363359
for _, n := range names {
364360
fmt.Fprintf(cmd.OutOrStdout(), " PackageSource/%s\n", n)
365361
}
366-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "The repository's applications register in the dashboard catalog automatically. A privileged install component is not installed until you confirm it with 'cozypkg add --allow-privileged'. Check the source's events if an app does not appear.\n")
362+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Tapping installs nothing. Install an app with:\n")
363+
for _, n := range names {
364+
fmt.Fprintf(cmd.OutOrStdout(), " cozypkg add %s\n", n)
365+
}
366+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "A privileged install component is not installed until you confirm it with 'cozypkg add --allow-privileged'.\n")
367367
return nil
368368
},
369369
}
370370

371371
var untapCmd = &cobra.Command{
372372
Use: "untap <packagesource-name>",
373373
Short: "Remove a tapped repository",
374-
Long: `Untap removes a tapped PackageSource, its Flux source, and the
375-
tap-managed registration Package that de-registers the repository's apps from
376-
the catalog. Running application instances are left in place but become
377-
unmanaged until the repository is tapped again. Only tapped sources (marked
378-
with the marketplace-tap label) can be untapped; official sources are refused.`,
374+
Long: `Untap removes a tapped PackageSource and its Flux source. A tap-managed
375+
registration Package left by an older Cozystack (one that registered apps on
376+
connect) is removed too, de-registering those apps. An app you installed yourself
377+
with 'cozypkg add' is left installed: untap refuses without --yes while such a
378+
Package is present. Running application instances are left in place but become
379+
unmanaged until the repository is tapped again. Only tapped sources (marked with
380+
the marketplace-tap label) can be untapped; official sources are refused.`,
379381
Args: cobra.ExactArgs(1),
380382
RunE: func(cmd *cobra.Command, args []string) error {
381383
k8sClient, err := newClusterClient(tapCmdFlags.kubeconfig)
@@ -404,13 +406,13 @@ func runUntap(ctx context.Context, k8sClient client.Client, name string, allowYe
404406
srcName = ps.Spec.SourceRef.Name
405407
}
406408

407-
// The registration Package (auto-created on connect, tap-managed)
408-
// de-registers the repository's apps and is removed with the untap. Deleting
409-
// it garbage-collects its registration HelmReleases and the
410-
// ApplicationDefinitions they render. It is removed only when it belongs to
411-
// THIS source (label AND source annotation); a Package a later tap created
412-
// under a reused name, or a foreign Package, is left in place and blocks the
413-
// untap without --yes.
409+
// A tap-managed registration Package (left by an older Cozystack that
410+
// registered apps on connect) de-registers the repository's apps and is
411+
// removed with the untap. Deleting it garbage-collects its registration
412+
// HelmReleases and the ApplicationDefinitions they render. It is removed only
413+
// when it belongs to THIS source (label AND source annotation); a Package a
414+
// later tap created under a reused name, or a foreign Package, is left in place
415+
// and blocks the untap without --yes.
414416
//
415417
// The Package is handled BEFORE the PackageSource: a transient error here must
416418
// abort the untap, not fall through to delete the PackageSource and OCIRepository

‎hack/packages-index/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ Cosign verification is **mandatory** on the gate for both lanes: the trust ancho
4242

4343
## Trust model
4444

45-
Signature verification happens here, at publication time, not at tap time. `cozypkg tap` and the dashboard connect flow validate an artifact's structure but do not verify its cosign signature: a cluster that taps a listed repository trusts that this index already verified it. The verification points are this CI gate (which pins each release to the entry's recorded identity) and, optionally, Flux `OCIRepository` verification at pull time. Tapping a third-party repository runs its charts in the management cluster, so operators should tap only sources they trust or that appear in a curated index like this one.
45+
Signature verification happens here, at publication time, not at tap time. `cozypkg tap` and the dashboard connect flow validate an artifact's structure but do not verify its cosign signature: a cluster that taps a listed repository trusts that this index already verified it. The verification points are this CI gate (which pins each release to the entry's recorded identity) and, optionally, Flux `OCIRepository` verification at pull time. Installing an app from a tapped repository runs its charts in the management cluster, so operators should tap only sources they trust or that appear in a curated index like this one.

‎internal/operator/tapmaterializer_reconciler.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ func (r *TapMaterializerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
169169
// Auto-registering on connect (removed) created a tap-managed Package whose
170170
// install-marked components Flux deployed under its cluster-admin service
171171
// account, so a publisher's install chart ran on connect with no operator
172-
// step (issue #4978). Installing is now explicit: `cozypkg add` (or a
173-
// dashboard action) creates the Package. Populating the catalog from
174-
// PackageSource metadata without an install is the long-term shape in
175-
// issue #4359.
172+
// step (issue #4978). Installing is now explicit: `cozypkg add` creates the
173+
// Package. Populating the catalog from PackageSource metadata without an
174+
// install is the long-term shape in issue #4359.
176175
applied[ps.GetName()] = true
177176
logger.Info("materialized PackageSource from tap", "name", ps.GetName(), "tap", repo.Name)
178177
}

‎packages/system/dashboard/images/console/apps/console/src/routes/TapsPage.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export function TapsPage() {
6262
</div>
6363

6464
<div className="mb-4 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800">
65-
Connecting a repository runs its charts in the management cluster. Connect only sources you
66-
trust. The index verifies signatures at publication time; connecting does not verify them.
65+
Connecting a repository makes its apps available but installs nothing. Install an app with{" "}
66+
<code>cozypkg add</code>. Connect only sources you trust. The index verifies signatures at
67+
publication time; connecting does not verify them.
6768
</div>
6869

6970
<div className="mb-6 flex flex-wrap items-end gap-2 rounded-lg border border-slate-200 bg-white p-4">
@@ -206,6 +207,12 @@ function TapCard({ tap, onDisconnect }: { tap: Tap; onDisconnect: (name: string)
206207
))}
207208
</ul>
208209
)}
210+
211+
{packages.length === 0 && (
212+
<p className="mt-3 text-xs text-slate-500">
213+
No apps installed from this repository yet. Install one with <code>cozypkg add</code>.
214+
</p>
215+
)}
209216
</div>
210217
)
211218
}

‎pkg/registry/core/tap/rest.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
258258
// Update only the fields this API owns (spec, the tap label and name
259259
// annotation) on the FETCHED object, so the operator's finalizer survives.
260260
// Clear the materialized-revision annotation so a re-connect re-materializes
261-
// and recovers a registration Package (or PackageSource) removed out-of-band
262-
// since the last materialization, the same recovery `cozypkg tap` performs.
261+
// and recovers a PackageSource removed out-of-band since the last
262+
// materialization, the same recovery `cozypkg tap` performs. Connecting
263+
// installs nothing, so this does not re-install an app removed with
264+
// `cozypkg del`.
263265
cur.Object["spec"] = repo.Object["spec"]
264266
labels := cur.GetLabels()
265267
if labels == nil {

0 commit comments

Comments
 (0)