Skip to content

Commit f94c17d

Browse files
committed
fix(marketplace): stop advising cozypkg add after tap; make add idempotent
Live verification surfaced two rough edges of the auto-register change: cozypkg tap still printed "Install with: cozypkg add", now misleading since the apps register on connect, and running that add failed with AlreadyExists against the tap-managed registration Package. The tap message now says the apps register automatically, and cozypkg add treats an already-registered Package as done. Signed-off-by: IvanHunters <[email protected]>
1 parent b51b941 commit f94c17d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎cmd/cozypkg/cmd/add.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
cozyv1alpha1 "github.com/cozystack/cozystack/api/v1alpha1"
2929
"github.com/spf13/cobra"
30+
apierrors "k8s.io/apimachinery/pkg/api/errors"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3233
"k8s.io/apimachinery/pkg/runtime"
@@ -498,6 +499,12 @@ func installPackage(ctx context.Context, k8sClient client.Client, packageSourceN
498499
}
499500

500501
if err := k8sClient.Create(ctx, pkg); err != nil {
502+
// A tapped repository registers its apps on connect, so the Package
503+
// may already exist; treat that as done rather than an error.
504+
if apierrors.IsAlreadyExists(err) {
505+
_, _ = fmt.Fprintf(os.Stderr, "Package %s is already registered\n", pkgName)
506+
continue
507+
}
501508
return fmt.Errorf("failed to create Package %s: %w", pkgName, err)
502509
}
503510

‎cmd/cozypkg/cmd/tap.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ charts in your management cluster: tap only sources you trust.`,
327327
for _, n := range names {
328328
fmt.Fprintf(cmd.OutOrStdout(), " PackageSource/%s\n", n)
329329
}
330-
fmt.Fprintf(cmd.OutOrStdout(), "Install with: cozypkg add %s\n", names[0])
330+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "The repository's applications are registered automatically; browse them in the dashboard catalog and create instances there.\n")
331331
return nil
332332
},
333333
}

0 commit comments

Comments
 (0)