# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

rules:
  - id: "mpl_busl"
    patterns:
      - pattern-either:
        - pattern-inside: |
            ...
            // SPDX-License-Identifier: MPL-2.0
            ...
            package $A
            ...
            import (
              ...
              ...
            )
            ...
        - pattern-inside: |
            ...
            // SPDX-License-Identifier: MPL-2.0
            ...
            package $A
            ...
            import ...
            ...
      - pattern: |
          "github.com/hashicorp/nomad/$...B"
      - metavariable-pattern:
          metavariable: $...B
          patterns:
            # List of MPL-2.0 packages that are allowed to be imported.
            # Command to find packages:
            #   find . -name LICENSE ! -path '*node_modules*' | sort
            - pattern-not: "api..."
            - pattern-not: "demo..."
            - pattern-not: "drivers/shared..."
            - pattern-not: "helper/crypto..."
            - pattern-not: "helper/grpc-middleware..."
            - pattern-not: "helper/pluginutils/grpcutils..."
            - pattern-not: "helper/pluginutils/hclspecutils..."
            - pattern-not: "helper/pointer..."
            - pattern-not: "helper/testlog..."
            - pattern-not: "helper/uuid..."
            - pattern-not: "jobspec..."
            - pattern-not: "jobspec2..."
            - pattern-not: "plugins..."
    message: "BUSL package `github.com/hashicorp/nomad/$...B` imported in MPL package `$A`"
    languages:
      - "generic"
    paths:
      exclude:
        - "*_test.go"
    severity: "ERROR"
