aboutsummaryrefslogtreecommitdiff
path: root/rules/providers.bzl
blob: 33a7fb570ae679ba676cb22f00a24908bc9061d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Basic providers for license rules.

This file should only contain the basic providers needed to create
license and package_info declarations. Providers needed to gather
them are declared in other places.
"""

LicenseKindInfo = provider(
    doc = """Provides information about a license_kind instance.""",
    fields = {
        "conditions": "list(string): List of conditions to be met when using this packages under this license.",
        "label": "Label: The full path to the license kind definition.",
        "long_name": "string: Human readable license name",
        "name": "string: Canonical license name",
    },
)

LicenseInfo = provider(
    doc = """Provides information about a license instance.""",
    fields = {
        "copyright_notice": "string: Human readable short copyright notice",
        "label": "Label: label of the license rule",
        "license_kinds": "list(LicenseKindInfo): License kinds ",
        "license_text": "string: The license file path",
        "namespace": "string: namespace of the license rule",
        # TODO(aiuto): move to PackageInfo
        "package_name": "string: Human readable package name",
        "package_url": "URL from which this package was downloaded.",
        "package_version": "Human readable version string",
    },
)

PackageInfo = provider(
    doc = """Provides information about a package.""",
    fields = {
        "type": "string: How to interpret data",
        "label": "Label: label of the package_info rule",
        "package_name": "string: Human readable package name",
        "package_url": "string: URL from which this package was downloaded.",
        "package_version": "string: Human readable version string",
    },
)

# This is more extensible. Because of the provider implementation, having a big
# dict of values rather than named fields is not much more costly.
# Design choice.  Replace data with actual providers, such as PackageInfo
ExperimentalMetadataInfo = provider(
    doc = """Generic bag of metadata.""",
    fields = {
        "type": "string: How to interpret data",
        "label": "Label: label of the metadata rule",
        "data": "String->any: Map of names to values",
    }
)