Utilisez des libellés pour identifier et regrouper des dépôts associés. Vous pouvez spécifier plusieurs libellés pour un dépôt.
Qu'est-ce qu'un libellé ?
Un libellé est une paire clé-valeur que vous pouvez attribuer à des Trusted Cloud by S3NS
dépôts. Elle vous aide à organiser ces ressources et à gérer vos coûts à grande échelle avec la précision dont vous avez besoin. Vous pouvez associer un libellé à chaque ressource, puis filtrer les ressources par libellé.
Exigences relatives aux étiquettes
Les libellés appliqués à une ressource doivent répondre aux exigences suivantes :
Chaque ressource peut comporter jusqu'à 64 étiquettes.
Chaque libellé doit correspondre à une paire clé/valeur.
Les clés doivent comporter un (1) caractère au minimum et 63 au maximum, et ne peuvent pas être vides. Les valeurs peuvent être vides et comporter 63 caractères au maximum.
Les clés et les valeurs ne peuvent contenir que des lettres minuscules, des chiffres, des traits de soulignement et des tirets. Tous les caractères doivent être au format d'encodage UTF-8. Les caractères internationaux sont autorisés. Les clés doivent commencer par une lettre minuscule ou un caractère international.
La partie clé d'un libellé doit être unique au sein d'une ressource spécifique.
Cependant, vous pouvez utiliser la même clé avec plusieurs ressources.
Ces limites s'appliquent à la clé et à la valeur de chaque libellé, ainsi qu'aux ressources Trusted Cloud individuelles associées à des libellés. Vous pouvez appliquer autant de libellés que vous le souhaitez à toutes les ressources d'un projet.
Cas d'utilisation courants des libellés
Voici quelques cas d'utilisation courants des libellés :
Libellés d'équipe ou de centre de coûts: ajoutez des libellés en fonction de l'équipe ou du centre de coûts pour distinguer les dépôts appartenant à différentes équipes (par exemple, team:research et team:analytics). Vous pouvez utiliser ce type de libellé pour la comptabilité analytique ou la budgétisation.
Libellés de composant : par exemple, component:redis, component:frontend, component:ingest et component:dashboard.
Libellés d'environnement ou d'étape : par exemple, environment:production et environment:test.
Libellés d'état : par exemple, state:active, state:readytodelete et state:archive.
Libellés de propriété : permettent d'identifier les équipes responsables des opérations (par exemple, team:shopping-cart).
Nous vous déconseillons de créer de grands nombres d'étiquettes uniques (par exemple, pour les horodatages ou les valeurs individuelles pour chaque appel d'API).
Le problème avec cette approche est que lorsque les valeurs changent fréquemment ou que des clés encombrent le catalogue, il est difficile de filtrer efficacement les ressources et de créer des rapports associés.
Ajouter et mettre à jour des libellés
Vous pouvez ajouter un ou plusieurs libellés à un dépôt. Vous pouvez également modifier la valeur d'un libellé existant.
Pour ajouter un libellé à un dépôt:
Console
Ouvrez la page Dépôts dans la console Trusted Cloud .
REPOSITORY est le nom du dépôt. Si vous avez configuré un dépôt par défaut, vous pouvez omettre cet indicateur pour utiliser le dépôt par défaut.
PROJECT est l' Trusted Cloud by S3NS ID de projet. Si cette option est ignorée, le projet en cours ou par défaut est utilisé.
LOCATION est l'emplacement régional du dépôt.
Vous pouvez omettre l'option `--location` pour utiliser la valeur par défaut.
KEY=VALUE,... est une liste de libellés séparés par des virgules spécifiés sous la forme de paires clé/valeur. Exemple : team=team-1,product=example_product,stage=development.
Pour plus d'informations sur la commande, exécutez la commande suivante :
gcloudartifactsrepositoriesupdate--help
Filtrer les dépôts par libellé
Vous pouvez filtrer les listes de dépôts par libellé dans la Trusted Cloud console ou à l'aide de Google Cloud CLI.
Console
Ouvrez la page Dépôts dans la console Trusted Cloud .
Dans le champ Filtre, sélectionnez Libellés comme critère de filtrage, puis saisissez votre clé, votre valeur ou votre paire clé-valeur.
Par exemple, pour n'afficher que les dépôts associés au libellé env:dev, vous pouvez saisir l'un des éléments suivants:
Saisissez la clé : env
Saisissez la valeur : dev
Saisissez la paire clé-valeur : env:dev
gcloud
Pour effectuer un filtrage en fonction des libellés, utilisez l'indicateur --filter avec la commande gcloud artifacts repositories list.
La valeur de l'option --filter doit être au format labels.KEY=VALUE. Par exemple, si vous souhaitez filtrer les dépôts du projet actif sur un libellé avec env comme clé et dev comme valeur, vous pouvez exécuter la commande suivante:
gcloud artifacts repositories list --filter labels.env=dev
REPOSITORY est le nom du dépôt. Si vous avez configuré un dépôt par défaut, vous pouvez omettre cet indicateur pour utiliser le dépôt par défaut.
PROJECT est l' Trusted Cloud by S3NS ID de projet. Si cette option est ignorée, le projet en cours ou par défaut est utilisé.
LOCATION est l'emplacement régional du dépôt.
Utilisez cette option pour afficher les dépôts dans un emplacement spécifique. Si vous avez configuré un emplacement par défaut, vous pouvez omettre cette option pour utiliser la valeur par défaut.
LABEL,... est une liste de libellés séparés par des virgules, les clés de chaque paire KEY=VALUE. Exemple : team,product.
Pour plus d'informations sur la commande, exécutez la commande suivante :
gcloudartifactsrepositoriesupdate--help
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/18 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/08/18 (UTC)."],[[["\u003cp\u003eLabels are key-value pairs used to organize and manage Google Cloud repositories, allowing for filtering and cost breakdown in billing reports.\u003c/p\u003e\n"],["\u003cp\u003eEach repository can have up to 64 labels, with specific requirements for the keys and values, such as length, character types, and uniqueness within a single resource.\u003c/p\u003e\n"],["\u003cp\u003eCommon use cases for labels include team or cost center identification, component classification, environment or stage specification, state tracking, and ownership assignment.\u003c/p\u003e\n"],["\u003cp\u003eLabels are added, updated, filtered, and deleted through the Google Cloud console or using gcloud commands, with options to manage individual labels or clear all labels at once.\u003c/p\u003e\n"],["\u003cp\u003eWhile labels are useful for annotations, they differ from tags, which are specifically designed to control policies and conditionally allow or deny access based on a resource having a particular tag.\u003c/p\u003e\n"]]],[],null,["# Label repositories\n\nUse labels to identify and group related repositories. You can specify multiple\nlabels for a repository.\nTo group repositories and other resources across Google Cloud for reporting, auditing, and access control in your Google Cloud organization, use [tags](/artifact-registry/docs/repositories/tag-repos). Tags and labels work independently of each other, and you can apply both to the same repository.\n\nWhat are labels?\n----------------\n\nA label is a key-value pair that you can assign to Google Cloud repositories.\nThey help you organize these resources and manage your costs at scale, with the\ngranularity you need. You can attach a label to each resource, then filter the\nresources based on their labels. Information about labels is forwarded to the billing system that\nlets you break down your billed charges by label. With built-in [billing reports](/billing/docs/how-to/reports),\nyou can filter and group costs by resource labels. You can also use labels to\nquery [billing data exports](/billing/docs/how-to/bq-examples).\n\nRequirements for labels\n-----------------------\n\nThe labels applied to a resource must meet the following\nrequirements:\n\n- Each resource can have up to 64 labels.\n- Each label must be a key-value pair.\n- Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.\n- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. Keys must start with a lowercase letter or international character.\n- The key portion of a label must be unique within a single resource. However, you can use the same key with multiple resources.\n\nThese limits apply to the key and value for each label, and to the\nindividual Google Cloud resources that have labels. There\nis no limit on how many labels you can apply across all resources\nwithin a project.\n\nCommon uses of labels\n---------------------\n\nHere are some common use cases for labels:\n\n- **Team or cost center labels** : Add labels based on team or\n cost center to distinguish repositories owned by different\n teams (for example, `team:research` and `team:analytics`). You can use this\n type of label for cost accounting or budgeting.\n\n- **Component labels** : For example, `component:redis`,\n `component:frontend`, `component:ingest`, and `component:dashboard`.\n\n- **Environment or stage labels** : For example,\n `environment:production` and `environment:test`.\n\n- **State labels** : For example, `state:active`,\n `state:readytodelete`, and `state:archive`.\n\n- **Ownership labels** : Used to identify the teams that are\n responsible for operations, for example: `team:shopping-cart`.\n\n\n| **Note:** Don't include sensitive information in labels, including personally identifiable information, such as an individual's name or title. Labels are not designed to handle sensitive information.\n\nWe don't recommend creating large numbers of unique labels, such as\nfor timestamps or individual values for every API call.\nThe problem with this approach is that when the values change frequently or with\nkeys that clutter the catalog, this makes it difficult to effectively filter and\nreport on resources.\n\nLabels and tags\n---------------\n\nLabels can be used as queryable annotations for resources, but can't be used\nto set conditions on policies. Tags provide a way to conditionally allow or\ndeny policies based on whether a resource has a specific tag, by providing fine-grained\ncontrol over policies. For more information, see the\n[Tags overview](/resource-manager/docs/tags/tags-overview).\n\nAdding and updating labels\n--------------------------\n\nYou can add one or more labels to a repository. You can also edit the value of\nan existing label.\n\nTo label a repository: \n\n### Console\n\n1. Open the **Repositories** page in the Google Cloud console.\n\n [Open the Repositories page](https://console.cloud.google.com/artifacts)\n2. Select a repository.\n\n3. If the info panel next to the repository list is not open, click\n **Show Info Panel**.\n\n4. In the info panel, click the **Labels** tab.\n\n5. Add or edit labels:\n\n 1. To add a label, click **Add Label** . Specify the key and value pair for the label, then click **Save**.\n 2. To edit an existing label, change the value for the label, then click **Save**.\n\n### gcloud\n\nYou can specify one or more labels to add or edit.\n\n- If a label exists, the corresponding value is updated.\n- If a label does not exist, the label is created.\n- If the command also includes the `--clear-labels` flag, all existing labels are removed before adding new labels.\n\nRun the following command: \n\n gcloud artifacts repositories update \u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e [--project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e] \\\n [--location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e] --update-labels=\"\u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e=\u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e,...\"\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eREPOSITORY\u003c/code\u003e\u003c/var\u003e is the name of the repository. If you configured a [default](/artifact-registry/docs/gcloud-defaults) repository, you can omit this flag to use the default.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ePROJECT\u003c/code\u003e\u003c/var\u003e is the Google Cloud project ID. If this flag is omitted, then the current or default project is used.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eLOCATION\u003c/code\u003e\u003c/var\u003e is the regional or multi-regional [location](/artifact-registry/docs/repo-locations) of the repository. You can omit the \\`--location\\` flag to use the default.\n- \u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e`,...` is a list of comma-separated labels specified as key-value pairs. For example: `team=team-1,product=example_product,stage=development`.\n\nFor more information about the command, run the following command: \n\n gcloud artifacts repositories update --help\n\nFiltering repositories by label\n-------------------------------\n\nYou can filter repository lists by label in Google Cloud console or\nusing Google Cloud CLI. \n\n### Console\n\n1. Open the **Repositories** page in the Google Cloud console.\n\n [Open the Repositories page](https://console.cloud.google.com/artifacts)\n2. In the **Filter** field, select **Labels** as the filter criteria and then\n enter your key, value, or key-value pair.\n\n For example, to show only repositories with the label `env:dev`, you\n can enter any of the following:\n - Enter the key: `env`\n - Enter the value: `dev`\n - Enter the key-value pair: `env:dev`\n\n### gcloud\n\nTo filter based on labels, use the `--filter` flag with the\n[gcloud artifacts repositories list](/sdk/gcloud/reference/artifacts/repositories/list)\ncommand.\n\nThe value of `--filter` flag must be in the `labels.`\u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e\nformat. For example, if you wanted to filter repositories in the active\nproject on a label with `env` as the key and `dev` as the value, you can run\nthis command: \n\n gcloud artifacts repositories list --filter labels.env=dev\n\nFor more information about the filter syntax in the gcloud CLI,\nsee the\n[`gcloud topic filters` documentation](/sdk/gcloud/reference/topic/filters).\n\nDeleting labels\n---------------\n\nTo delete labels: \n\n### Console\n\n1. Open the **Repositories** page in the Google Cloud console.\n\n [Open the Repositories page](https://console.cloud.google.com/artifacts)\n2. Click **Select a repository**.\n\n3. If the info panel next to the repository list is not open, click\n **Show Info Panel**.\n\n4. In the info panel, click the **Labels** tab.\n\n5. Click **Delete Item** next to the label that you want to remove.\n\n### gcloud\n\nYou can delete specific labels or remove all labels for a repository.\n\nTo remove specific labels, run the following command: \n\n gcloud artifacts repositories update \u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e [--project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e] \\\n [--location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e] --remove-labels=\"\u003cvar translate=\"no\"\u003eLABEL\u003c/var\u003e,...\"\n\nTo remove all labels, run the following command: \n\n gcloud artifacts repositories update \u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e \\\n [--project=\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e] [--location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e] --clear-labels\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eREPOSITORY\u003c/code\u003e\u003c/var\u003e is the name of the repository. If you configured a [default](/artifact-registry/docs/gcloud-defaults) repository, you can omit this flag to use the default.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ePROJECT\u003c/code\u003e\u003c/var\u003e is the Google Cloud project ID. If this flag is omitted, the current or default project is used.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eLOCATION\u003c/code\u003e\u003c/var\u003e is the regional or multi-regional [location](/artifact-registry/docs/repo-locations) of the repository. Use this flag to view repositories in a specific location. If you configured a [default](/artifact-registry/docs/gcloud-defaults) location, then you can omit this flag to use the default.\n- \u003cvar translate=\"no\"\u003eLABEL\u003c/var\u003e,... is a list of comma-separated labels, the keys from each \u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e pair. For example: `team,product`.\n\nFor more information about the command, run the following command: \n\n gcloud artifacts repositories update --help"]]