├── .github └── workflows │ ├── apply_recommendations.yml │ ├── do_apply_recommendations.yml │ ├── do_pull_recommendations.yml │ └── pull_recommendations.yml ├── .gitignore ├── LICENSE ├── README.md ├── apply_recommendations └── action.yml ├── docker ├── Dockerfile ├── action.yml ├── cmd │ └── adaptive-metrics │ │ ├── apply.go │ │ ├── diff.go │ │ ├── github_action.go │ │ ├── main.go │ │ └── pull.go ├── go.mod ├── go.sum ├── internal │ ├── client.go │ └── models.go └── vendor │ ├── github.com │ ├── google │ │ └── go-cmp │ │ │ ├── LICENSE │ │ │ └── cmp │ │ │ ├── compare.go │ │ │ ├── export.go │ │ │ ├── internal │ │ │ ├── diff │ │ │ │ ├── debug_disable.go │ │ │ │ ├── debug_enable.go │ │ │ │ └── diff.go │ │ │ ├── flags │ │ │ │ └── flags.go │ │ │ ├── function │ │ │ │ └── func.go │ │ │ └── value │ │ │ │ ├── name.go │ │ │ │ ├── pointer.go │ │ │ │ └── sort.go │ │ │ ├── options.go │ │ │ ├── path.go │ │ │ ├── report.go │ │ │ ├── report_compare.go │ │ │ ├── report_references.go │ │ │ ├── report_reflect.go │ │ │ ├── report_slices.go │ │ │ ├── report_text.go │ │ │ └── report_value.go │ └── prometheus │ │ ├── client_model │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── go │ │ │ └── metrics.pb.go │ │ └── common │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── model │ │ ├── alert.go │ │ ├── fingerprinting.go │ │ ├── fnv.go │ │ ├── labels.go │ │ ├── labelset.go │ │ ├── labelset_string.go │ │ ├── labelset_string_go120.go │ │ ├── metadata.go │ │ ├── metric.go │ │ ├── model.go │ │ ├── signature.go │ │ ├── silence.go │ │ ├── time.go │ │ ├── value.go │ │ ├── value_float.go │ │ ├── value_histogram.go │ │ └── value_type.go │ ├── google.golang.org │ └── protobuf │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── encoding │ │ ├── prototext │ │ │ ├── decode.go │ │ │ ├── doc.go │ │ │ └── encode.go │ │ └── protowire │ │ │ └── wire.go │ │ ├── internal │ │ ├── descfmt │ │ │ └── stringer.go │ │ ├── descopts │ │ │ └── options.go │ │ ├── detrand │ │ │ └── rand.go │ │ ├── editiondefaults │ │ │ ├── defaults.go │ │ │ └── editions_defaults.binpb │ │ ├── encoding │ │ │ ├── defval │ │ │ │ └── default.go │ │ │ ├── messageset │ │ │ │ └── messageset.go │ │ │ ├── tag │ │ │ │ └── tag.go │ │ │ └── text │ │ │ │ ├── decode.go │ │ │ │ ├── decode_number.go │ │ │ │ ├── decode_string.go │ │ │ │ ├── decode_token.go │ │ │ │ ├── doc.go │ │ │ │ └── encode.go │ │ ├── errors │ │ │ ├── errors.go │ │ │ ├── is_go112.go │ │ │ └── is_go113.go │ │ ├── filedesc │ │ │ ├── build.go │ │ │ ├── desc.go │ │ │ ├── desc_init.go │ │ │ ├── desc_lazy.go │ │ │ ├── desc_list.go │ │ │ ├── desc_list_gen.go │ │ │ ├── editions.go │ │ │ └── placeholder.go │ │ ├── filetype │ │ │ └── build.go │ │ ├── flags │ │ │ ├── flags.go │ │ │ ├── proto_legacy_disable.go │ │ │ └── proto_legacy_enable.go │ │ ├── genid │ │ │ ├── any_gen.go │ │ │ ├── api_gen.go │ │ │ ├── descriptor_gen.go │ │ │ ├── doc.go │ │ │ ├── duration_gen.go │ │ │ ├── empty_gen.go │ │ │ ├── field_mask_gen.go │ │ │ ├── go_features_gen.go │ │ │ ├── goname.go │ │ │ ├── map_entry.go │ │ │ ├── source_context_gen.go │ │ │ ├── struct_gen.go │ │ │ ├── timestamp_gen.go │ │ │ ├── type_gen.go │ │ │ ├── wrappers.go │ │ │ └── wrappers_gen.go │ │ ├── impl │ │ │ ├── api_export.go │ │ │ ├── checkinit.go │ │ │ ├── codec_extension.go │ │ │ ├── codec_field.go │ │ │ ├── codec_gen.go │ │ │ ├── codec_map.go │ │ │ ├── codec_map_go111.go │ │ │ ├── codec_map_go112.go │ │ │ ├── codec_message.go │ │ │ ├── codec_messageset.go │ │ │ ├── codec_reflect.go │ │ │ ├── codec_tables.go │ │ │ ├── codec_unsafe.go │ │ │ ├── convert.go │ │ │ ├── convert_list.go │ │ │ ├── convert_map.go │ │ │ ├── decode.go │ │ │ ├── encode.go │ │ │ ├── enum.go │ │ │ ├── extension.go │ │ │ ├── legacy_enum.go │ │ │ ├── legacy_export.go │ │ │ ├── legacy_extension.go │ │ │ ├── legacy_file.go │ │ │ ├── legacy_message.go │ │ │ ├── merge.go │ │ │ ├── merge_gen.go │ │ │ ├── message.go │ │ │ ├── message_reflect.go │ │ │ ├── message_reflect_field.go │ │ │ ├── message_reflect_gen.go │ │ │ ├── pointer_reflect.go │ │ │ ├── pointer_unsafe.go │ │ │ ├── validate.go │ │ │ └── weak.go │ │ ├── order │ │ │ ├── order.go │ │ │ └── range.go │ │ ├── pragma │ │ │ └── pragma.go │ │ ├── set │ │ │ └── ints.go │ │ ├── strs │ │ │ ├── strings.go │ │ │ ├── strings_pure.go │ │ │ ├── strings_unsafe_go120.go │ │ │ └── strings_unsafe_go121.go │ │ └── version │ │ │ └── version.go │ │ ├── proto │ │ ├── checkinit.go │ │ ├── decode.go │ │ ├── decode_gen.go │ │ ├── doc.go │ │ ├── encode.go │ │ ├── encode_gen.go │ │ ├── equal.go │ │ ├── extension.go │ │ ├── merge.go │ │ ├── messageset.go │ │ ├── proto.go │ │ ├── proto_methods.go │ │ ├── proto_reflect.go │ │ ├── reset.go │ │ ├── size.go │ │ ├── size_gen.go │ │ └── wrappers.go │ │ ├── reflect │ │ ├── protoreflect │ │ │ ├── methods.go │ │ │ ├── proto.go │ │ │ ├── source.go │ │ │ ├── source_gen.go │ │ │ ├── type.go │ │ │ ├── value.go │ │ │ ├── value_equal.go │ │ │ ├── value_pure.go │ │ │ ├── value_union.go │ │ │ ├── value_unsafe_go120.go │ │ │ └── value_unsafe_go121.go │ │ └── protoregistry │ │ │ └── registry.go │ │ ├── runtime │ │ ├── protoiface │ │ │ ├── legacy.go │ │ │ └── methods.go │ │ └── protoimpl │ │ │ ├── impl.go │ │ │ └── version.go │ │ └── types │ │ └── known │ │ └── timestamppb │ │ └── timestamp.pb.go │ └── modules.txt └── pull_recommendations └── action.yml /.github/workflows/apply_recommendations.yml: -------------------------------------------------------------------------------- 1 | name: Apply Adaptive Metrics recommendations 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | grafana_am_api_url: 7 | required: true 8 | type: string 9 | secrets: 10 | grafana_am_api_key: 11 | required: true 12 | 13 | jobs: 14 | autoapply: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | contents: write 18 | pull-requests: write 19 | env: 20 | GRAFANA_AM_API_URL: ${{ inputs.grafana_am_api_url }} 21 | GRAFANA_AM_API_KEY: ${{ secrets.grafana_am_api_key }} 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | with: 26 | persist-credentials: false 27 | - name: Apply recommendations 28 | uses: ./apply_recommendations 29 | - name: Commit and push changes 30 | run: | 31 | git config user.name github-actions 32 | git config user.email github-actions@github.com 33 | git add . 34 | git commit -m 'Auto-apply updated aggregation rules.' || exit 0 35 | git push 36 | -------------------------------------------------------------------------------- /.github/workflows/do_apply_recommendations.yml: -------------------------------------------------------------------------------- 1 | name: Triggered apply of Adaptive Metrics recommendations 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - 'main' 8 | paths: 9 | - 'recommendations.json' 10 | - 'recommendations-*.json' 11 | - 'main.tf' 12 | 13 | permissions: 14 | contents: write 15 | pull-requests: write 16 | 17 | jobs: 18 | do-autoapply: 19 | uses: ./.github/workflows/apply_recommendations.yml 20 | with: 21 | grafana_am_api_url: ${{ vars.grafana_am_api_url }} 22 | secrets: 23 | grafana_am_api_key: ${{ secrets.grafana_am_api_key }} 24 | -------------------------------------------------------------------------------- /.github/workflows/do_pull_recommendations.yml: -------------------------------------------------------------------------------- 1 | name: Scheduled refresh of Adaptive Metrics recommendations 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 4 * * 1-5' 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | do-autoapply: 14 | uses: ./.github/workflows/pull_recommendations.yml 15 | with: 16 | grafana_am_api_url: ${{ vars.grafana_am_api_url }} 17 | secrets: 18 | grafana_am_api_key: ${{ secrets.grafana_am_api_key }} 19 | automerge_pat: ${{ secrets.automerge_pat }} 20 | -------------------------------------------------------------------------------- /.github/workflows/pull_recommendations.yml: -------------------------------------------------------------------------------- 1 | name: Pull Adaptive Metrics recommendations 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | grafana_am_api_url: 7 | required: true 8 | type: string 9 | secrets: 10 | grafana_am_api_key: 11 | required: true 12 | automerge_pat: 13 | 14 | jobs: 15 | autoapply: 16 | runs-on: ubuntu-latest 17 | permissions: 18 | contents: write 19 | pull-requests: write 20 | env: 21 | GRAFANA_AM_API_URL: ${{ inputs.grafana_am_api_url }} 22 | GRAFANA_AM_API_KEY: ${{ secrets.grafana_am_api_key }} 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | with: 27 | persist-credentials: false 28 | - name: Pull recommendations 29 | uses: ./pull_recommendations 30 | id: pull_recommendations 31 | - name: Create pull request 32 | id: cpr 33 | uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.0.0 34 | with: 35 | title: Scheduled refresh of the latest recommendations. 36 | commit-message: Scheduled refresh of the latest recommendations. 37 | body: Scheduled refresh of the latest recommendations. 38 | - name: Enable pull request auto-merge 39 | if: ${{ steps.cpr.outputs.pull-request-operation == 'created' && env.GH_TOKEN != '' }} 40 | run: | 41 | # Validate PR number is a positive integer 42 | if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then 43 | echo "Error: Invalid pull request number" 44 | exit 1 45 | fi 46 | gh pr merge --merge --auto "$PR_NUMBER" 47 | env: 48 | GH_TOKEN: ${{ secrets.automerge_pat }} 49 | PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }} 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automatically apply recommendations from Adaptive Metrics 2 | 3 | Use this template repository to set up auto-apply mode for Adaptive Metrics in Grafana Cloud. 4 | 5 | > [!NOTE] 6 | > Auto-apply mode for Adaptive Metrics is currently in [public preview](https://grafana.com/docs/release-life-cycle/). This feature is still under development and support is limited at this time. 7 | 8 | ## What to expect 9 | 10 | By default, auto-apply mode runs at 04:00 UTC Monday through Friday. To configure this setting, edit the `schedule` parameter in the `.github/workflows/pull_recommendations.yml` file. 11 | 12 | At the scheduled time, the GitHub Action pulls the latest recommendations and creates a pull request named "Scheduled refresh of the latest recommendations". 13 | 14 | After you merge this pull request, the GitHub Action uploads the updated rules to Grafana Cloud. 15 | 16 | You can also set the pull request to merge automatically. 17 | 18 | ## Automatically apply recommendations 19 | 20 | Create a new repository using this one as a template to automatically apply Adaptive Metrics recommendations in Grafana Cloud. 21 | 22 | 1. Create a new repository by navigating to "Use this template" → "Create a new repository" at the top-right of the repository page in GitHub. 23 | 24 | 2. Go to "Settings" → "Secrets and variables" → "Actions" → "Variables" → " New repository variable" and add the following variable to the new repository: 25 | 26 | - `grafana_am_api_url`: This is your Grafana Cloud Prometheus URL. To find this URL, go to your `grafana.com` account (https://grafana.com → "My Account") and click on the "Details" button of your Grafana Cloud Prometheus stack. 27 | The URL is listed at the top of the page next to the Prometheus icon. 28 | > Make sure to use only the host part of this URL. Remove any parameters after `grafana.net`. 29 | 30 | 3. Go to "Settings" → "Secrets and variables" → "Actions" → "New repository secret" and add the following secret to the new repository: 31 | 32 | - `grafana_am_api_key`: You must specify this key in the format `:`, where: 33 | - `` is the numeric instance ID for which you want to enable auto-apply mode. You can find this value in the "Query Endpoint" section of the *Details* page under "Username / Instance ID". 34 | - `` is a token from a [Grafana Cloud Access Policy](https://grafana.com/docs/grafana-cloud/account-management/authentication-and-permissions/access-policies/). Make sure the access policy has `metrics:read` and `metrics:write` scopes for the appropriate stack ID. 35 | 36 | 4. Go to "Settings" → "Actions" → "General" → "Workflow permissions" and select the checkbox for "Allow GitHub Actions to create and approve pull requests". Then, click "Save". 37 | 38 | After you set up this configuration, you can manually run the workflow named "Pull Adaptive Metrics recommendations". 39 | By default, this workflow creates a pull request with the latest recommendations. 40 | After you merge this pull request, the workflow automatically creates the corresponding set of aggregation rules. 41 | 42 | ## (Optional) Automatically merge rules 43 | 44 | You can enable auto-merge mode to skip the manual pull request review and merge processes. 45 | 46 | 1. Create a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). The personal access token should have access to the repo and read/write permissions for "Pull Requests" and "Contents" enabled. 47 | 48 | 2. Go to "Settings" → "Secrets and variables" → "Actions" → "New repository secret" and add the following secret to the new repository: 49 | 50 | - `automerge_pat`: This is the personal access token you created in the previous step. 51 | 52 | ## See also 53 | 54 | - [Grafana Adaptive Metrics](https://grafana.com/docs/grafana-cloud/cost-management-and-billing/reduce-costs/metrics-costs/control-metrics-usage-via-adaptive-metrics/) 55 | - [Grafana Adaptive Metrics Terraform provider](https://registry.terraform.io/providers/grafana/grafana-adaptive-metrics/latest/docs) 56 | 57 | Have feedback about this feature? Open an issue to let the team know! 58 | -------------------------------------------------------------------------------- /apply_recommendations/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Grafana Adaptive Metrics Auto-apply (Apply Recommendations)' 2 | description: 'Apply your Adaptive Metrics recommendations.' 3 | runs: 4 | using: 'docker' 5 | image: '../docker/Dockerfile' 6 | args: 7 | - apply 8 | inputs: 9 | working-dir: 10 | default: './' 11 | description: 'The directory to run the apply in.' 12 | dry-run: 13 | default: 'false' 14 | description: 'Whether to apply the recommendations or just print a summary of changes.' 15 | managed-by: 16 | default: 'gh-action-autoapply' 17 | description: 'The tag used to set the managed_by label on applied rules.' 18 | outputs: 19 | changes-detected: 20 | description: 'Whether any changes were detected in the recommendations.' 21 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.22.5-bookworm AS build 2 | 3 | COPY . /opt 4 | WORKDIR /opt 5 | 6 | RUN CGO_ENABLED=0 GOOS=linux go build -o /adaptive-metrics-auto-apply ./cmd/adaptive-metrics/ 7 | 8 | FROM gcr.io/distroless/base-debian11 9 | 10 | WORKDIR / 11 | 12 | COPY --from=build /adaptive-metrics-auto-apply /adaptive-metrics-auto-apply 13 | 14 | ENTRYPOINT ["/adaptive-metrics-auto-apply"] 15 | -------------------------------------------------------------------------------- /docker/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Grafana Adaptive Metrics Auto-apply (Apply Recommendations)' 2 | description: 'Apply your Adaptive Metrics recommendations.' 3 | runs: 4 | using: 'docker' 5 | image: 'Dockerfile' 6 | inputs: 7 | working-dir: 8 | default: './' 9 | description: 'The directory to run the apply in.' 10 | dry-run: 11 | default: 'false' 12 | description: 'Whether to apply the recommendations or just print tf plan output.' 13 | managed-by: 14 | default: 'gh-action-autoapply' 15 | description: 'The tag used to set the managed_by label on applied rules.' 16 | -------------------------------------------------------------------------------- /docker/cmd/adaptive-metrics/diff.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "reflect" 7 | "strings" 8 | 9 | "github.com/google/go-cmp/cmp" 10 | 11 | "github.com/grafana/adaptive-metrics-autoapply/docker/internal" 12 | ) 13 | 14 | func writeDiff(output io.Writer, segment internal.Segment, oldRec, newRec []internal.Recommendation) int { 15 | type stateChange struct { 16 | old, new internal.Recommendation 17 | } 18 | 19 | changesByName := map[string]stateChange{} 20 | for _, rule := range oldRec { 21 | changesByName[rule.Metric] = stateChange{old: rule} 22 | } 23 | 24 | for _, rule := range newRec { 25 | change, ok := changesByName[rule.Metric] 26 | if !ok { 27 | changesByName[rule.Metric] = stateChange{new: rule} 28 | continue 29 | } 30 | 31 | change.new = rule 32 | changesByName[rule.Metric] = change 33 | } 34 | 35 | var changes int 36 | var segmentOutput = new(strings.Builder) 37 | for _, change := range changesByName { 38 | if generateDiff(segmentOutput, change.old, change.new) { 39 | changes++ 40 | } 41 | } 42 | 43 | if changes > 0 { 44 | diffOutput := segmentOutput.String() 45 | diffOutput = strings.Trim(diffOutput, "\n") 46 | fmt.Fprintf(output, "#### Segment %q:\n```diff\n%s\n```\n", segment.Name, diffOutput) 47 | } 48 | 49 | return changes 50 | } 51 | 52 | func generateDiff(output *strings.Builder, a, b internal.Recommendation) bool { 53 | 54 | aVal := reflect.ValueOf(a) 55 | bVal := reflect.ValueOf(b) 56 | rType := aVal.Type() 57 | 58 | metricName := a.Metric 59 | diffType := "~" 60 | if aVal.IsZero() { 61 | diffType = "+" 62 | metricName = b.Metric 63 | } 64 | if bVal.IsZero() { 65 | diffType = "-" 66 | metricName = a.Metric 67 | } 68 | 69 | metricOutput := new(strings.Builder) 70 | for i := 0; i < aVal.NumField(); i++ { 71 | fieldType := rType.Field(i) 72 | if fieldType.Name == "Metric" { 73 | continue 74 | } 75 | aField := aVal.Field(i) 76 | bField := bVal.Field(i) 77 | name := strings.Split(fieldType.Tag.Get("json"), ",")[0] 78 | 79 | if aField.IsZero() && bField.IsZero() { 80 | continue 81 | } 82 | 83 | if aField.IsZero() { 84 | fmt.Fprintf(metricOutput, "+\t%s=%q\n", name, bField.Interface()) 85 | continue 86 | } 87 | 88 | if bField.IsZero() { 89 | fmt.Fprintf(metricOutput, "-\t%s=%q\n", name, aField.Interface()) 90 | continue 91 | } 92 | 93 | d := cmp.Diff(aField.Interface(), bField.Interface()) 94 | if d != "" { 95 | fmt.Fprintf(metricOutput, "~\t%s\n", name) 96 | fmt.Fprintln(metricOutput, d) 97 | } 98 | } 99 | 100 | if metricOutput.Len() > 0 { 101 | fmt.Fprintf(output, "%s%s\n%s", diffType, metricName, metricOutput.String()) 102 | output.WriteString("\n") 103 | return true 104 | } 105 | 106 | return false 107 | } 108 | -------------------------------------------------------------------------------- /docker/cmd/adaptive-metrics/github_action.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | type githubActionWorkflowCommands struct { 11 | outputFile io.WriteCloser 12 | summaryFile io.WriteCloser 13 | } 14 | 15 | func newGithubActionWorkflowCommands() (*githubActionWorkflowCommands, error) { 16 | if os.Getenv("GITHUB_ACTIONS") != "true" { 17 | return nil, nil 18 | } 19 | 20 | outputFile, err := os.OpenFile(os.Getenv("GITHUB_OUTPUT"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | summaryFile, err := os.OpenFile(os.Getenv("GITHUB_STEP_SUMMARY"), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644) 26 | if err != nil { 27 | return nil, err 28 | } 29 | 30 | return &githubActionWorkflowCommands{ 31 | outputFile: outputFile, 32 | summaryFile: summaryFile, 33 | }, nil 34 | } 35 | 36 | func (c *githubActionWorkflowCommands) writeStepSummary(summary string) error { 37 | if c == nil { 38 | return nil 39 | } 40 | 41 | _, err := io.WriteString(c.summaryFile, summary) 42 | return err 43 | } 44 | 45 | func (c *githubActionWorkflowCommands) writeOutput(name, value string) error { 46 | if c == nil { 47 | return nil 48 | } 49 | 50 | name = strings.ReplaceAll(name, " ", "_") 51 | 52 | _, err := fmt.Fprintf(c.outputFile, "%s=%s\n", name, value) 53 | return err 54 | } 55 | 56 | func (c *githubActionWorkflowCommands) close() { 57 | if c == nil { 58 | return 59 | } 60 | 61 | c.outputFile.Close() 62 | c.summaryFile.Close() 63 | } 64 | -------------------------------------------------------------------------------- /docker/cmd/adaptive-metrics/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | if len(os.Args) < 2 { 10 | log.Fatalf("missing command, available commands: pull, apply") 11 | } 12 | 13 | switch os.Args[1] { 14 | case "pull": 15 | pull(os.Args[2:]) 16 | case "apply": 17 | apply(os.Args[2:]) 18 | default: 19 | log.Fatalf("unknown command %s, available commands: pull, apply", os.Args[1]) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docker/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/grafana/adaptive-metrics-autoapply/docker 2 | 3 | go 1.22.5 4 | 5 | require ( 6 | github.com/google/go-cmp v0.6.0 7 | github.com/prometheus/common v0.55.0 8 | ) 9 | 10 | require ( 11 | github.com/prometheus/client_model v0.6.1 // indirect 12 | google.golang.org/protobuf v1.34.2 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /docker/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 2 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 3 | github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= 4 | github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= 5 | github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= 6 | github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= 7 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 8 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 9 | -------------------------------------------------------------------------------- /docker/internal/client.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | "net/http" 9 | "net/url" 10 | "strconv" 11 | ) 12 | 13 | type Client struct { 14 | httpClient *http.Client 15 | userAgent string 16 | 17 | apiURL string 18 | apiKey string 19 | } 20 | 21 | func NewClient(httpClient *http.Client, userAgent, apiURL, apiKey string) *Client { 22 | return &Client{ 23 | httpClient: httpClient, 24 | userAgent: userAgent, 25 | apiURL: apiURL, 26 | apiKey: apiKey, 27 | } 28 | } 29 | 30 | func (c *Client) FetchSegments() ([]Segment, error) { 31 | resp, err := c.makeNewRequest(http.MethodGet, "aggregations/rules/segments", nil, nil, nil) 32 | if err != nil { 33 | return nil, err 34 | } 35 | defer resp.Body.Close() 36 | 37 | var segments []Segment 38 | if err = json.NewDecoder(resp.Body).Decode(&segments); err != nil { 39 | return nil, err 40 | } 41 | 42 | return segments, nil 43 | } 44 | 45 | func (c *Client) FetchRecommendations(segment Segment, verbose bool) ([]Recommendation, error) { 46 | resp, err := c.makeNewRequest(http.MethodGet, "aggregations/recommendations", url.Values{ 47 | "segment": []string{segment.Identifier}, 48 | "verbose": []string{strconv.FormatBool(verbose)}, 49 | }, nil, nil) 50 | if err != nil { 51 | return nil, err 52 | } 53 | defer resp.Body.Close() 54 | 55 | var recs []Recommendation 56 | if err = json.NewDecoder(resp.Body).Decode(&recs); err != nil { 57 | return nil, err 58 | } 59 | 60 | return recs, nil 61 | } 62 | 63 | func (c *Client) ValidateRules(rules []Recommendation) error { 64 | buf, err := json.Marshal(rules) 65 | if err != nil { 66 | return err 67 | } 68 | 69 | resp, err := c.makeNewRequest(http.MethodPost, "aggregations/check-rules", nil, nil, bytes.NewReader(buf)) 70 | if err != nil { 71 | return err 72 | } 73 | defer resp.Body.Close() 74 | 75 | if resp.StatusCode != http.StatusOK { 76 | bodyBuf, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) 77 | if err != nil { 78 | return fmt.Errorf("unexpected status code: %d", resp.StatusCode) 79 | } 80 | 81 | return fmt.Errorf("unexpected status code: %d with body %q", resp.StatusCode, bodyBuf) 82 | } 83 | 84 | return nil 85 | } 86 | 87 | func (c *Client) GetRules(segment Segment) ([]Recommendation, string, error) { 88 | resp, err := c.makeNewRequest(http.MethodGet, "aggregations/rules", url.Values{ 89 | "segment": []string{segment.Identifier}, 90 | }, nil, nil) 91 | if err != nil { 92 | return nil, "", err 93 | } 94 | defer resp.Body.Close() 95 | if resp.StatusCode != http.StatusOK { 96 | return nil, "", fmt.Errorf("unexpected status code: %d", resp.StatusCode) 97 | } 98 | 99 | etag := resp.Header.Get("ETag") 100 | var rules []Recommendation 101 | if err = json.NewDecoder(resp.Body).Decode(&rules); err != nil { 102 | return nil, "", err 103 | } 104 | 105 | return rules, etag, nil 106 | } 107 | 108 | func (c *Client) UpdateRules(segment Segment, etag string, rules []Recommendation) error { 109 | buf, err := json.Marshal(rules) 110 | if err != nil { 111 | return err 112 | } 113 | 114 | resp, err := c.makeNewRequest(http.MethodPost, "aggregations/rules", url.Values{ 115 | "segment": []string{segment.Identifier}, 116 | }, http.Header{"If-Match": []string{etag}}, bytes.NewReader(buf)) 117 | if err != nil { 118 | return err 119 | } 120 | defer resp.Body.Close() 121 | 122 | if resp.StatusCode != http.StatusOK { 123 | bodyBuf, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) 124 | if err != nil { 125 | return fmt.Errorf("unexpected status code: %d", resp.StatusCode) 126 | } 127 | 128 | return fmt.Errorf("unexpected status code: %d with body %q", resp.StatusCode, bodyBuf) 129 | } 130 | 131 | return nil 132 | } 133 | 134 | func (c *Client) makeNewRequest(method, subPath string, queryParams url.Values, headers http.Header, body io.Reader) (*http.Response, error) { 135 | p := fmt.Sprintf("%s/%s", c.apiURL, subPath) 136 | if queryParams != nil { 137 | p += "?" + queryParams.Encode() 138 | } 139 | 140 | req, err := http.NewRequest(method, p, body) 141 | if err != nil { 142 | return nil, err 143 | } 144 | 145 | if headers == nil { 146 | headers = make(http.Header) 147 | } 148 | req.Header = headers.Clone() 149 | req.Header.Set("User-Agent", c.userAgent) 150 | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.apiKey)) 151 | 152 | return c.httpClient.Do(req) 153 | } 154 | -------------------------------------------------------------------------------- /docker/internal/models.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/prometheus/common/model" 5 | ) 6 | 7 | const ( 8 | DefaultSegmentName = "default" 9 | ) 10 | 11 | var DefaultSegment = Segment{Name: DefaultSegmentName} 12 | 13 | type Segment struct { 14 | Identifier string `json:"id,omitempty"` 15 | Name string `json:"name"` 16 | Selector string `json:"selector,omitempty"` 17 | FallbackToDefault bool `json:"fallback_to_default,omitempty"` 18 | } 19 | 20 | type RuleData struct { 21 | Metric string `json:"metric" yaml:"metric"` 22 | MatchType string `json:"match_type,omitempty" yaml:"match_type,omitempty"` 23 | 24 | Drop bool `json:"drop,omitempty" yaml:"drop,omitempty"` 25 | KeepLabels []string `json:"keep_labels,omitempty" yaml:"keep_labels,omitempty"` 26 | DropLabels []string `json:"drop_labels,omitempty" yaml:"drop_labels,omitempty"` 27 | 28 | Aggregations []string `json:"aggregations,omitempty" yaml:"aggregations,omitempty"` 29 | AggregationInterval model.Duration `json:"aggregation_interval,omitempty" yaml:"aggregation_interval,omitempty"` 30 | AggregationDelay model.Duration `json:"aggregation_delay,omitempty" yaml:"aggregation_delay,omitempty"` 31 | 32 | Ingest bool `json:"ingest,omitempty" yaml:"ingest,omitempty"` 33 | 34 | ManagedBy string `json:"managed_by,omitempty"` 35 | } 36 | 37 | type Recommendation struct { 38 | RuleData 39 | 40 | RecommendedAction string `json:"recommended_action,omitempty"` 41 | UsagesInRules int `json:"usages_in_rules,omitempty"` 42 | UsagesInQueries int `json:"usages_in_queries,omitempty"` 43 | UsagesInDashboards int `json:"usages_in_dashboards,omitempty"` 44 | 45 | // Used when recommended action is "add" 46 | KeptLabels []string `json:"kept_labels,omitempty"` 47 | 48 | RawSeriesCount int `json:"raw_series_count,omitempty"` // Number of series the client is sending. 49 | CurrentSeriesCount int `json:"current_series_count,omitempty"` // Number of series stored in the database. 50 | RecommendedSeriesCount int `json:"recommended_series_count,omitempty"` // Number of series after applying the recommendation. 51 | } 52 | 53 | func ConvertVerboseToRules(recs []Recommendation) []RuleData { 54 | rules := make([]RuleData, 0, len(recs)) 55 | for _, rec := range recs { 56 | if rec.RecommendedAction == "remove" { 57 | continue 58 | } 59 | rules = append(rules, rec.RuleData) 60 | } 61 | return rules 62 | } 63 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/export.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cmp 6 | 7 | import ( 8 | "reflect" 9 | "unsafe" 10 | ) 11 | 12 | // retrieveUnexportedField uses unsafe to forcibly retrieve any field from 13 | // a struct such that the value has read-write permissions. 14 | // 15 | // The parent struct, v, must be addressable, while f must be a StructField 16 | // describing the field to retrieve. If addr is false, 17 | // then the returned value will be shallowed copied to be non-addressable. 18 | func retrieveUnexportedField(v reflect.Value, f reflect.StructField, addr bool) reflect.Value { 19 | ve := reflect.NewAt(f.Type, unsafe.Pointer(uintptr(unsafe.Pointer(v.UnsafeAddr()))+f.Offset)).Elem() 20 | if !addr { 21 | // A field is addressable if and only if the struct is addressable. 22 | // If the original parent value was not addressable, shallow copy the 23 | // value to make it non-addressable to avoid leaking an implementation 24 | // detail of how forcibly exporting a field works. 25 | if ve.Kind() == reflect.Interface && ve.IsNil() { 26 | return reflect.Zero(f.Type) 27 | } 28 | return reflect.ValueOf(ve.Interface()).Convert(f.Type) 29 | } 30 | return ve 31 | } 32 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_disable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !cmp_debug 6 | // +build !cmp_debug 7 | 8 | package diff 9 | 10 | var debug debugger 11 | 12 | type debugger struct{} 13 | 14 | func (debugger) Begin(_, _ int, f EqualFunc, _, _ *EditScript) EqualFunc { 15 | return f 16 | } 17 | func (debugger) Update() {} 18 | func (debugger) Finish() {} 19 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_enable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build cmp_debug 6 | // +build cmp_debug 7 | 8 | package diff 9 | 10 | import ( 11 | "fmt" 12 | "strings" 13 | "sync" 14 | "time" 15 | ) 16 | 17 | // The algorithm can be seen running in real-time by enabling debugging: 18 | // go test -tags=cmp_debug -v 19 | // 20 | // Example output: 21 | // === RUN TestDifference/#34 22 | // ┌───────────────────────────────┐ 23 | // │ \ · · · · · · · · · · · · · · │ 24 | // │ · # · · · · · · · · · · · · · │ 25 | // │ · \ · · · · · · · · · · · · · │ 26 | // │ · · \ · · · · · · · · · · · · │ 27 | // │ · · · X # · · · · · · · · · · │ 28 | // │ · · · # \ · · · · · · · · · · │ 29 | // │ · · · · · # # · · · · · · · · │ 30 | // │ · · · · · # \ · · · · · · · · │ 31 | // │ · · · · · · · \ · · · · · · · │ 32 | // │ · · · · · · · · \ · · · · · · │ 33 | // │ · · · · · · · · · \ · · · · · │ 34 | // │ · · · · · · · · · · \ · · # · │ 35 | // │ · · · · · · · · · · · \ # # · │ 36 | // │ · · · · · · · · · · · # # # · │ 37 | // │ · · · · · · · · · · # # # # · │ 38 | // │ · · · · · · · · · # # # # # · │ 39 | // │ · · · · · · · · · · · · · · \ │ 40 | // └───────────────────────────────┘ 41 | // [.Y..M.XY......YXYXY.|] 42 | // 43 | // The grid represents the edit-graph where the horizontal axis represents 44 | // list X and the vertical axis represents list Y. The start of the two lists 45 | // is the top-left, while the ends are the bottom-right. The '·' represents 46 | // an unexplored node in the graph. The '\' indicates that the two symbols 47 | // from list X and Y are equal. The 'X' indicates that two symbols are similar 48 | // (but not exactly equal) to each other. The '#' indicates that the two symbols 49 | // are different (and not similar). The algorithm traverses this graph trying to 50 | // make the paths starting in the top-left and the bottom-right connect. 51 | // 52 | // The series of '.', 'X', 'Y', and 'M' characters at the bottom represents 53 | // the currently established path from the forward and reverse searches, 54 | // separated by a '|' character. 55 | 56 | const ( 57 | updateDelay = 100 * time.Millisecond 58 | finishDelay = 500 * time.Millisecond 59 | ansiTerminal = true // ANSI escape codes used to move terminal cursor 60 | ) 61 | 62 | var debug debugger 63 | 64 | type debugger struct { 65 | sync.Mutex 66 | p1, p2 EditScript 67 | fwdPath, revPath *EditScript 68 | grid []byte 69 | lines int 70 | } 71 | 72 | func (dbg *debugger) Begin(nx, ny int, f EqualFunc, p1, p2 *EditScript) EqualFunc { 73 | dbg.Lock() 74 | dbg.fwdPath, dbg.revPath = p1, p2 75 | top := "┌─" + strings.Repeat("──", nx) + "┐\n" 76 | row := "│ " + strings.Repeat("· ", nx) + "│\n" 77 | btm := "└─" + strings.Repeat("──", nx) + "┘\n" 78 | dbg.grid = []byte(top + strings.Repeat(row, ny) + btm) 79 | dbg.lines = strings.Count(dbg.String(), "\n") 80 | fmt.Print(dbg) 81 | 82 | // Wrap the EqualFunc so that we can intercept each result. 83 | return func(ix, iy int) (r Result) { 84 | cell := dbg.grid[len(top)+iy*len(row):][len("│ ")+len("· ")*ix:][:len("·")] 85 | for i := range cell { 86 | cell[i] = 0 // Zero out the multiple bytes of UTF-8 middle-dot 87 | } 88 | switch r = f(ix, iy); { 89 | case r.Equal(): 90 | cell[0] = '\\' 91 | case r.Similar(): 92 | cell[0] = 'X' 93 | default: 94 | cell[0] = '#' 95 | } 96 | return 97 | } 98 | } 99 | 100 | func (dbg *debugger) Update() { 101 | dbg.print(updateDelay) 102 | } 103 | 104 | func (dbg *debugger) Finish() { 105 | dbg.print(finishDelay) 106 | dbg.Unlock() 107 | } 108 | 109 | func (dbg *debugger) String() string { 110 | dbg.p1, dbg.p2 = *dbg.fwdPath, dbg.p2[:0] 111 | for i := len(*dbg.revPath) - 1; i >= 0; i-- { 112 | dbg.p2 = append(dbg.p2, (*dbg.revPath)[i]) 113 | } 114 | return fmt.Sprintf("%s[%v|%v]\n\n", dbg.grid, dbg.p1, dbg.p2) 115 | } 116 | 117 | func (dbg *debugger) print(d time.Duration) { 118 | if ansiTerminal { 119 | fmt.Printf("\x1b[%dA", dbg.lines) // Reset terminal cursor 120 | } 121 | fmt.Print(dbg) 122 | time.Sleep(d) 123 | } 124 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/flags/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package flags 6 | 7 | // Deterministic controls whether the output of Diff should be deterministic. 8 | // This is only used for testing. 9 | var Deterministic bool 10 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/function/func.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package function provides functionality for identifying function types. 6 | package function 7 | 8 | import ( 9 | "reflect" 10 | "regexp" 11 | "runtime" 12 | "strings" 13 | ) 14 | 15 | type funcType int 16 | 17 | const ( 18 | _ funcType = iota 19 | 20 | tbFunc // func(T) bool 21 | ttbFunc // func(T, T) bool 22 | trbFunc // func(T, R) bool 23 | tibFunc // func(T, I) bool 24 | trFunc // func(T) R 25 | 26 | Equal = ttbFunc // func(T, T) bool 27 | EqualAssignable = tibFunc // func(T, I) bool; encapsulates func(T, T) bool 28 | Transformer = trFunc // func(T) R 29 | ValueFilter = ttbFunc // func(T, T) bool 30 | Less = ttbFunc // func(T, T) bool 31 | ValuePredicate = tbFunc // func(T) bool 32 | KeyValuePredicate = trbFunc // func(T, R) bool 33 | ) 34 | 35 | var boolType = reflect.TypeOf(true) 36 | 37 | // IsType reports whether the reflect.Type is of the specified function type. 38 | func IsType(t reflect.Type, ft funcType) bool { 39 | if t == nil || t.Kind() != reflect.Func || t.IsVariadic() { 40 | return false 41 | } 42 | ni, no := t.NumIn(), t.NumOut() 43 | switch ft { 44 | case tbFunc: // func(T) bool 45 | if ni == 1 && no == 1 && t.Out(0) == boolType { 46 | return true 47 | } 48 | case ttbFunc: // func(T, T) bool 49 | if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType { 50 | return true 51 | } 52 | case trbFunc: // func(T, R) bool 53 | if ni == 2 && no == 1 && t.Out(0) == boolType { 54 | return true 55 | } 56 | case tibFunc: // func(T, I) bool 57 | if ni == 2 && no == 1 && t.In(0).AssignableTo(t.In(1)) && t.Out(0) == boolType { 58 | return true 59 | } 60 | case trFunc: // func(T) R 61 | if ni == 1 && no == 1 { 62 | return true 63 | } 64 | } 65 | return false 66 | } 67 | 68 | var lastIdentRx = regexp.MustCompile(`[_\p{L}][_\p{L}\p{N}]*$`) 69 | 70 | // NameOf returns the name of the function value. 71 | func NameOf(v reflect.Value) string { 72 | fnc := runtime.FuncForPC(v.Pointer()) 73 | if fnc == nil { 74 | return "" 75 | } 76 | fullName := fnc.Name() // e.g., "long/path/name/mypkg.(*MyType).(long/path/name/mypkg.myMethod)-fm" 77 | 78 | // Method closures have a "-fm" suffix. 79 | fullName = strings.TrimSuffix(fullName, "-fm") 80 | 81 | var name string 82 | for len(fullName) > 0 { 83 | inParen := strings.HasSuffix(fullName, ")") 84 | fullName = strings.TrimSuffix(fullName, ")") 85 | 86 | s := lastIdentRx.FindString(fullName) 87 | if s == "" { 88 | break 89 | } 90 | name = s + "." + name 91 | fullName = strings.TrimSuffix(fullName, s) 92 | 93 | if i := strings.LastIndexByte(fullName, '('); inParen && i >= 0 { 94 | fullName = fullName[:i] 95 | } 96 | fullName = strings.TrimSuffix(fullName, ".") 97 | } 98 | return strings.TrimSuffix(name, ".") 99 | } 100 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/value/name.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package value 6 | 7 | import ( 8 | "reflect" 9 | "strconv" 10 | ) 11 | 12 | var anyType = reflect.TypeOf((*interface{})(nil)).Elem() 13 | 14 | // TypeString is nearly identical to reflect.Type.String, 15 | // but has an additional option to specify that full type names be used. 16 | func TypeString(t reflect.Type, qualified bool) string { 17 | return string(appendTypeName(nil, t, qualified, false)) 18 | } 19 | 20 | func appendTypeName(b []byte, t reflect.Type, qualified, elideFunc bool) []byte { 21 | // BUG: Go reflection provides no way to disambiguate two named types 22 | // of the same name and within the same package, 23 | // but declared within the namespace of different functions. 24 | 25 | // Use the "any" alias instead of "interface{}" for better readability. 26 | if t == anyType { 27 | return append(b, "any"...) 28 | } 29 | 30 | // Named type. 31 | if t.Name() != "" { 32 | if qualified && t.PkgPath() != "" { 33 | b = append(b, '"') 34 | b = append(b, t.PkgPath()...) 35 | b = append(b, '"') 36 | b = append(b, '.') 37 | b = append(b, t.Name()...) 38 | } else { 39 | b = append(b, t.String()...) 40 | } 41 | return b 42 | } 43 | 44 | // Unnamed type. 45 | switch k := t.Kind(); k { 46 | case reflect.Bool, reflect.String, reflect.UnsafePointer, 47 | reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, 48 | reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, 49 | reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: 50 | b = append(b, k.String()...) 51 | case reflect.Chan: 52 | if t.ChanDir() == reflect.RecvDir { 53 | b = append(b, "<-"...) 54 | } 55 | b = append(b, "chan"...) 56 | if t.ChanDir() == reflect.SendDir { 57 | b = append(b, "<-"...) 58 | } 59 | b = append(b, ' ') 60 | b = appendTypeName(b, t.Elem(), qualified, false) 61 | case reflect.Func: 62 | if !elideFunc { 63 | b = append(b, "func"...) 64 | } 65 | b = append(b, '(') 66 | for i := 0; i < t.NumIn(); i++ { 67 | if i > 0 { 68 | b = append(b, ", "...) 69 | } 70 | if i == t.NumIn()-1 && t.IsVariadic() { 71 | b = append(b, "..."...) 72 | b = appendTypeName(b, t.In(i).Elem(), qualified, false) 73 | } else { 74 | b = appendTypeName(b, t.In(i), qualified, false) 75 | } 76 | } 77 | b = append(b, ')') 78 | switch t.NumOut() { 79 | case 0: 80 | // Do nothing 81 | case 1: 82 | b = append(b, ' ') 83 | b = appendTypeName(b, t.Out(0), qualified, false) 84 | default: 85 | b = append(b, " ("...) 86 | for i := 0; i < t.NumOut(); i++ { 87 | if i > 0 { 88 | b = append(b, ", "...) 89 | } 90 | b = appendTypeName(b, t.Out(i), qualified, false) 91 | } 92 | b = append(b, ')') 93 | } 94 | case reflect.Struct: 95 | b = append(b, "struct{ "...) 96 | for i := 0; i < t.NumField(); i++ { 97 | if i > 0 { 98 | b = append(b, "; "...) 99 | } 100 | sf := t.Field(i) 101 | if !sf.Anonymous { 102 | if qualified && sf.PkgPath != "" { 103 | b = append(b, '"') 104 | b = append(b, sf.PkgPath...) 105 | b = append(b, '"') 106 | b = append(b, '.') 107 | } 108 | b = append(b, sf.Name...) 109 | b = append(b, ' ') 110 | } 111 | b = appendTypeName(b, sf.Type, qualified, false) 112 | if sf.Tag != "" { 113 | b = append(b, ' ') 114 | b = strconv.AppendQuote(b, string(sf.Tag)) 115 | } 116 | } 117 | if b[len(b)-1] == ' ' { 118 | b = b[:len(b)-1] 119 | } else { 120 | b = append(b, ' ') 121 | } 122 | b = append(b, '}') 123 | case reflect.Slice, reflect.Array: 124 | b = append(b, '[') 125 | if k == reflect.Array { 126 | b = strconv.AppendUint(b, uint64(t.Len()), 10) 127 | } 128 | b = append(b, ']') 129 | b = appendTypeName(b, t.Elem(), qualified, false) 130 | case reflect.Map: 131 | b = append(b, "map["...) 132 | b = appendTypeName(b, t.Key(), qualified, false) 133 | b = append(b, ']') 134 | b = appendTypeName(b, t.Elem(), qualified, false) 135 | case reflect.Ptr: 136 | b = append(b, '*') 137 | b = appendTypeName(b, t.Elem(), qualified, false) 138 | case reflect.Interface: 139 | b = append(b, "interface{ "...) 140 | for i := 0; i < t.NumMethod(); i++ { 141 | if i > 0 { 142 | b = append(b, "; "...) 143 | } 144 | m := t.Method(i) 145 | if qualified && m.PkgPath != "" { 146 | b = append(b, '"') 147 | b = append(b, m.PkgPath...) 148 | b = append(b, '"') 149 | b = append(b, '.') 150 | } 151 | b = append(b, m.Name...) 152 | b = appendTypeName(b, m.Type, qualified, true) 153 | } 154 | if b[len(b)-1] == ' ' { 155 | b = b[:len(b)-1] 156 | } else { 157 | b = append(b, ' ') 158 | } 159 | b = append(b, '}') 160 | default: 161 | panic("invalid kind: " + k.String()) 162 | } 163 | return b 164 | } 165 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/value/pointer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package value 6 | 7 | import ( 8 | "reflect" 9 | "unsafe" 10 | ) 11 | 12 | // Pointer is an opaque typed pointer and is guaranteed to be comparable. 13 | type Pointer struct { 14 | p unsafe.Pointer 15 | t reflect.Type 16 | } 17 | 18 | // PointerOf returns a Pointer from v, which must be a 19 | // reflect.Ptr, reflect.Slice, or reflect.Map. 20 | func PointerOf(v reflect.Value) Pointer { 21 | // The proper representation of a pointer is unsafe.Pointer, 22 | // which is necessary if the GC ever uses a moving collector. 23 | return Pointer{unsafe.Pointer(v.Pointer()), v.Type()} 24 | } 25 | 26 | // IsNil reports whether the pointer is nil. 27 | func (p Pointer) IsNil() bool { 28 | return p.p == nil 29 | } 30 | 31 | // Uintptr returns the pointer as a uintptr. 32 | func (p Pointer) Uintptr() uintptr { 33 | return uintptr(p.p) 34 | } 35 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package value 6 | 7 | import ( 8 | "fmt" 9 | "math" 10 | "reflect" 11 | "sort" 12 | ) 13 | 14 | // SortKeys sorts a list of map keys, deduplicating keys if necessary. 15 | // The type of each value must be comparable. 16 | func SortKeys(vs []reflect.Value) []reflect.Value { 17 | if len(vs) == 0 { 18 | return vs 19 | } 20 | 21 | // Sort the map keys. 22 | sort.SliceStable(vs, func(i, j int) bool { return isLess(vs[i], vs[j]) }) 23 | 24 | // Deduplicate keys (fails for NaNs). 25 | vs2 := vs[:1] 26 | for _, v := range vs[1:] { 27 | if isLess(vs2[len(vs2)-1], v) { 28 | vs2 = append(vs2, v) 29 | } 30 | } 31 | return vs2 32 | } 33 | 34 | // isLess is a generic function for sorting arbitrary map keys. 35 | // The inputs must be of the same type and must be comparable. 36 | func isLess(x, y reflect.Value) bool { 37 | switch x.Type().Kind() { 38 | case reflect.Bool: 39 | return !x.Bool() && y.Bool() 40 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 41 | return x.Int() < y.Int() 42 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 43 | return x.Uint() < y.Uint() 44 | case reflect.Float32, reflect.Float64: 45 | // NOTE: This does not sort -0 as less than +0 46 | // since Go maps treat -0 and +0 as equal keys. 47 | fx, fy := x.Float(), y.Float() 48 | return fx < fy || math.IsNaN(fx) && !math.IsNaN(fy) 49 | case reflect.Complex64, reflect.Complex128: 50 | cx, cy := x.Complex(), y.Complex() 51 | rx, ix, ry, iy := real(cx), imag(cx), real(cy), imag(cy) 52 | if rx == ry || (math.IsNaN(rx) && math.IsNaN(ry)) { 53 | return ix < iy || math.IsNaN(ix) && !math.IsNaN(iy) 54 | } 55 | return rx < ry || math.IsNaN(rx) && !math.IsNaN(ry) 56 | case reflect.Ptr, reflect.UnsafePointer, reflect.Chan: 57 | return x.Pointer() < y.Pointer() 58 | case reflect.String: 59 | return x.String() < y.String() 60 | case reflect.Array: 61 | for i := 0; i < x.Len(); i++ { 62 | if isLess(x.Index(i), y.Index(i)) { 63 | return true 64 | } 65 | if isLess(y.Index(i), x.Index(i)) { 66 | return false 67 | } 68 | } 69 | return false 70 | case reflect.Struct: 71 | for i := 0; i < x.NumField(); i++ { 72 | if isLess(x.Field(i), y.Field(i)) { 73 | return true 74 | } 75 | if isLess(y.Field(i), x.Field(i)) { 76 | return false 77 | } 78 | } 79 | return false 80 | case reflect.Interface: 81 | vx, vy := x.Elem(), y.Elem() 82 | if !vx.IsValid() || !vy.IsValid() { 83 | return !vx.IsValid() && vy.IsValid() 84 | } 85 | tx, ty := vx.Type(), vy.Type() 86 | if tx == ty { 87 | return isLess(x.Elem(), y.Elem()) 88 | } 89 | if tx.Kind() != ty.Kind() { 90 | return vx.Kind() < vy.Kind() 91 | } 92 | if tx.String() != ty.String() { 93 | return tx.String() < ty.String() 94 | } 95 | if tx.PkgPath() != ty.PkgPath() { 96 | return tx.PkgPath() < ty.PkgPath() 97 | } 98 | // This can happen in rare situations, so we fallback to just comparing 99 | // the unique pointer for a reflect.Type. This guarantees deterministic 100 | // ordering within a program, but it is obviously not stable. 101 | return reflect.ValueOf(vx.Type()).Pointer() < reflect.ValueOf(vy.Type()).Pointer() 102 | default: 103 | // Must be Func, Map, or Slice; which are not comparable. 104 | panic(fmt.Sprintf("%T is not comparable", x.Type())) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/report.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cmp 6 | 7 | // defaultReporter implements the reporter interface. 8 | // 9 | // As Equal serially calls the PushStep, Report, and PopStep methods, the 10 | // defaultReporter constructs a tree-based representation of the compared value 11 | // and the result of each comparison (see valueNode). 12 | // 13 | // When the String method is called, the FormatDiff method transforms the 14 | // valueNode tree into a textNode tree, which is a tree-based representation 15 | // of the textual output (see textNode). 16 | // 17 | // Lastly, the textNode.String method produces the final report as a string. 18 | type defaultReporter struct { 19 | root *valueNode 20 | curr *valueNode 21 | } 22 | 23 | func (r *defaultReporter) PushStep(ps PathStep) { 24 | r.curr = r.curr.PushStep(ps) 25 | if r.root == nil { 26 | r.root = r.curr 27 | } 28 | } 29 | func (r *defaultReporter) Report(rs Result) { 30 | r.curr.Report(rs) 31 | } 32 | func (r *defaultReporter) PopStep() { 33 | r.curr = r.curr.PopStep() 34 | } 35 | 36 | // String provides a full report of the differences detected as a structured 37 | // literal in pseudo-Go syntax. String may only be called after the entire tree 38 | // has been traversed. 39 | func (r *defaultReporter) String() string { 40 | assert(r.root != nil && r.curr == nil) 41 | if r.root.NumDiff == 0 { 42 | return "" 43 | } 44 | ptrs := new(pointerReferences) 45 | text := formatOptions{}.FormatDiff(r.root, ptrs) 46 | resolveReferences(text) 47 | return text.String() 48 | } 49 | 50 | func assert(ok bool) { 51 | if !ok { 52 | panic("assertion failure") 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /docker/vendor/github.com/google/go-cmp/cmp/report_value.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019, The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cmp 6 | 7 | import "reflect" 8 | 9 | // valueNode represents a single node within a report, which is a 10 | // structured representation of the value tree, containing information 11 | // regarding which nodes are equal or not. 12 | type valueNode struct { 13 | parent *valueNode 14 | 15 | Type reflect.Type 16 | ValueX reflect.Value 17 | ValueY reflect.Value 18 | 19 | // NumSame is the number of leaf nodes that are equal. 20 | // All descendants are equal only if NumDiff is 0. 21 | NumSame int 22 | // NumDiff is the number of leaf nodes that are not equal. 23 | NumDiff int 24 | // NumIgnored is the number of leaf nodes that are ignored. 25 | NumIgnored int 26 | // NumCompared is the number of leaf nodes that were compared 27 | // using an Equal method or Comparer function. 28 | NumCompared int 29 | // NumTransformed is the number of non-leaf nodes that were transformed. 30 | NumTransformed int 31 | // NumChildren is the number of transitive descendants of this node. 32 | // This counts from zero; thus, leaf nodes have no descendants. 33 | NumChildren int 34 | // MaxDepth is the maximum depth of the tree. This counts from zero; 35 | // thus, leaf nodes have a depth of zero. 36 | MaxDepth int 37 | 38 | // Records is a list of struct fields, slice elements, or map entries. 39 | Records []reportRecord // If populated, implies Value is not populated 40 | 41 | // Value is the result of a transformation, pointer indirect, of 42 | // type assertion. 43 | Value *valueNode // If populated, implies Records is not populated 44 | 45 | // TransformerName is the name of the transformer. 46 | TransformerName string // If non-empty, implies Value is populated 47 | } 48 | type reportRecord struct { 49 | Key reflect.Value // Invalid for slice element 50 | Value *valueNode 51 | } 52 | 53 | func (parent *valueNode) PushStep(ps PathStep) (child *valueNode) { 54 | vx, vy := ps.Values() 55 | child = &valueNode{parent: parent, Type: ps.Type(), ValueX: vx, ValueY: vy} 56 | switch s := ps.(type) { 57 | case StructField: 58 | assert(parent.Value == nil) 59 | parent.Records = append(parent.Records, reportRecord{Key: reflect.ValueOf(s.Name()), Value: child}) 60 | case SliceIndex: 61 | assert(parent.Value == nil) 62 | parent.Records = append(parent.Records, reportRecord{Value: child}) 63 | case MapIndex: 64 | assert(parent.Value == nil) 65 | parent.Records = append(parent.Records, reportRecord{Key: s.Key(), Value: child}) 66 | case Indirect: 67 | assert(parent.Value == nil && parent.Records == nil) 68 | parent.Value = child 69 | case TypeAssertion: 70 | assert(parent.Value == nil && parent.Records == nil) 71 | parent.Value = child 72 | case Transform: 73 | assert(parent.Value == nil && parent.Records == nil) 74 | parent.Value = child 75 | parent.TransformerName = s.Name() 76 | parent.NumTransformed++ 77 | default: 78 | assert(parent == nil) // Must be the root step 79 | } 80 | return child 81 | } 82 | 83 | func (r *valueNode) Report(rs Result) { 84 | assert(r.MaxDepth == 0) // May only be called on leaf nodes 85 | 86 | if rs.ByIgnore() { 87 | r.NumIgnored++ 88 | } else { 89 | if rs.Equal() { 90 | r.NumSame++ 91 | } else { 92 | r.NumDiff++ 93 | } 94 | } 95 | assert(r.NumSame+r.NumDiff+r.NumIgnored == 1) 96 | 97 | if rs.ByMethod() { 98 | r.NumCompared++ 99 | } 100 | if rs.ByFunc() { 101 | r.NumCompared++ 102 | } 103 | assert(r.NumCompared <= 1) 104 | } 105 | 106 | func (child *valueNode) PopStep() (parent *valueNode) { 107 | if child.parent == nil { 108 | return nil 109 | } 110 | parent = child.parent 111 | parent.NumSame += child.NumSame 112 | parent.NumDiff += child.NumDiff 113 | parent.NumIgnored += child.NumIgnored 114 | parent.NumCompared += child.NumCompared 115 | parent.NumTransformed += child.NumTransformed 116 | parent.NumChildren += child.NumChildren + 1 117 | if parent.MaxDepth < child.MaxDepth+1 { 118 | parent.MaxDepth = child.MaxDepth + 1 119 | } 120 | return parent 121 | } 122 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/fingerprinting.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "fmt" 18 | "strconv" 19 | ) 20 | 21 | // Fingerprint provides a hash-capable representation of a Metric. 22 | // For our purposes, FNV-1A 64-bit is used. 23 | type Fingerprint uint64 24 | 25 | // FingerprintFromString transforms a string representation into a Fingerprint. 26 | func FingerprintFromString(s string) (Fingerprint, error) { 27 | num, err := strconv.ParseUint(s, 16, 64) 28 | return Fingerprint(num), err 29 | } 30 | 31 | // ParseFingerprint parses the input string into a fingerprint. 32 | func ParseFingerprint(s string) (Fingerprint, error) { 33 | num, err := strconv.ParseUint(s, 16, 64) 34 | if err != nil { 35 | return 0, err 36 | } 37 | return Fingerprint(num), nil 38 | } 39 | 40 | func (f Fingerprint) String() string { 41 | return fmt.Sprintf("%016x", uint64(f)) 42 | } 43 | 44 | // Fingerprints represents a collection of Fingerprint subject to a given 45 | // natural sorting scheme. It implements sort.Interface. 46 | type Fingerprints []Fingerprint 47 | 48 | // Len implements sort.Interface. 49 | func (f Fingerprints) Len() int { 50 | return len(f) 51 | } 52 | 53 | // Less implements sort.Interface. 54 | func (f Fingerprints) Less(i, j int) bool { 55 | return f[i] < f[j] 56 | } 57 | 58 | // Swap implements sort.Interface. 59 | func (f Fingerprints) Swap(i, j int) { 60 | f[i], f[j] = f[j], f[i] 61 | } 62 | 63 | // FingerprintSet is a set of Fingerprints. 64 | type FingerprintSet map[Fingerprint]struct{} 65 | 66 | // Equal returns true if both sets contain the same elements (and not more). 67 | func (s FingerprintSet) Equal(o FingerprintSet) bool { 68 | if len(s) != len(o) { 69 | return false 70 | } 71 | 72 | for k := range s { 73 | if _, ok := o[k]; !ok { 74 | return false 75 | } 76 | } 77 | 78 | return true 79 | } 80 | 81 | // Intersection returns the elements contained in both sets. 82 | func (s FingerprintSet) Intersection(o FingerprintSet) FingerprintSet { 83 | myLength, otherLength := len(s), len(o) 84 | if myLength == 0 || otherLength == 0 { 85 | return FingerprintSet{} 86 | } 87 | 88 | subSet := s 89 | superSet := o 90 | 91 | if otherLength < myLength { 92 | subSet = o 93 | superSet = s 94 | } 95 | 96 | out := FingerprintSet{} 97 | 98 | for k := range subSet { 99 | if _, ok := superSet[k]; ok { 100 | out[k] = struct{}{} 101 | } 102 | } 103 | 104 | return out 105 | } 106 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | // Inline and byte-free variant of hash/fnv's fnv64a. 17 | 18 | const ( 19 | offset64 = 14695981039346656037 20 | prime64 = 1099511628211 21 | ) 22 | 23 | // hashNew initializes a new fnv64a hash value. 24 | func hashNew() uint64 { 25 | return offset64 26 | } 27 | 28 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 29 | func hashAdd(h uint64, s string) uint64 { 30 | for i := 0; i < len(s); i++ { 31 | h ^= uint64(s[i]) 32 | h *= prime64 33 | } 34 | return h 35 | } 36 | 37 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 38 | func hashAddByte(h uint64, b byte) uint64 { 39 | h ^= uint64(b) 40 | h *= prime64 41 | return h 42 | } 43 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/labelset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "encoding/json" 18 | "fmt" 19 | "sort" 20 | ) 21 | 22 | // A LabelSet is a collection of LabelName and LabelValue pairs. The LabelSet 23 | // may be fully-qualified down to the point where it may resolve to a single 24 | // Metric in the data store or not. All operations that occur within the realm 25 | // of a LabelSet can emit a vector of Metric entities to which the LabelSet may 26 | // match. 27 | type LabelSet map[LabelName]LabelValue 28 | 29 | // Validate checks whether all names and values in the label set 30 | // are valid. 31 | func (ls LabelSet) Validate() error { 32 | for ln, lv := range ls { 33 | if !ln.IsValid() { 34 | return fmt.Errorf("invalid name %q", ln) 35 | } 36 | if !lv.IsValid() { 37 | return fmt.Errorf("invalid value %q", lv) 38 | } 39 | } 40 | return nil 41 | } 42 | 43 | // Equal returns true iff both label sets have exactly the same key/value pairs. 44 | func (ls LabelSet) Equal(o LabelSet) bool { 45 | if len(ls) != len(o) { 46 | return false 47 | } 48 | for ln, lv := range ls { 49 | olv, ok := o[ln] 50 | if !ok { 51 | return false 52 | } 53 | if olv != lv { 54 | return false 55 | } 56 | } 57 | return true 58 | } 59 | 60 | // Before compares the metrics, using the following criteria: 61 | // 62 | // If m has fewer labels than o, it is before o. If it has more, it is not. 63 | // 64 | // If the number of labels is the same, the superset of all label names is 65 | // sorted alphanumerically. The first differing label pair found in that order 66 | // determines the outcome: If the label does not exist at all in m, then m is 67 | // before o, and vice versa. Otherwise the label value is compared 68 | // alphanumerically. 69 | // 70 | // If m and o are equal, the method returns false. 71 | func (ls LabelSet) Before(o LabelSet) bool { 72 | if len(ls) < len(o) { 73 | return true 74 | } 75 | if len(ls) > len(o) { 76 | return false 77 | } 78 | 79 | lns := make(LabelNames, 0, len(ls)+len(o)) 80 | for ln := range ls { 81 | lns = append(lns, ln) 82 | } 83 | for ln := range o { 84 | lns = append(lns, ln) 85 | } 86 | // It's probably not worth it to de-dup lns. 87 | sort.Sort(lns) 88 | for _, ln := range lns { 89 | mlv, ok := ls[ln] 90 | if !ok { 91 | return true 92 | } 93 | olv, ok := o[ln] 94 | if !ok { 95 | return false 96 | } 97 | if mlv < olv { 98 | return true 99 | } 100 | if mlv > olv { 101 | return false 102 | } 103 | } 104 | return false 105 | } 106 | 107 | // Clone returns a copy of the label set. 108 | func (ls LabelSet) Clone() LabelSet { 109 | lsn := make(LabelSet, len(ls)) 110 | for ln, lv := range ls { 111 | lsn[ln] = lv 112 | } 113 | return lsn 114 | } 115 | 116 | // Merge is a helper function to non-destructively merge two label sets. 117 | func (l LabelSet) Merge(other LabelSet) LabelSet { 118 | result := make(LabelSet, len(l)) 119 | 120 | for k, v := range l { 121 | result[k] = v 122 | } 123 | 124 | for k, v := range other { 125 | result[k] = v 126 | } 127 | 128 | return result 129 | } 130 | 131 | // Fingerprint returns the LabelSet's fingerprint. 132 | func (ls LabelSet) Fingerprint() Fingerprint { 133 | return labelSetToFingerprint(ls) 134 | } 135 | 136 | // FastFingerprint returns the LabelSet's Fingerprint calculated by a faster hashing 137 | // algorithm, which is, however, more susceptible to hash collisions. 138 | func (ls LabelSet) FastFingerprint() Fingerprint { 139 | return labelSetToFastFingerprint(ls) 140 | } 141 | 142 | // UnmarshalJSON implements the json.Unmarshaler interface. 143 | func (l *LabelSet) UnmarshalJSON(b []byte) error { 144 | var m map[LabelName]LabelValue 145 | if err := json.Unmarshal(b, &m); err != nil { 146 | return err 147 | } 148 | // encoding/json only unmarshals maps of the form map[string]T. It treats 149 | // LabelName as a string and does not call its UnmarshalJSON method. 150 | // Thus, we have to replicate the behavior here. 151 | for ln := range m { 152 | if !ln.IsValid() { 153 | return fmt.Errorf("%q is not a valid label name", ln) 154 | } 155 | } 156 | *l = LabelSet(m) 157 | return nil 158 | } 159 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/labelset_string.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build go1.21 15 | 16 | package model 17 | 18 | import ( 19 | "bytes" 20 | "slices" 21 | "strconv" 22 | ) 23 | 24 | // String will look like `{foo="bar", more="less"}`. Names are sorted alphabetically. 25 | func (l LabelSet) String() string { 26 | var lna [32]string // On stack to avoid memory allocation for sorting names. 27 | labelNames := lna[:0] 28 | for name := range l { 29 | labelNames = append(labelNames, string(name)) 30 | } 31 | slices.Sort(labelNames) 32 | var bytea [1024]byte // On stack to avoid memory allocation while building the output. 33 | b := bytes.NewBuffer(bytea[:0]) 34 | b.WriteByte('{') 35 | for i, name := range labelNames { 36 | if i > 0 { 37 | b.WriteString(", ") 38 | } 39 | b.WriteString(name) 40 | b.WriteByte('=') 41 | b.Write(strconv.AppendQuote(b.AvailableBuffer(), string(l[LabelName(name)]))) 42 | } 43 | b.WriteByte('}') 44 | return b.String() 45 | } 46 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/labelset_string_go120.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !go1.21 15 | 16 | package model 17 | 18 | import ( 19 | "fmt" 20 | "sort" 21 | "strings" 22 | ) 23 | 24 | // String was optimized using functions not available for go 1.20 25 | // or lower. We keep the old implementation for compatibility with client_golang. 26 | // Once client golang drops support for go 1.20 (scheduled for August 2024), this 27 | // file can be removed. 28 | func (l LabelSet) String() string { 29 | labelNames := make([]string, 0, len(l)) 30 | for name := range l { 31 | labelNames = append(labelNames, string(name)) 32 | } 33 | sort.Strings(labelNames) 34 | lstrs := make([]string, 0, len(l)) 35 | for _, name := range labelNames { 36 | lstrs = append(lstrs, fmt.Sprintf("%s=%q", name, l[LabelName(name)])) 37 | } 38 | return fmt.Sprintf("{%s}", strings.Join(lstrs, ", ")) 39 | } 40 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/metadata.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | // MetricType represents metric type values. 17 | type MetricType string 18 | 19 | const ( 20 | MetricTypeCounter = MetricType("counter") 21 | MetricTypeGauge = MetricType("gauge") 22 | MetricTypeHistogram = MetricType("histogram") 23 | MetricTypeGaugeHistogram = MetricType("gaugehistogram") 24 | MetricTypeSummary = MetricType("summary") 25 | MetricTypeInfo = MetricType("info") 26 | MetricTypeStateset = MetricType("stateset") 27 | MetricTypeUnknown = MetricType("unknown") 28 | ) 29 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/model.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package model contains common data structures that are shared across 15 | // Prometheus components and libraries. 16 | package model 17 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/signature.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "sort" 18 | ) 19 | 20 | // SeparatorByte is a byte that cannot occur in valid UTF-8 sequences and is 21 | // used to separate label names, label values, and other strings from each other 22 | // when calculating their combined hash value (aka signature aka fingerprint). 23 | const SeparatorByte byte = 255 24 | 25 | // cache the signature of an empty label set. 26 | var emptyLabelSignature = hashNew() 27 | 28 | // LabelsToSignature returns a quasi-unique signature (i.e., fingerprint) for a 29 | // given label set. (Collisions are possible but unlikely if the number of label 30 | // sets the function is applied to is small.) 31 | func LabelsToSignature(labels map[string]string) uint64 { 32 | if len(labels) == 0 { 33 | return emptyLabelSignature 34 | } 35 | 36 | labelNames := make([]string, 0, len(labels)) 37 | for labelName := range labels { 38 | labelNames = append(labelNames, labelName) 39 | } 40 | sort.Strings(labelNames) 41 | 42 | sum := hashNew() 43 | for _, labelName := range labelNames { 44 | sum = hashAdd(sum, labelName) 45 | sum = hashAddByte(sum, SeparatorByte) 46 | sum = hashAdd(sum, labels[labelName]) 47 | sum = hashAddByte(sum, SeparatorByte) 48 | } 49 | return sum 50 | } 51 | 52 | // labelSetToFingerprint works exactly as LabelsToSignature but takes a LabelSet as 53 | // parameter (rather than a label map) and returns a Fingerprint. 54 | func labelSetToFingerprint(ls LabelSet) Fingerprint { 55 | if len(ls) == 0 { 56 | return Fingerprint(emptyLabelSignature) 57 | } 58 | 59 | labelNames := make(LabelNames, 0, len(ls)) 60 | for labelName := range ls { 61 | labelNames = append(labelNames, labelName) 62 | } 63 | sort.Sort(labelNames) 64 | 65 | sum := hashNew() 66 | for _, labelName := range labelNames { 67 | sum = hashAdd(sum, string(labelName)) 68 | sum = hashAddByte(sum, SeparatorByte) 69 | sum = hashAdd(sum, string(ls[labelName])) 70 | sum = hashAddByte(sum, SeparatorByte) 71 | } 72 | return Fingerprint(sum) 73 | } 74 | 75 | // labelSetToFastFingerprint works similar to labelSetToFingerprint but uses a 76 | // faster and less allocation-heavy hash function, which is more susceptible to 77 | // create hash collisions. Therefore, collision detection should be applied. 78 | func labelSetToFastFingerprint(ls LabelSet) Fingerprint { 79 | if len(ls) == 0 { 80 | return Fingerprint(emptyLabelSignature) 81 | } 82 | 83 | var result uint64 84 | for labelName, labelValue := range ls { 85 | sum := hashNew() 86 | sum = hashAdd(sum, string(labelName)) 87 | sum = hashAddByte(sum, SeparatorByte) 88 | sum = hashAdd(sum, string(labelValue)) 89 | result ^= sum 90 | } 91 | return Fingerprint(result) 92 | } 93 | 94 | // SignatureForLabels works like LabelsToSignature but takes a Metric as 95 | // parameter (rather than a label map) and only includes the labels with the 96 | // specified LabelNames into the signature calculation. The labels passed in 97 | // will be sorted by this function. 98 | func SignatureForLabels(m Metric, labels ...LabelName) uint64 { 99 | if len(labels) == 0 { 100 | return emptyLabelSignature 101 | } 102 | 103 | sort.Sort(LabelNames(labels)) 104 | 105 | sum := hashNew() 106 | for _, label := range labels { 107 | sum = hashAdd(sum, string(label)) 108 | sum = hashAddByte(sum, SeparatorByte) 109 | sum = hashAdd(sum, string(m[label])) 110 | sum = hashAddByte(sum, SeparatorByte) 111 | } 112 | return sum 113 | } 114 | 115 | // SignatureWithoutLabels works like LabelsToSignature but takes a Metric as 116 | // parameter (rather than a label map) and excludes the labels with any of the 117 | // specified LabelNames from the signature calculation. 118 | func SignatureWithoutLabels(m Metric, labels map[LabelName]struct{}) uint64 { 119 | if len(m) == 0 { 120 | return emptyLabelSignature 121 | } 122 | 123 | labelNames := make(LabelNames, 0, len(m)) 124 | for labelName := range m { 125 | if _, exclude := labels[labelName]; !exclude { 126 | labelNames = append(labelNames, labelName) 127 | } 128 | } 129 | if len(labelNames) == 0 { 130 | return emptyLabelSignature 131 | } 132 | sort.Sort(labelNames) 133 | 134 | sum := hashNew() 135 | for _, labelName := range labelNames { 136 | sum = hashAdd(sum, string(labelName)) 137 | sum = hashAddByte(sum, SeparatorByte) 138 | sum = hashAdd(sum, string(m[labelName])) 139 | sum = hashAddByte(sum, SeparatorByte) 140 | } 141 | return sum 142 | } 143 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/silence.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "encoding/json" 18 | "fmt" 19 | "regexp" 20 | "time" 21 | ) 22 | 23 | // Matcher describes a matches the value of a given label. 24 | type Matcher struct { 25 | Name LabelName `json:"name"` 26 | Value string `json:"value"` 27 | IsRegex bool `json:"isRegex"` 28 | } 29 | 30 | func (m *Matcher) UnmarshalJSON(b []byte) error { 31 | type plain Matcher 32 | if err := json.Unmarshal(b, (*plain)(m)); err != nil { 33 | return err 34 | } 35 | 36 | if len(m.Name) == 0 { 37 | return fmt.Errorf("label name in matcher must not be empty") 38 | } 39 | if m.IsRegex { 40 | if _, err := regexp.Compile(m.Value); err != nil { 41 | return err 42 | } 43 | } 44 | return nil 45 | } 46 | 47 | // Validate returns true iff all fields of the matcher have valid values. 48 | func (m *Matcher) Validate() error { 49 | if !m.Name.IsValid() { 50 | return fmt.Errorf("invalid name %q", m.Name) 51 | } 52 | if m.IsRegex { 53 | if _, err := regexp.Compile(m.Value); err != nil { 54 | return fmt.Errorf("invalid regular expression %q", m.Value) 55 | } 56 | } else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 { 57 | return fmt.Errorf("invalid value %q", m.Value) 58 | } 59 | return nil 60 | } 61 | 62 | // Silence defines the representation of a silence definition in the Prometheus 63 | // eco-system. 64 | type Silence struct { 65 | ID uint64 `json:"id,omitempty"` 66 | 67 | Matchers []*Matcher `json:"matchers"` 68 | 69 | StartsAt time.Time `json:"startsAt"` 70 | EndsAt time.Time `json:"endsAt"` 71 | 72 | CreatedAt time.Time `json:"createdAt,omitempty"` 73 | CreatedBy string `json:"createdBy"` 74 | Comment string `json:"comment,omitempty"` 75 | } 76 | 77 | // Validate returns true iff all fields of the silence have valid values. 78 | func (s *Silence) Validate() error { 79 | if len(s.Matchers) == 0 { 80 | return fmt.Errorf("at least one matcher required") 81 | } 82 | for _, m := range s.Matchers { 83 | if err := m.Validate(); err != nil { 84 | return fmt.Errorf("invalid matcher: %w", err) 85 | } 86 | } 87 | if s.StartsAt.IsZero() { 88 | return fmt.Errorf("start time missing") 89 | } 90 | if s.EndsAt.IsZero() { 91 | return fmt.Errorf("end time missing") 92 | } 93 | if s.EndsAt.Before(s.StartsAt) { 94 | return fmt.Errorf("start time must be before end time") 95 | } 96 | if s.CreatedBy == "" { 97 | return fmt.Errorf("creator information missing") 98 | } 99 | if s.Comment == "" { 100 | return fmt.Errorf("comment missing") 101 | } 102 | if s.CreatedAt.IsZero() { 103 | return fmt.Errorf("creation timestamp missing") 104 | } 105 | return nil 106 | } 107 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/value_float.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "encoding/json" 18 | "fmt" 19 | "math" 20 | "strconv" 21 | ) 22 | 23 | // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a 24 | // non-existing sample pair. It is a SamplePair with timestamp Earliest and 25 | // value 0.0. Note that the natural zero value of SamplePair has a timestamp 26 | // of 0, which is possible to appear in a real SamplePair and thus not 27 | // suitable to signal a non-existing SamplePair. 28 | var ZeroSamplePair = SamplePair{Timestamp: Earliest} 29 | 30 | // A SampleValue is a representation of a value for a given sample at a given 31 | // time. 32 | type SampleValue float64 33 | 34 | // MarshalJSON implements json.Marshaler. 35 | func (v SampleValue) MarshalJSON() ([]byte, error) { 36 | return json.Marshal(v.String()) 37 | } 38 | 39 | // UnmarshalJSON implements json.Unmarshaler. 40 | func (v *SampleValue) UnmarshalJSON(b []byte) error { 41 | if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { 42 | return fmt.Errorf("sample value must be a quoted string") 43 | } 44 | f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) 45 | if err != nil { 46 | return err 47 | } 48 | *v = SampleValue(f) 49 | return nil 50 | } 51 | 52 | // Equal returns true if the value of v and o is equal or if both are NaN. Note 53 | // that v==o is false if both are NaN. If you want the conventional float 54 | // behavior, use == to compare two SampleValues. 55 | func (v SampleValue) Equal(o SampleValue) bool { 56 | if v == o { 57 | return true 58 | } 59 | return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) 60 | } 61 | 62 | func (v SampleValue) String() string { 63 | return strconv.FormatFloat(float64(v), 'f', -1, 64) 64 | } 65 | 66 | // SamplePair pairs a SampleValue with a Timestamp. 67 | type SamplePair struct { 68 | Timestamp Time 69 | Value SampleValue 70 | } 71 | 72 | func (s SamplePair) MarshalJSON() ([]byte, error) { 73 | t, err := json.Marshal(s.Timestamp) 74 | if err != nil { 75 | return nil, err 76 | } 77 | v, err := json.Marshal(s.Value) 78 | if err != nil { 79 | return nil, err 80 | } 81 | return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil 82 | } 83 | 84 | // UnmarshalJSON implements json.Unmarshaler. 85 | func (s *SamplePair) UnmarshalJSON(b []byte) error { 86 | v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} 87 | return json.Unmarshal(b, &v) 88 | } 89 | 90 | // Equal returns true if this SamplePair and o have equal Values and equal 91 | // Timestamps. The semantics of Value equality is defined by SampleValue.Equal. 92 | func (s *SamplePair) Equal(o *SamplePair) bool { 93 | return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) 94 | } 95 | 96 | func (s SamplePair) String() string { 97 | return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) 98 | } 99 | -------------------------------------------------------------------------------- /docker/vendor/github.com/prometheus/common/model/value_type.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | import ( 17 | "encoding/json" 18 | "fmt" 19 | ) 20 | 21 | // Value is a generic interface for values resulting from a query evaluation. 22 | type Value interface { 23 | Type() ValueType 24 | String() string 25 | } 26 | 27 | func (Matrix) Type() ValueType { return ValMatrix } 28 | func (Vector) Type() ValueType { return ValVector } 29 | func (*Scalar) Type() ValueType { return ValScalar } 30 | func (*String) Type() ValueType { return ValString } 31 | 32 | type ValueType int 33 | 34 | const ( 35 | ValNone ValueType = iota 36 | ValScalar 37 | ValVector 38 | ValMatrix 39 | ValString 40 | ) 41 | 42 | // MarshalJSON implements json.Marshaler. 43 | func (et ValueType) MarshalJSON() ([]byte, error) { 44 | return json.Marshal(et.String()) 45 | } 46 | 47 | func (et *ValueType) UnmarshalJSON(b []byte) error { 48 | var s string 49 | if err := json.Unmarshal(b, &s); err != nil { 50 | return err 51 | } 52 | switch s { 53 | case "": 54 | *et = ValNone 55 | case "scalar": 56 | *et = ValScalar 57 | case "vector": 58 | *et = ValVector 59 | case "matrix": 60 | *et = ValMatrix 61 | case "string": 62 | *et = ValString 63 | default: 64 | return fmt.Errorf("unknown value type %q", s) 65 | } 66 | return nil 67 | } 68 | 69 | func (e ValueType) String() string { 70 | switch e { 71 | case ValNone: 72 | return "" 73 | case ValScalar: 74 | return "scalar" 75 | case ValVector: 76 | return "vector" 77 | case ValMatrix: 78 | return "matrix" 79 | case ValString: 80 | return "string" 81 | } 82 | panic("ValueType.String: unhandled value type") 83 | } 84 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/encoding/prototext/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package prototext marshals and unmarshals protocol buffer messages as the 6 | // textproto format. 7 | package prototext 8 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/descopts/options.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package descopts contains the nil pointers to concrete descriptor options. 6 | // 7 | // This package exists as a form of reverse dependency injection so that certain 8 | // packages (e.g., internal/filedesc and internal/filetype can avoid a direct 9 | // dependency on the descriptor proto package). 10 | package descopts 11 | 12 | import pref "google.golang.org/protobuf/reflect/protoreflect" 13 | 14 | // These variables are set by the init function in descriptor.pb.go via logic 15 | // in internal/filetype. In other words, so long as the descriptor proto package 16 | // is linked in, these variables will be populated. 17 | // 18 | // Each variable is populated with a nil pointer to the options struct. 19 | var ( 20 | File pref.ProtoMessage 21 | Enum pref.ProtoMessage 22 | EnumValue pref.ProtoMessage 23 | Message pref.ProtoMessage 24 | Field pref.ProtoMessage 25 | Oneof pref.ProtoMessage 26 | ExtensionRange pref.ProtoMessage 27 | Service pref.ProtoMessage 28 | Method pref.ProtoMessage 29 | ) 30 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/detrand/rand.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package detrand provides deterministically random functionality. 6 | // 7 | // The pseudo-randomness of these functions is seeded by the program binary 8 | // itself and guarantees that the output does not change within a program, 9 | // while ensuring that the output is unstable across different builds. 10 | package detrand 11 | 12 | import ( 13 | "encoding/binary" 14 | "hash/fnv" 15 | "os" 16 | ) 17 | 18 | // Disable disables detrand such that all functions returns the zero value. 19 | // This function is not concurrent-safe and must be called during program init. 20 | func Disable() { 21 | randSeed = 0 22 | } 23 | 24 | // Bool returns a deterministically random boolean. 25 | func Bool() bool { 26 | return randSeed%2 == 1 27 | } 28 | 29 | // Intn returns a deterministically random integer between 0 and n-1, inclusive. 30 | func Intn(n int) int { 31 | if n <= 0 { 32 | panic("must be positive") 33 | } 34 | return int(randSeed % uint64(n)) 35 | } 36 | 37 | // randSeed is a best-effort at an approximate hash of the Go binary. 38 | var randSeed = binaryHash() 39 | 40 | func binaryHash() uint64 { 41 | // Open the Go binary. 42 | s, err := os.Executable() 43 | if err != nil { 44 | return 0 45 | } 46 | f, err := os.Open(s) 47 | if err != nil { 48 | return 0 49 | } 50 | defer f.Close() 51 | 52 | // Hash the size and several samples of the Go binary. 53 | const numSamples = 8 54 | var buf [64]byte 55 | h := fnv.New64() 56 | fi, err := f.Stat() 57 | if err != nil { 58 | return 0 59 | } 60 | binary.LittleEndian.PutUint64(buf[:8], uint64(fi.Size())) 61 | h.Write(buf[:8]) 62 | for i := int64(0); i < numSamples; i++ { 63 | if _, err := f.ReadAt(buf[:], i*fi.Size()/numSamples); err != nil { 64 | return 0 65 | } 66 | h.Write(buf[:]) 67 | } 68 | return h.Sum64() 69 | } 70 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package editiondefaults contains the binary representation of the editions 6 | // defaults. 7 | package editiondefaults 8 | 9 | import _ "embed" 10 | 11 | //go:embed editions_defaults.binpb 12 | var Defaults []byte 13 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafana/adaptive-metrics-autoapply/8170885a6efb81ac7ce5ef5110679b2d3d2944fa/docker/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package text implements the text format for protocol buffers. 6 | // This package has no semantic understanding for protocol buffers and is only 7 | // a parser and composer for the format. 8 | // 9 | // There is no formal specification for the protobuf text format, as such the 10 | // C++ implementation (see google::protobuf::TextFormat) is the reference 11 | // implementation of the text format. 12 | // 13 | // This package is neither a superset nor a subset of the C++ implementation. 14 | // This implementation permits a more liberal grammar in some cases to be 15 | // backwards compatible with the historical Go implementation. 16 | // Future parsings unique to Go should not be added. 17 | // Some grammars allowed by the C++ implementation are deliberately 18 | // not implemented here because they are considered a bug by the protobuf team 19 | // and should not be replicated. 20 | // 21 | // The Go implementation should implement a sufficient amount of the C++ 22 | // grammar such that the default text serialization by C++ can be parsed by Go. 23 | // However, just because the C++ parser accepts some input does not mean that 24 | // the Go implementation should as well. 25 | // 26 | // The text format is almost a superset of JSON except: 27 | // - message keys are not quoted strings, but identifiers 28 | // - the top-level value must be a message without the delimiters 29 | package text 30 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/errors/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package errors implements functions to manipulate errors. 6 | package errors 7 | 8 | import ( 9 | "errors" 10 | "fmt" 11 | 12 | "google.golang.org/protobuf/internal/detrand" 13 | ) 14 | 15 | // Error is a sentinel matching all errors produced by this package. 16 | var Error = errors.New("protobuf error") 17 | 18 | // New formats a string according to the format specifier and arguments and 19 | // returns an error that has a "proto" prefix. 20 | func New(f string, x ...any) error { 21 | return &prefixError{s: format(f, x...)} 22 | } 23 | 24 | type prefixError struct{ s string } 25 | 26 | var prefix = func() string { 27 | // Deliberately introduce instability into the error message string to 28 | // discourage users from performing error string comparisons. 29 | if detrand.Bool() { 30 | return "proto: " // use non-breaking spaces (U+00a0) 31 | } else { 32 | return "proto: " // use regular spaces (U+0020) 33 | } 34 | }() 35 | 36 | func (e *prefixError) Error() string { 37 | return prefix + e.s 38 | } 39 | 40 | func (e *prefixError) Unwrap() error { 41 | return Error 42 | } 43 | 44 | // Wrap returns an error that has a "proto" prefix, the formatted string described 45 | // by the format specifier and arguments, and a suffix of err. The error wraps err. 46 | func Wrap(err error, f string, x ...any) error { 47 | return &wrapError{ 48 | s: format(f, x...), 49 | err: err, 50 | } 51 | } 52 | 53 | type wrapError struct { 54 | s string 55 | err error 56 | } 57 | 58 | func (e *wrapError) Error() string { 59 | return format("%v%v: %v", prefix, e.s, e.err) 60 | } 61 | 62 | func (e *wrapError) Unwrap() error { 63 | return e.err 64 | } 65 | 66 | func (e *wrapError) Is(target error) bool { 67 | return target == Error 68 | } 69 | 70 | func format(f string, x ...any) string { 71 | // avoid "proto: " prefix when chaining 72 | for i := 0; i < len(x); i++ { 73 | switch e := x[i].(type) { 74 | case *prefixError: 75 | x[i] = e.s 76 | case *wrapError: 77 | x[i] = format("%v: %v", e.s, e.err) 78 | } 79 | } 80 | return fmt.Sprintf(f, x...) 81 | } 82 | 83 | func InvalidUTF8(name string) error { 84 | return New("field %v contains invalid UTF-8", name) 85 | } 86 | 87 | func RequiredNotSet(name string) error { 88 | return New("required field %v not set", name) 89 | } 90 | 91 | type SizeMismatchError struct { 92 | Calculated, Measured int 93 | } 94 | 95 | func (e *SizeMismatchError) Error() string { 96 | return fmt.Sprintf("size mismatch (see https://github.com/golang/protobuf/issues/1609): calculated=%d, measured=%d", e.Calculated, e.Measured) 97 | } 98 | 99 | func MismatchedSizeCalculation(calculated, measured int) error { 100 | return &SizeMismatchError{ 101 | Calculated: calculated, 102 | Measured: measured, 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/errors/is_go112.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.13 6 | // +build !go1.13 7 | 8 | package errors 9 | 10 | import "reflect" 11 | 12 | // Is is a copy of Go 1.13's errors.Is for use with older Go versions. 13 | func Is(err, target error) bool { 14 | if target == nil { 15 | return err == target 16 | } 17 | 18 | isComparable := reflect.TypeOf(target).Comparable() 19 | for { 20 | if isComparable && err == target { 21 | return true 22 | } 23 | if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { 24 | return true 25 | } 26 | if err = unwrap(err); err == nil { 27 | return false 28 | } 29 | } 30 | } 31 | 32 | func unwrap(err error) error { 33 | u, ok := err.(interface { 34 | Unwrap() error 35 | }) 36 | if !ok { 37 | return nil 38 | } 39 | return u.Unwrap() 40 | } 41 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/errors/is_go113.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.13 6 | // +build go1.13 7 | 8 | package errors 9 | 10 | import "errors" 11 | 12 | // Is is errors.Is. 13 | func Is(err, target error) bool { return errors.Is(err, target) } 14 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/flags/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package flags provides a set of flags controlled by build tags. 6 | package flags 7 | 8 | // ProtoLegacy specifies whether to enable support for legacy functionality 9 | // such as MessageSets, weak fields, and various other obscure behavior 10 | // that is necessary to maintain backwards compatibility with proto1 or 11 | // the pre-release variants of proto2 and proto3. 12 | // 13 | // This is disabled by default unless built with the "protolegacy" tag. 14 | // 15 | // WARNING: The compatibility agreement covers nothing provided by this flag. 16 | // As such, functionality may suddenly be removed or changed at our discretion. 17 | const ProtoLegacy = protoLegacy 18 | 19 | // LazyUnmarshalExtensions specifies whether to lazily unmarshal extensions. 20 | // 21 | // Lazy extension unmarshaling validates the contents of message-valued 22 | // extension fields at unmarshal time, but defers creating the message 23 | // structure until the extension is first accessed. 24 | const LazyUnmarshalExtensions = ProtoLegacy 25 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !protolegacy 6 | // +build !protolegacy 7 | 8 | package flags 9 | 10 | const protoLegacy = false 11 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build protolegacy 6 | // +build protolegacy 7 | 8 | package flags 9 | 10 | const protoLegacy = true 11 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/any_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_any_proto = "google/protobuf/any.proto" 14 | 15 | // Names for google.protobuf.Any. 16 | const ( 17 | Any_message_name protoreflect.Name = "Any" 18 | Any_message_fullname protoreflect.FullName = "google.protobuf.Any" 19 | ) 20 | 21 | // Field names for google.protobuf.Any. 22 | const ( 23 | Any_TypeUrl_field_name protoreflect.Name = "type_url" 24 | Any_Value_field_name protoreflect.Name = "value" 25 | 26 | Any_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Any.type_url" 27 | Any_Value_field_fullname protoreflect.FullName = "google.protobuf.Any.value" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Any. 31 | const ( 32 | Any_TypeUrl_field_number protoreflect.FieldNumber = 1 33 | Any_Value_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package genid contains constants for declarations in descriptor.proto 6 | // and the well-known types. 7 | package genid 8 | 9 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 10 | 11 | const GoogleProtobuf_package protoreflect.FullName = "google.protobuf" 12 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_duration_proto = "google/protobuf/duration.proto" 14 | 15 | // Names for google.protobuf.Duration. 16 | const ( 17 | Duration_message_name protoreflect.Name = "Duration" 18 | Duration_message_fullname protoreflect.FullName = "google.protobuf.Duration" 19 | ) 20 | 21 | // Field names for google.protobuf.Duration. 22 | const ( 23 | Duration_Seconds_field_name protoreflect.Name = "seconds" 24 | Duration_Nanos_field_name protoreflect.Name = "nanos" 25 | 26 | Duration_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Duration.seconds" 27 | Duration_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Duration.nanos" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Duration. 31 | const ( 32 | Duration_Seconds_field_number protoreflect.FieldNumber = 1 33 | Duration_Nanos_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_empty_proto = "google/protobuf/empty.proto" 14 | 15 | // Names for google.protobuf.Empty. 16 | const ( 17 | Empty_message_name protoreflect.Name = "Empty" 18 | Empty_message_fullname protoreflect.FullName = "google.protobuf.Empty" 19 | ) 20 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_field_mask_proto = "google/protobuf/field_mask.proto" 14 | 15 | // Names for google.protobuf.FieldMask. 16 | const ( 17 | FieldMask_message_name protoreflect.Name = "FieldMask" 18 | FieldMask_message_fullname protoreflect.FullName = "google.protobuf.FieldMask" 19 | ) 20 | 21 | // Field names for google.protobuf.FieldMask. 22 | const ( 23 | FieldMask_Paths_field_name protoreflect.Name = "paths" 24 | 25 | FieldMask_Paths_field_fullname protoreflect.FullName = "google.protobuf.FieldMask.paths" 26 | ) 27 | 28 | // Field numbers for google.protobuf.FieldMask. 29 | const ( 30 | FieldMask_Paths_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto" 14 | 15 | // Names for google.protobuf.GoFeatures. 16 | const ( 17 | GoFeatures_message_name protoreflect.Name = "GoFeatures" 18 | GoFeatures_message_fullname protoreflect.FullName = "google.protobuf.GoFeatures" 19 | ) 20 | 21 | // Field names for google.protobuf.GoFeatures. 22 | const ( 23 | GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum" 24 | 25 | GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "google.protobuf.GoFeatures.legacy_unmarshal_json_enum" 26 | ) 27 | 28 | // Field numbers for google.protobuf.GoFeatures. 29 | const ( 30 | GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/goname.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | // Go names of implementation-specific struct fields in generated messages. 8 | const ( 9 | State_goname = "state" 10 | 11 | SizeCache_goname = "sizeCache" 12 | SizeCacheA_goname = "XXX_sizecache" 13 | 14 | WeakFields_goname = "weakFields" 15 | WeakFieldsA_goname = "XXX_weak" 16 | 17 | UnknownFields_goname = "unknownFields" 18 | UnknownFieldsA_goname = "XXX_unrecognized" 19 | 20 | ExtensionFields_goname = "extensionFields" 21 | ExtensionFieldsA_goname = "XXX_InternalExtensions" 22 | ExtensionFieldsB_goname = "XXX_extensions" 23 | 24 | WeakFieldPrefix_goname = "XXX_weak_" 25 | ) 26 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/map_entry.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 8 | 9 | // Generic field names and numbers for synthetic map entry messages. 10 | const ( 11 | MapEntry_Key_field_name protoreflect.Name = "key" 12 | MapEntry_Value_field_name protoreflect.Name = "value" 13 | 14 | MapEntry_Key_field_number protoreflect.FieldNumber = 1 15 | MapEntry_Value_field_number protoreflect.FieldNumber = 2 16 | ) 17 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_source_context_proto = "google/protobuf/source_context.proto" 14 | 15 | // Names for google.protobuf.SourceContext. 16 | const ( 17 | SourceContext_message_name protoreflect.Name = "SourceContext" 18 | SourceContext_message_fullname protoreflect.FullName = "google.protobuf.SourceContext" 19 | ) 20 | 21 | // Field names for google.protobuf.SourceContext. 22 | const ( 23 | SourceContext_FileName_field_name protoreflect.Name = "file_name" 24 | 25 | SourceContext_FileName_field_fullname protoreflect.FullName = "google.protobuf.SourceContext.file_name" 26 | ) 27 | 28 | // Field numbers for google.protobuf.SourceContext. 29 | const ( 30 | SourceContext_FileName_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_struct_proto = "google/protobuf/struct.proto" 14 | 15 | // Full and short names for google.protobuf.NullValue. 16 | const ( 17 | NullValue_enum_fullname = "google.protobuf.NullValue" 18 | NullValue_enum_name = "NullValue" 19 | ) 20 | 21 | // Enum values for google.protobuf.NullValue. 22 | const ( 23 | NullValue_NULL_VALUE_enum_value = 0 24 | ) 25 | 26 | // Names for google.protobuf.Struct. 27 | const ( 28 | Struct_message_name protoreflect.Name = "Struct" 29 | Struct_message_fullname protoreflect.FullName = "google.protobuf.Struct" 30 | ) 31 | 32 | // Field names for google.protobuf.Struct. 33 | const ( 34 | Struct_Fields_field_name protoreflect.Name = "fields" 35 | 36 | Struct_Fields_field_fullname protoreflect.FullName = "google.protobuf.Struct.fields" 37 | ) 38 | 39 | // Field numbers for google.protobuf.Struct. 40 | const ( 41 | Struct_Fields_field_number protoreflect.FieldNumber = 1 42 | ) 43 | 44 | // Names for google.protobuf.Struct.FieldsEntry. 45 | const ( 46 | Struct_FieldsEntry_message_name protoreflect.Name = "FieldsEntry" 47 | Struct_FieldsEntry_message_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry" 48 | ) 49 | 50 | // Field names for google.protobuf.Struct.FieldsEntry. 51 | const ( 52 | Struct_FieldsEntry_Key_field_name protoreflect.Name = "key" 53 | Struct_FieldsEntry_Value_field_name protoreflect.Name = "value" 54 | 55 | Struct_FieldsEntry_Key_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.key" 56 | Struct_FieldsEntry_Value_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.value" 57 | ) 58 | 59 | // Field numbers for google.protobuf.Struct.FieldsEntry. 60 | const ( 61 | Struct_FieldsEntry_Key_field_number protoreflect.FieldNumber = 1 62 | Struct_FieldsEntry_Value_field_number protoreflect.FieldNumber = 2 63 | ) 64 | 65 | // Names for google.protobuf.Value. 66 | const ( 67 | Value_message_name protoreflect.Name = "Value" 68 | Value_message_fullname protoreflect.FullName = "google.protobuf.Value" 69 | ) 70 | 71 | // Field names for google.protobuf.Value. 72 | const ( 73 | Value_NullValue_field_name protoreflect.Name = "null_value" 74 | Value_NumberValue_field_name protoreflect.Name = "number_value" 75 | Value_StringValue_field_name protoreflect.Name = "string_value" 76 | Value_BoolValue_field_name protoreflect.Name = "bool_value" 77 | Value_StructValue_field_name protoreflect.Name = "struct_value" 78 | Value_ListValue_field_name protoreflect.Name = "list_value" 79 | 80 | Value_NullValue_field_fullname protoreflect.FullName = "google.protobuf.Value.null_value" 81 | Value_NumberValue_field_fullname protoreflect.FullName = "google.protobuf.Value.number_value" 82 | Value_StringValue_field_fullname protoreflect.FullName = "google.protobuf.Value.string_value" 83 | Value_BoolValue_field_fullname protoreflect.FullName = "google.protobuf.Value.bool_value" 84 | Value_StructValue_field_fullname protoreflect.FullName = "google.protobuf.Value.struct_value" 85 | Value_ListValue_field_fullname protoreflect.FullName = "google.protobuf.Value.list_value" 86 | ) 87 | 88 | // Field numbers for google.protobuf.Value. 89 | const ( 90 | Value_NullValue_field_number protoreflect.FieldNumber = 1 91 | Value_NumberValue_field_number protoreflect.FieldNumber = 2 92 | Value_StringValue_field_number protoreflect.FieldNumber = 3 93 | Value_BoolValue_field_number protoreflect.FieldNumber = 4 94 | Value_StructValue_field_number protoreflect.FieldNumber = 5 95 | Value_ListValue_field_number protoreflect.FieldNumber = 6 96 | ) 97 | 98 | // Oneof names for google.protobuf.Value. 99 | const ( 100 | Value_Kind_oneof_name protoreflect.Name = "kind" 101 | 102 | Value_Kind_oneof_fullname protoreflect.FullName = "google.protobuf.Value.kind" 103 | ) 104 | 105 | // Names for google.protobuf.ListValue. 106 | const ( 107 | ListValue_message_name protoreflect.Name = "ListValue" 108 | ListValue_message_fullname protoreflect.FullName = "google.protobuf.ListValue" 109 | ) 110 | 111 | // Field names for google.protobuf.ListValue. 112 | const ( 113 | ListValue_Values_field_name protoreflect.Name = "values" 114 | 115 | ListValue_Values_field_fullname protoreflect.FullName = "google.protobuf.ListValue.values" 116 | ) 117 | 118 | // Field numbers for google.protobuf.ListValue. 119 | const ( 120 | ListValue_Values_field_number protoreflect.FieldNumber = 1 121 | ) 122 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_timestamp_proto = "google/protobuf/timestamp.proto" 14 | 15 | // Names for google.protobuf.Timestamp. 16 | const ( 17 | Timestamp_message_name protoreflect.Name = "Timestamp" 18 | Timestamp_message_fullname protoreflect.FullName = "google.protobuf.Timestamp" 19 | ) 20 | 21 | // Field names for google.protobuf.Timestamp. 22 | const ( 23 | Timestamp_Seconds_field_name protoreflect.Name = "seconds" 24 | Timestamp_Nanos_field_name protoreflect.Name = "nanos" 25 | 26 | Timestamp_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.seconds" 27 | Timestamp_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.nanos" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Timestamp. 31 | const ( 32 | Timestamp_Seconds_field_number protoreflect.FieldNumber = 1 33 | Timestamp_Nanos_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/genid/wrappers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 8 | 9 | // Generic field name and number for messages in wrappers.proto. 10 | const ( 11 | WrapperValue_Value_field_name protoreflect.Name = "value" 12 | WrapperValue_Value_field_number protoreflect.FieldNumber = 1 13 | ) 14 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/checkinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "sync" 9 | 10 | "google.golang.org/protobuf/internal/errors" 11 | "google.golang.org/protobuf/reflect/protoreflect" 12 | "google.golang.org/protobuf/runtime/protoiface" 13 | ) 14 | 15 | func (mi *MessageInfo) checkInitialized(in protoiface.CheckInitializedInput) (protoiface.CheckInitializedOutput, error) { 16 | var p pointer 17 | if ms, ok := in.Message.(*messageState); ok { 18 | p = ms.pointer() 19 | } else { 20 | p = in.Message.(*messageReflectWrapper).pointer() 21 | } 22 | return protoiface.CheckInitializedOutput{}, mi.checkInitializedPointer(p) 23 | } 24 | 25 | func (mi *MessageInfo) checkInitializedPointer(p pointer) error { 26 | mi.init() 27 | if !mi.needsInitCheck { 28 | return nil 29 | } 30 | if p.IsNil() { 31 | for _, f := range mi.orderedCoderFields { 32 | if f.isRequired { 33 | return errors.RequiredNotSet(string(mi.Desc.Fields().ByNumber(f.num).FullName())) 34 | } 35 | } 36 | return nil 37 | } 38 | if mi.extensionOffset.IsValid() { 39 | e := p.Apply(mi.extensionOffset).Extensions() 40 | if err := mi.isInitExtensions(e); err != nil { 41 | return err 42 | } 43 | } 44 | for _, f := range mi.orderedCoderFields { 45 | if !f.isRequired && f.funcs.isInit == nil { 46 | continue 47 | } 48 | fptr := p.Apply(f.offset) 49 | if f.isPointer && fptr.Elem().IsNil() { 50 | if f.isRequired { 51 | return errors.RequiredNotSet(string(mi.Desc.Fields().ByNumber(f.num).FullName())) 52 | } 53 | continue 54 | } 55 | if f.funcs.isInit == nil { 56 | continue 57 | } 58 | if err := f.funcs.isInit(fptr, f); err != nil { 59 | return err 60 | } 61 | } 62 | return nil 63 | } 64 | 65 | func (mi *MessageInfo) isInitExtensions(ext *map[int32]ExtensionField) error { 66 | if ext == nil { 67 | return nil 68 | } 69 | for _, x := range *ext { 70 | ei := getExtensionFieldInfo(x.Type()) 71 | if ei.funcs.isInit == nil || x.isUnexpandedLazy() { 72 | continue 73 | } 74 | v := x.Value() 75 | if !v.IsValid() { 76 | continue 77 | } 78 | if err := ei.funcs.isInit(v); err != nil { 79 | return err 80 | } 81 | } 82 | return nil 83 | } 84 | 85 | var ( 86 | needsInitCheckMu sync.Mutex 87 | needsInitCheckMap sync.Map 88 | ) 89 | 90 | // needsInitCheck reports whether a message needs to be checked for partial initialization. 91 | // 92 | // It returns true if the message transitively includes any required or extension fields. 93 | func needsInitCheck(md protoreflect.MessageDescriptor) bool { 94 | if v, ok := needsInitCheckMap.Load(md); ok { 95 | if has, ok := v.(bool); ok { 96 | return has 97 | } 98 | } 99 | needsInitCheckMu.Lock() 100 | defer needsInitCheckMu.Unlock() 101 | return needsInitCheckLocked(md) 102 | } 103 | 104 | func needsInitCheckLocked(md protoreflect.MessageDescriptor) (has bool) { 105 | if v, ok := needsInitCheckMap.Load(md); ok { 106 | // If has is true, we've previously determined that this message 107 | // needs init checks. 108 | // 109 | // If has is false, we've previously determined that it can never 110 | // be uninitialized. 111 | // 112 | // If has is not a bool, we've just encountered a cycle in the 113 | // message graph. In this case, it is safe to return false: If 114 | // the message does have required fields, we'll detect them later 115 | // in the graph traversal. 116 | has, ok := v.(bool) 117 | return ok && has 118 | } 119 | needsInitCheckMap.Store(md, struct{}{}) // avoid cycles while descending into this message 120 | defer func() { 121 | needsInitCheckMap.Store(md, has) 122 | }() 123 | if md.RequiredNumbers().Len() > 0 { 124 | return true 125 | } 126 | if md.ExtensionRanges().Len() > 0 { 127 | return true 128 | } 129 | for i := 0; i < md.Fields().Len(); i++ { 130 | fd := md.Fields().Get(i) 131 | // Map keys are never messages, so just consider the map value. 132 | if fd.IsMap() { 133 | fd = fd.MapValue() 134 | } 135 | fmd := fd.Message() 136 | if fmd != nil && needsInitCheckLocked(fmd) { 137 | return true 138 | } 139 | } 140 | return false 141 | } 142 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.12 6 | // +build !go1.12 7 | 8 | package impl 9 | 10 | import "reflect" 11 | 12 | type mapIter struct { 13 | v reflect.Value 14 | keys []reflect.Value 15 | } 16 | 17 | // mapRange provides a less-efficient equivalent to 18 | // the Go 1.12 reflect.Value.MapRange method. 19 | func mapRange(v reflect.Value) *mapIter { 20 | return &mapIter{v: v} 21 | } 22 | 23 | func (i *mapIter) Next() bool { 24 | if i.keys == nil { 25 | i.keys = i.v.MapKeys() 26 | } else { 27 | i.keys = i.keys[1:] 28 | } 29 | return len(i.keys) > 0 30 | } 31 | 32 | func (i *mapIter) Key() reflect.Value { 33 | return i.keys[0] 34 | } 35 | 36 | func (i *mapIter) Value() reflect.Value { 37 | return i.v.MapIndex(i.keys[0]) 38 | } 39 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.12 6 | // +build go1.12 7 | 8 | package impl 9 | 10 | import "reflect" 11 | 12 | func mapRange(v reflect.Value) *reflect.MapIter { return v.MapRange() } 13 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "sort" 9 | 10 | "google.golang.org/protobuf/encoding/protowire" 11 | "google.golang.org/protobuf/internal/encoding/messageset" 12 | "google.golang.org/protobuf/internal/errors" 13 | "google.golang.org/protobuf/internal/flags" 14 | ) 15 | 16 | func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int) { 17 | if !flags.ProtoLegacy { 18 | return 0 19 | } 20 | 21 | ext := *p.Apply(mi.extensionOffset).Extensions() 22 | for _, x := range ext { 23 | xi := getExtensionFieldInfo(x.Type()) 24 | if xi.funcs.size == nil { 25 | continue 26 | } 27 | num, _ := protowire.DecodeTag(xi.wiretag) 28 | size += messageset.SizeField(num) 29 | if fullyLazyExtensions(opts) { 30 | // Don't expand the extension, instead use the buffer to calculate size 31 | if lb := x.lazyBuffer(); lb != nil { 32 | // We got hold of the buffer, so it's still lazy. 33 | // Don't count the tag size in the extension buffer, it's already added. 34 | size += protowire.SizeTag(messageset.FieldMessage) + len(lb) - xi.tagsize 35 | continue 36 | } 37 | } 38 | size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts) 39 | } 40 | 41 | if u := mi.getUnknownBytes(p); u != nil { 42 | size += messageset.SizeUnknown(*u) 43 | } 44 | 45 | return size 46 | } 47 | 48 | func marshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts marshalOptions) ([]byte, error) { 49 | if !flags.ProtoLegacy { 50 | return b, errors.New("no support for message_set_wire_format") 51 | } 52 | 53 | ext := *p.Apply(mi.extensionOffset).Extensions() 54 | switch len(ext) { 55 | case 0: 56 | case 1: 57 | // Fast-path for one extension: Don't bother sorting the keys. 58 | for _, x := range ext { 59 | var err error 60 | b, err = marshalMessageSetField(mi, b, x, opts) 61 | if err != nil { 62 | return b, err 63 | } 64 | } 65 | default: 66 | // Sort the keys to provide a deterministic encoding. 67 | // Not sure this is required, but the old code does it. 68 | keys := make([]int, 0, len(ext)) 69 | for k := range ext { 70 | keys = append(keys, int(k)) 71 | } 72 | sort.Ints(keys) 73 | for _, k := range keys { 74 | var err error 75 | b, err = marshalMessageSetField(mi, b, ext[int32(k)], opts) 76 | if err != nil { 77 | return b, err 78 | } 79 | } 80 | } 81 | 82 | if u := mi.getUnknownBytes(p); u != nil { 83 | var err error 84 | b, err = messageset.AppendUnknown(b, *u) 85 | if err != nil { 86 | return b, err 87 | } 88 | } 89 | 90 | return b, nil 91 | } 92 | 93 | func marshalMessageSetField(mi *MessageInfo, b []byte, x ExtensionField, opts marshalOptions) ([]byte, error) { 94 | xi := getExtensionFieldInfo(x.Type()) 95 | num, _ := protowire.DecodeTag(xi.wiretag) 96 | b = messageset.AppendFieldStart(b, num) 97 | 98 | if fullyLazyExtensions(opts) { 99 | // Don't expand the extension if it's still in wire format, instead use the buffer content. 100 | if lb := x.lazyBuffer(); lb != nil { 101 | // The tag inside the lazy buffer is a different tag (the extension 102 | // number), but what we need here is the tag for FieldMessage: 103 | b = protowire.AppendVarint(b, protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType)) 104 | b = append(b, lb[xi.tagsize:]...) 105 | b = messageset.AppendFieldEnd(b) 106 | return b, nil 107 | } 108 | } 109 | 110 | b, err := xi.funcs.marshal(b, x.Value(), protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType), opts) 111 | if err != nil { 112 | return b, err 113 | } 114 | b = messageset.AppendFieldEnd(b) 115 | return b, nil 116 | } 117 | 118 | func unmarshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts unmarshalOptions) (out unmarshalOutput, err error) { 119 | if !flags.ProtoLegacy { 120 | return out, errors.New("no support for message_set_wire_format") 121 | } 122 | 123 | ep := p.Apply(mi.extensionOffset).Extensions() 124 | if *ep == nil { 125 | *ep = make(map[int32]ExtensionField) 126 | } 127 | ext := *ep 128 | initialized := true 129 | err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error { 130 | o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts) 131 | if err == errUnknown { 132 | u := mi.mutableUnknownBytes(p) 133 | *u = protowire.AppendTag(*u, num, protowire.BytesType) 134 | *u = append(*u, v...) 135 | return nil 136 | } 137 | if !o.initialized { 138 | initialized = false 139 | } 140 | return err 141 | }) 142 | out.n = len(b) 143 | out.initialized = initialized 144 | return out, err 145 | } 146 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine 6 | // +build !purego,!appengine 7 | 8 | package impl 9 | 10 | // When using unsafe pointers, we can just treat enum values as int32s. 11 | 12 | var ( 13 | coderEnumNoZero = coderInt32NoZero 14 | coderEnum = coderInt32 15 | coderEnumPtr = coderInt32Ptr 16 | coderEnumSlice = coderInt32Slice 17 | coderEnumPackedSlice = coderInt32PackedSlice 18 | ) 19 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/convert_list.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "fmt" 9 | "reflect" 10 | 11 | "google.golang.org/protobuf/reflect/protoreflect" 12 | ) 13 | 14 | func newListConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Converter { 15 | switch { 16 | case t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Slice: 17 | return &listPtrConverter{t, newSingularConverter(t.Elem().Elem(), fd)} 18 | case t.Kind() == reflect.Slice: 19 | return &listConverter{t, newSingularConverter(t.Elem(), fd)} 20 | } 21 | panic(fmt.Sprintf("invalid Go type %v for field %v", t, fd.FullName())) 22 | } 23 | 24 | type listConverter struct { 25 | goType reflect.Type // []T 26 | c Converter 27 | } 28 | 29 | func (c *listConverter) PBValueOf(v reflect.Value) protoreflect.Value { 30 | if v.Type() != c.goType { 31 | panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType)) 32 | } 33 | pv := reflect.New(c.goType) 34 | pv.Elem().Set(v) 35 | return protoreflect.ValueOfList(&listReflect{pv, c.c}) 36 | } 37 | 38 | func (c *listConverter) GoValueOf(v protoreflect.Value) reflect.Value { 39 | rv := v.List().(*listReflect).v 40 | if rv.IsNil() { 41 | return reflect.Zero(c.goType) 42 | } 43 | return rv.Elem() 44 | } 45 | 46 | func (c *listConverter) IsValidPB(v protoreflect.Value) bool { 47 | list, ok := v.Interface().(*listReflect) 48 | if !ok { 49 | return false 50 | } 51 | return list.v.Type().Elem() == c.goType 52 | } 53 | 54 | func (c *listConverter) IsValidGo(v reflect.Value) bool { 55 | return v.IsValid() && v.Type() == c.goType 56 | } 57 | 58 | func (c *listConverter) New() protoreflect.Value { 59 | return protoreflect.ValueOfList(&listReflect{reflect.New(c.goType), c.c}) 60 | } 61 | 62 | func (c *listConverter) Zero() protoreflect.Value { 63 | return protoreflect.ValueOfList(&listReflect{reflect.Zero(reflect.PtrTo(c.goType)), c.c}) 64 | } 65 | 66 | type listPtrConverter struct { 67 | goType reflect.Type // *[]T 68 | c Converter 69 | } 70 | 71 | func (c *listPtrConverter) PBValueOf(v reflect.Value) protoreflect.Value { 72 | if v.Type() != c.goType { 73 | panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType)) 74 | } 75 | return protoreflect.ValueOfList(&listReflect{v, c.c}) 76 | } 77 | 78 | func (c *listPtrConverter) GoValueOf(v protoreflect.Value) reflect.Value { 79 | return v.List().(*listReflect).v 80 | } 81 | 82 | func (c *listPtrConverter) IsValidPB(v protoreflect.Value) bool { 83 | list, ok := v.Interface().(*listReflect) 84 | if !ok { 85 | return false 86 | } 87 | return list.v.Type() == c.goType 88 | } 89 | 90 | func (c *listPtrConverter) IsValidGo(v reflect.Value) bool { 91 | return v.IsValid() && v.Type() == c.goType 92 | } 93 | 94 | func (c *listPtrConverter) New() protoreflect.Value { 95 | return c.PBValueOf(reflect.New(c.goType.Elem())) 96 | } 97 | 98 | func (c *listPtrConverter) Zero() protoreflect.Value { 99 | return c.PBValueOf(reflect.Zero(c.goType)) 100 | } 101 | 102 | type listReflect struct { 103 | v reflect.Value // *[]T 104 | conv Converter 105 | } 106 | 107 | func (ls *listReflect) Len() int { 108 | if ls.v.IsNil() { 109 | return 0 110 | } 111 | return ls.v.Elem().Len() 112 | } 113 | func (ls *listReflect) Get(i int) protoreflect.Value { 114 | return ls.conv.PBValueOf(ls.v.Elem().Index(i)) 115 | } 116 | func (ls *listReflect) Set(i int, v protoreflect.Value) { 117 | ls.v.Elem().Index(i).Set(ls.conv.GoValueOf(v)) 118 | } 119 | func (ls *listReflect) Append(v protoreflect.Value) { 120 | ls.v.Elem().Set(reflect.Append(ls.v.Elem(), ls.conv.GoValueOf(v))) 121 | } 122 | func (ls *listReflect) AppendMutable() protoreflect.Value { 123 | if _, ok := ls.conv.(*messageConverter); !ok { 124 | panic("invalid AppendMutable on list with non-message type") 125 | } 126 | v := ls.NewElement() 127 | ls.Append(v) 128 | return v 129 | } 130 | func (ls *listReflect) Truncate(i int) { 131 | ls.v.Elem().Set(ls.v.Elem().Slice(0, i)) 132 | } 133 | func (ls *listReflect) NewElement() protoreflect.Value { 134 | return ls.conv.New() 135 | } 136 | func (ls *listReflect) IsValid() bool { 137 | return !ls.v.IsNil() 138 | } 139 | func (ls *listReflect) protoUnwrap() any { 140 | return ls.v.Interface() 141 | } 142 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/convert_map.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "fmt" 9 | "reflect" 10 | 11 | "google.golang.org/protobuf/reflect/protoreflect" 12 | ) 13 | 14 | type mapConverter struct { 15 | goType reflect.Type // map[K]V 16 | keyConv, valConv Converter 17 | } 18 | 19 | func newMapConverter(t reflect.Type, fd protoreflect.FieldDescriptor) *mapConverter { 20 | if t.Kind() != reflect.Map { 21 | panic(fmt.Sprintf("invalid Go type %v for field %v", t, fd.FullName())) 22 | } 23 | return &mapConverter{ 24 | goType: t, 25 | keyConv: newSingularConverter(t.Key(), fd.MapKey()), 26 | valConv: newSingularConverter(t.Elem(), fd.MapValue()), 27 | } 28 | } 29 | 30 | func (c *mapConverter) PBValueOf(v reflect.Value) protoreflect.Value { 31 | if v.Type() != c.goType { 32 | panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType)) 33 | } 34 | return protoreflect.ValueOfMap(&mapReflect{v, c.keyConv, c.valConv}) 35 | } 36 | 37 | func (c *mapConverter) GoValueOf(v protoreflect.Value) reflect.Value { 38 | return v.Map().(*mapReflect).v 39 | } 40 | 41 | func (c *mapConverter) IsValidPB(v protoreflect.Value) bool { 42 | mapv, ok := v.Interface().(*mapReflect) 43 | if !ok { 44 | return false 45 | } 46 | return mapv.v.Type() == c.goType 47 | } 48 | 49 | func (c *mapConverter) IsValidGo(v reflect.Value) bool { 50 | return v.IsValid() && v.Type() == c.goType 51 | } 52 | 53 | func (c *mapConverter) New() protoreflect.Value { 54 | return c.PBValueOf(reflect.MakeMap(c.goType)) 55 | } 56 | 57 | func (c *mapConverter) Zero() protoreflect.Value { 58 | return c.PBValueOf(reflect.Zero(c.goType)) 59 | } 60 | 61 | type mapReflect struct { 62 | v reflect.Value // map[K]V 63 | keyConv Converter 64 | valConv Converter 65 | } 66 | 67 | func (ms *mapReflect) Len() int { 68 | return ms.v.Len() 69 | } 70 | func (ms *mapReflect) Has(k protoreflect.MapKey) bool { 71 | rk := ms.keyConv.GoValueOf(k.Value()) 72 | rv := ms.v.MapIndex(rk) 73 | return rv.IsValid() 74 | } 75 | func (ms *mapReflect) Get(k protoreflect.MapKey) protoreflect.Value { 76 | rk := ms.keyConv.GoValueOf(k.Value()) 77 | rv := ms.v.MapIndex(rk) 78 | if !rv.IsValid() { 79 | return protoreflect.Value{} 80 | } 81 | return ms.valConv.PBValueOf(rv) 82 | } 83 | func (ms *mapReflect) Set(k protoreflect.MapKey, v protoreflect.Value) { 84 | rk := ms.keyConv.GoValueOf(k.Value()) 85 | rv := ms.valConv.GoValueOf(v) 86 | ms.v.SetMapIndex(rk, rv) 87 | } 88 | func (ms *mapReflect) Clear(k protoreflect.MapKey) { 89 | rk := ms.keyConv.GoValueOf(k.Value()) 90 | ms.v.SetMapIndex(rk, reflect.Value{}) 91 | } 92 | func (ms *mapReflect) Mutable(k protoreflect.MapKey) protoreflect.Value { 93 | if _, ok := ms.valConv.(*messageConverter); !ok { 94 | panic("invalid Mutable on map with non-message value type") 95 | } 96 | v := ms.Get(k) 97 | if !v.IsValid() { 98 | v = ms.NewValue() 99 | ms.Set(k, v) 100 | } 101 | return v 102 | } 103 | func (ms *mapReflect) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) { 104 | iter := mapRange(ms.v) 105 | for iter.Next() { 106 | k := ms.keyConv.PBValueOf(iter.Key()).MapKey() 107 | v := ms.valConv.PBValueOf(iter.Value()) 108 | if !f(k, v) { 109 | return 110 | } 111 | } 112 | } 113 | func (ms *mapReflect) NewValue() protoreflect.Value { 114 | return ms.valConv.New() 115 | } 116 | func (ms *mapReflect) IsValid() bool { 117 | return !ms.v.IsNil() 118 | } 119 | func (ms *mapReflect) protoUnwrap() any { 120 | return ms.v.Interface() 121 | } 122 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/enum.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "reflect" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | type EnumInfo struct { 14 | GoReflectType reflect.Type // int32 kind 15 | Desc protoreflect.EnumDescriptor 16 | } 17 | 18 | func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum { 19 | return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum) 20 | } 21 | func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc } 22 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "encoding/binary" 9 | "encoding/json" 10 | "hash/crc32" 11 | "math" 12 | "reflect" 13 | 14 | "google.golang.org/protobuf/internal/errors" 15 | "google.golang.org/protobuf/reflect/protoreflect" 16 | "google.golang.org/protobuf/runtime/protoiface" 17 | ) 18 | 19 | // These functions exist to support exported APIs in generated protobufs. 20 | // While these are deprecated, they cannot be removed for compatibility reasons. 21 | 22 | // LegacyEnumName returns the name of enums used in legacy code. 23 | func (Export) LegacyEnumName(ed protoreflect.EnumDescriptor) string { 24 | return legacyEnumName(ed) 25 | } 26 | 27 | // LegacyMessageTypeOf returns the protoreflect.MessageType for m, 28 | // with name used as the message name if necessary. 29 | func (Export) LegacyMessageTypeOf(m protoiface.MessageV1, name protoreflect.FullName) protoreflect.MessageType { 30 | if mv := (Export{}).protoMessageV2Of(m); mv != nil { 31 | return mv.ProtoReflect().Type() 32 | } 33 | return legacyLoadMessageType(reflect.TypeOf(m), name) 34 | } 35 | 36 | // UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input. 37 | // The input can either be a string representing the enum value by name, 38 | // or a number representing the enum number itself. 39 | func (Export) UnmarshalJSONEnum(ed protoreflect.EnumDescriptor, b []byte) (protoreflect.EnumNumber, error) { 40 | if b[0] == '"' { 41 | var name protoreflect.Name 42 | if err := json.Unmarshal(b, &name); err != nil { 43 | return 0, errors.New("invalid input for enum %v: %s", ed.FullName(), b) 44 | } 45 | ev := ed.Values().ByName(name) 46 | if ev == nil { 47 | return 0, errors.New("invalid value for enum %v: %s", ed.FullName(), name) 48 | } 49 | return ev.Number(), nil 50 | } else { 51 | var num protoreflect.EnumNumber 52 | if err := json.Unmarshal(b, &num); err != nil { 53 | return 0, errors.New("invalid input for enum %v: %s", ed.FullName(), b) 54 | } 55 | return num, nil 56 | } 57 | } 58 | 59 | // CompressGZIP compresses the input as a GZIP-encoded file. 60 | // The current implementation does no compression. 61 | func (Export) CompressGZIP(in []byte) (out []byte) { 62 | // RFC 1952, section 2.3.1. 63 | var gzipHeader = [10]byte{0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff} 64 | 65 | // RFC 1951, section 3.2.4. 66 | var blockHeader [5]byte 67 | const maxBlockSize = math.MaxUint16 68 | numBlocks := 1 + len(in)/maxBlockSize 69 | 70 | // RFC 1952, section 2.3.1. 71 | var gzipFooter [8]byte 72 | binary.LittleEndian.PutUint32(gzipFooter[0:4], crc32.ChecksumIEEE(in)) 73 | binary.LittleEndian.PutUint32(gzipFooter[4:8], uint32(len(in))) 74 | 75 | // Encode the input without compression using raw DEFLATE blocks. 76 | out = make([]byte, 0, len(gzipHeader)+len(blockHeader)*numBlocks+len(in)+len(gzipFooter)) 77 | out = append(out, gzipHeader[:]...) 78 | for blockHeader[0] == 0 { 79 | blockSize := maxBlockSize 80 | if blockSize > len(in) { 81 | blockHeader[0] = 0x01 // final bit per RFC 1951, section 3.2.3. 82 | blockSize = len(in) 83 | } 84 | binary.LittleEndian.PutUint16(blockHeader[1:3], uint16(blockSize)) 85 | binary.LittleEndian.PutUint16(blockHeader[3:5], ^uint16(blockSize)) 86 | out = append(out, blockHeader[:]...) 87 | out = append(out, in[:blockSize]...) 88 | in = in[blockSize:] 89 | } 90 | out = append(out, gzipFooter[:]...) 91 | return out 92 | } 93 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "bytes" 9 | "compress/gzip" 10 | "io" 11 | "sync" 12 | 13 | "google.golang.org/protobuf/internal/filedesc" 14 | "google.golang.org/protobuf/reflect/protoreflect" 15 | "google.golang.org/protobuf/reflect/protoregistry" 16 | ) 17 | 18 | // Every enum and message type generated by protoc-gen-go since commit 2fc053c5 19 | // on February 25th, 2016 has had a method to get the raw descriptor. 20 | // Types that were not generated by protoc-gen-go or were generated prior 21 | // to that version are not supported. 22 | // 23 | // The []byte returned is the encoded form of a FileDescriptorProto message 24 | // compressed using GZIP. The []int is the path from the top-level file 25 | // to the specific message or enum declaration. 26 | type ( 27 | enumV1 interface { 28 | EnumDescriptor() ([]byte, []int) 29 | } 30 | messageV1 interface { 31 | Descriptor() ([]byte, []int) 32 | } 33 | ) 34 | 35 | var legacyFileDescCache sync.Map // map[*byte]protoreflect.FileDescriptor 36 | 37 | // legacyLoadFileDesc unmarshals b as a compressed FileDescriptorProto message. 38 | // 39 | // This assumes that b is immutable and that b does not refer to part of a 40 | // concatenated series of GZIP files (which would require shenanigans that 41 | // rely on the concatenation properties of both protobufs and GZIP). 42 | // File descriptors generated by protoc-gen-go do not rely on that property. 43 | func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor { 44 | // Fast-path: check whether we already have a cached file descriptor. 45 | if fd, ok := legacyFileDescCache.Load(&b[0]); ok { 46 | return fd.(protoreflect.FileDescriptor) 47 | } 48 | 49 | // Slow-path: decompress and unmarshal the file descriptor proto. 50 | zr, err := gzip.NewReader(bytes.NewReader(b)) 51 | if err != nil { 52 | panic(err) 53 | } 54 | b2, err := io.ReadAll(zr) 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | fd := filedesc.Builder{ 60 | RawDescriptor: b2, 61 | FileRegistry: resolverOnly{protoregistry.GlobalFiles}, // do not register back to global registry 62 | }.Build().File 63 | if fd, ok := legacyFileDescCache.LoadOrStore(&b[0], fd); ok { 64 | return fd.(protoreflect.FileDescriptor) 65 | } 66 | return fd 67 | } 68 | 69 | type resolverOnly struct { 70 | reg *protoregistry.Files 71 | } 72 | 73 | func (r resolverOnly) FindFileByPath(path string) (protoreflect.FileDescriptor, error) { 74 | return r.reg.FindFileByPath(path) 75 | } 76 | func (r resolverOnly) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { 77 | return r.reg.FindDescriptorByName(name) 78 | } 79 | func (resolverOnly) RegisterFile(protoreflect.FileDescriptor) error { 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/impl/weak.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "fmt" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | "google.golang.org/protobuf/reflect/protoregistry" 12 | ) 13 | 14 | // weakFields adds methods to the exported WeakFields type for internal use. 15 | // 16 | // The exported type is an alias to an unnamed type, so methods can't be 17 | // defined directly on it. 18 | type weakFields WeakFields 19 | 20 | func (w weakFields) get(num protoreflect.FieldNumber) (protoreflect.ProtoMessage, bool) { 21 | m, ok := w[int32(num)] 22 | return m, ok 23 | } 24 | 25 | func (w *weakFields) set(num protoreflect.FieldNumber, m protoreflect.ProtoMessage) { 26 | if *w == nil { 27 | *w = make(weakFields) 28 | } 29 | (*w)[int32(num)] = m 30 | } 31 | 32 | func (w *weakFields) clear(num protoreflect.FieldNumber) { 33 | delete(*w, int32(num)) 34 | } 35 | 36 | func (Export) HasWeak(w WeakFields, num protoreflect.FieldNumber) bool { 37 | _, ok := w[int32(num)] 38 | return ok 39 | } 40 | 41 | func (Export) ClearWeak(w *WeakFields, num protoreflect.FieldNumber) { 42 | delete(*w, int32(num)) 43 | } 44 | 45 | func (Export) GetWeak(w WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName) protoreflect.ProtoMessage { 46 | if m, ok := w[int32(num)]; ok { 47 | return m 48 | } 49 | mt, _ := protoregistry.GlobalTypes.FindMessageByName(name) 50 | if mt == nil { 51 | panic(fmt.Sprintf("message %v for weak field is not linked in", name)) 52 | } 53 | return mt.Zero().Interface() 54 | } 55 | 56 | func (Export) SetWeak(w *WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName, m protoreflect.ProtoMessage) { 57 | if m != nil { 58 | mt, _ := protoregistry.GlobalTypes.FindMessageByName(name) 59 | if mt == nil { 60 | panic(fmt.Sprintf("message %v for weak field is not linked in", name)) 61 | } 62 | if mt != m.ProtoReflect().Type() { 63 | panic(fmt.Sprintf("invalid message type for weak field: got %T, want %T", m, mt.Zero().Interface())) 64 | } 65 | } 66 | if m == nil || !m.ProtoReflect().IsValid() { 67 | delete(*w, int32(num)) 68 | return 69 | } 70 | if *w == nil { 71 | *w = make(weakFields) 72 | } 73 | (*w)[int32(num)] = m 74 | } 75 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/order/order.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package order 6 | 7 | import ( 8 | "google.golang.org/protobuf/reflect/protoreflect" 9 | ) 10 | 11 | // FieldOrder specifies the ordering to visit message fields. 12 | // It is a function that reports whether x is ordered before y. 13 | type FieldOrder func(x, y protoreflect.FieldDescriptor) bool 14 | 15 | var ( 16 | // AnyFieldOrder specifies no specific field ordering. 17 | AnyFieldOrder FieldOrder = nil 18 | 19 | // LegacyFieldOrder sorts fields in the same ordering as emitted by 20 | // wire serialization in the github.com/golang/protobuf implementation. 21 | LegacyFieldOrder FieldOrder = func(x, y protoreflect.FieldDescriptor) bool { 22 | ox, oy := x.ContainingOneof(), y.ContainingOneof() 23 | inOneof := func(od protoreflect.OneofDescriptor) bool { 24 | return od != nil && !od.IsSynthetic() 25 | } 26 | 27 | // Extension fields sort before non-extension fields. 28 | if x.IsExtension() != y.IsExtension() { 29 | return x.IsExtension() && !y.IsExtension() 30 | } 31 | // Fields not within a oneof sort before those within a oneof. 32 | if inOneof(ox) != inOneof(oy) { 33 | return !inOneof(ox) && inOneof(oy) 34 | } 35 | // Fields in disjoint oneof sets are sorted by declaration index. 36 | if inOneof(ox) && inOneof(oy) && ox != oy { 37 | return ox.Index() < oy.Index() 38 | } 39 | // Fields sorted by field number. 40 | return x.Number() < y.Number() 41 | } 42 | 43 | // NumberFieldOrder sorts fields by their field number. 44 | NumberFieldOrder FieldOrder = func(x, y protoreflect.FieldDescriptor) bool { 45 | return x.Number() < y.Number() 46 | } 47 | 48 | // IndexNameFieldOrder sorts non-extension fields before extension fields. 49 | // Non-extensions are sorted according to their declaration index. 50 | // Extensions are sorted according to their full name. 51 | IndexNameFieldOrder FieldOrder = func(x, y protoreflect.FieldDescriptor) bool { 52 | // Non-extension fields sort before extension fields. 53 | if x.IsExtension() != y.IsExtension() { 54 | return !x.IsExtension() && y.IsExtension() 55 | } 56 | // Extensions sorted by fullname. 57 | if x.IsExtension() && y.IsExtension() { 58 | return x.FullName() < y.FullName() 59 | } 60 | // Non-extensions sorted by declaration index. 61 | return x.Index() < y.Index() 62 | } 63 | ) 64 | 65 | // KeyOrder specifies the ordering to visit map entries. 66 | // It is a function that reports whether x is ordered before y. 67 | type KeyOrder func(x, y protoreflect.MapKey) bool 68 | 69 | var ( 70 | // AnyKeyOrder specifies no specific key ordering. 71 | AnyKeyOrder KeyOrder = nil 72 | 73 | // GenericKeyOrder sorts false before true, numeric keys in ascending order, 74 | // and strings in lexicographical ordering according to UTF-8 codepoints. 75 | GenericKeyOrder KeyOrder = func(x, y protoreflect.MapKey) bool { 76 | switch x.Interface().(type) { 77 | case bool: 78 | return !x.Bool() && y.Bool() 79 | case int32, int64: 80 | return x.Int() < y.Int() 81 | case uint32, uint64: 82 | return x.Uint() < y.Uint() 83 | case string: 84 | return x.String() < y.String() 85 | default: 86 | panic("invalid map key type") 87 | } 88 | } 89 | ) 90 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/order/range.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package order provides ordered access to messages and maps. 6 | package order 7 | 8 | import ( 9 | "sort" 10 | "sync" 11 | 12 | "google.golang.org/protobuf/reflect/protoreflect" 13 | ) 14 | 15 | type messageField struct { 16 | fd protoreflect.FieldDescriptor 17 | v protoreflect.Value 18 | } 19 | 20 | var messageFieldPool = sync.Pool{ 21 | New: func() any { return new([]messageField) }, 22 | } 23 | 24 | type ( 25 | // FieldRnger is an interface for visiting all fields in a message. 26 | // The protoreflect.Message type implements this interface. 27 | FieldRanger interface{ Range(VisitField) } 28 | // VisitField is called every time a message field is visited. 29 | VisitField = func(protoreflect.FieldDescriptor, protoreflect.Value) bool 30 | ) 31 | 32 | // RangeFields iterates over the fields of fs according to the specified order. 33 | func RangeFields(fs FieldRanger, less FieldOrder, fn VisitField) { 34 | if less == nil { 35 | fs.Range(fn) 36 | return 37 | } 38 | 39 | // Obtain a pre-allocated scratch buffer. 40 | p := messageFieldPool.Get().(*[]messageField) 41 | fields := (*p)[:0] 42 | defer func() { 43 | if cap(fields) < 1024 { 44 | *p = fields 45 | messageFieldPool.Put(p) 46 | } 47 | }() 48 | 49 | // Collect all fields in the message and sort them. 50 | fs.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 51 | fields = append(fields, messageField{fd, v}) 52 | return true 53 | }) 54 | sort.Slice(fields, func(i, j int) bool { 55 | return less(fields[i].fd, fields[j].fd) 56 | }) 57 | 58 | // Visit the fields in the specified ordering. 59 | for _, f := range fields { 60 | if !fn(f.fd, f.v) { 61 | return 62 | } 63 | } 64 | } 65 | 66 | type mapEntry struct { 67 | k protoreflect.MapKey 68 | v protoreflect.Value 69 | } 70 | 71 | var mapEntryPool = sync.Pool{ 72 | New: func() any { return new([]mapEntry) }, 73 | } 74 | 75 | type ( 76 | // EntryRanger is an interface for visiting all fields in a message. 77 | // The protoreflect.Map type implements this interface. 78 | EntryRanger interface{ Range(VisitEntry) } 79 | // VisitEntry is called every time a map entry is visited. 80 | VisitEntry = func(protoreflect.MapKey, protoreflect.Value) bool 81 | ) 82 | 83 | // RangeEntries iterates over the entries of es according to the specified order. 84 | func RangeEntries(es EntryRanger, less KeyOrder, fn VisitEntry) { 85 | if less == nil { 86 | es.Range(fn) 87 | return 88 | } 89 | 90 | // Obtain a pre-allocated scratch buffer. 91 | p := mapEntryPool.Get().(*[]mapEntry) 92 | entries := (*p)[:0] 93 | defer func() { 94 | if cap(entries) < 1024 { 95 | *p = entries 96 | mapEntryPool.Put(p) 97 | } 98 | }() 99 | 100 | // Collect all entries in the map and sort them. 101 | es.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool { 102 | entries = append(entries, mapEntry{k, v}) 103 | return true 104 | }) 105 | sort.Slice(entries, func(i, j int) bool { 106 | return less(entries[i].k, entries[j].k) 107 | }) 108 | 109 | // Visit the entries in the specified ordering. 110 | for _, e := range entries { 111 | if !fn(e.k, e.v) { 112 | return 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/pragma/pragma.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package pragma provides types that can be embedded into a struct to 6 | // statically enforce or prevent certain language properties. 7 | package pragma 8 | 9 | import "sync" 10 | 11 | // NoUnkeyedLiterals can be embedded in a struct to prevent unkeyed literals. 12 | type NoUnkeyedLiterals struct{} 13 | 14 | // DoNotImplement can be embedded in an interface to prevent trivial 15 | // implementations of the interface. 16 | // 17 | // This is useful to prevent unauthorized implementations of an interface 18 | // so that it can be extended in the future for any protobuf language changes. 19 | type DoNotImplement interface{ ProtoInternal(DoNotImplement) } 20 | 21 | // DoNotCompare can be embedded in a struct to prevent comparability. 22 | type DoNotCompare [0]func() 23 | 24 | // DoNotCopy can be embedded in a struct to help prevent shallow copies. 25 | // This does not rely on a Go language feature, but rather a special case 26 | // within the vet checker. 27 | // 28 | // See https://golang.org/issues/8005. 29 | type DoNotCopy [0]sync.Mutex 30 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/set/ints.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package set provides simple set data structures for uint64s. 6 | package set 7 | 8 | import "math/bits" 9 | 10 | // int64s represents a set of integers within the range of 0..63. 11 | type int64s uint64 12 | 13 | func (bs *int64s) Len() int { 14 | return bits.OnesCount64(uint64(*bs)) 15 | } 16 | func (bs *int64s) Has(n uint64) bool { 17 | return uint64(*bs)&(uint64(1)< 0 18 | } 19 | func (bs *int64s) Set(n uint64) { 20 | *(*uint64)(bs) |= uint64(1) << n 21 | } 22 | func (bs *int64s) Clear(n uint64) { 23 | *(*uint64)(bs) &^= uint64(1) << n 24 | } 25 | 26 | // Ints represents a set of integers within the range of 0..math.MaxUint64. 27 | type Ints struct { 28 | lo int64s 29 | hi map[uint64]struct{} 30 | } 31 | 32 | func (bs *Ints) Len() int { 33 | return bs.lo.Len() + len(bs.hi) 34 | } 35 | func (bs *Ints) Has(n uint64) bool { 36 | if n < 64 { 37 | return bs.lo.Has(n) 38 | } 39 | _, ok := bs.hi[n] 40 | return ok 41 | } 42 | func (bs *Ints) Set(n uint64) { 43 | if n < 64 { 44 | bs.lo.Set(n) 45 | return 46 | } 47 | if bs.hi == nil { 48 | bs.hi = make(map[uint64]struct{}) 49 | } 50 | bs.hi[n] = struct{}{} 51 | } 52 | func (bs *Ints) Clear(n uint64) { 53 | if n < 64 { 54 | bs.lo.Clear(n) 55 | return 56 | } 57 | delete(bs.hi, n) 58 | } 59 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build purego || appengine 6 | // +build purego appengine 7 | 8 | package strs 9 | 10 | import pref "google.golang.org/protobuf/reflect/protoreflect" 11 | 12 | func UnsafeString(b []byte) string { 13 | return string(b) 14 | } 15 | 16 | func UnsafeBytes(s string) []byte { 17 | return []byte(s) 18 | } 19 | 20 | type Builder struct{} 21 | 22 | func (*Builder) AppendFullName(prefix pref.FullName, name pref.Name) pref.FullName { 23 | return prefix.Append(name) 24 | } 25 | 26 | func (*Builder) MakeString(b []byte) string { 27 | return string(b) 28 | } 29 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go120.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine && !go1.21 6 | // +build !purego,!appengine,!go1.21 7 | 8 | package strs 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "google.golang.org/protobuf/reflect/protoreflect" 14 | ) 15 | 16 | type ( 17 | stringHeader struct { 18 | Data unsafe.Pointer 19 | Len int 20 | } 21 | sliceHeader struct { 22 | Data unsafe.Pointer 23 | Len int 24 | Cap int 25 | } 26 | ) 27 | 28 | // UnsafeString returns an unsafe string reference of b. 29 | // The caller must treat the input slice as immutable. 30 | // 31 | // WARNING: Use carefully. The returned result must not leak to the end user 32 | // unless the input slice is provably immutable. 33 | func UnsafeString(b []byte) (s string) { 34 | src := (*sliceHeader)(unsafe.Pointer(&b)) 35 | dst := (*stringHeader)(unsafe.Pointer(&s)) 36 | dst.Data = src.Data 37 | dst.Len = src.Len 38 | return s 39 | } 40 | 41 | // UnsafeBytes returns an unsafe bytes slice reference of s. 42 | // The caller must treat returned slice as immutable. 43 | // 44 | // WARNING: Use carefully. The returned result must not leak to the end user. 45 | func UnsafeBytes(s string) (b []byte) { 46 | src := (*stringHeader)(unsafe.Pointer(&s)) 47 | dst := (*sliceHeader)(unsafe.Pointer(&b)) 48 | dst.Data = src.Data 49 | dst.Len = src.Len 50 | dst.Cap = src.Len 51 | return b 52 | } 53 | 54 | // Builder builds a set of strings with shared lifetime. 55 | // This differs from strings.Builder, which is for building a single string. 56 | type Builder struct { 57 | buf []byte 58 | } 59 | 60 | // AppendFullName is equivalent to protoreflect.FullName.Append, 61 | // but optimized for large batches where each name has a shared lifetime. 62 | func (sb *Builder) AppendFullName(prefix protoreflect.FullName, name protoreflect.Name) protoreflect.FullName { 63 | n := len(prefix) + len(".") + len(name) 64 | if len(prefix) == 0 { 65 | n -= len(".") 66 | } 67 | sb.grow(n) 68 | sb.buf = append(sb.buf, prefix...) 69 | sb.buf = append(sb.buf, '.') 70 | sb.buf = append(sb.buf, name...) 71 | return protoreflect.FullName(sb.last(n)) 72 | } 73 | 74 | // MakeString is equivalent to string(b), but optimized for large batches 75 | // with a shared lifetime. 76 | func (sb *Builder) MakeString(b []byte) string { 77 | sb.grow(len(b)) 78 | sb.buf = append(sb.buf, b...) 79 | return sb.last(len(b)) 80 | } 81 | 82 | func (sb *Builder) grow(n int) { 83 | if cap(sb.buf)-len(sb.buf) >= n { 84 | return 85 | } 86 | 87 | // Unlike strings.Builder, we do not need to copy over the contents 88 | // of the old buffer since our builder provides no API for 89 | // retrieving previously created strings. 90 | sb.buf = make([]byte, 0, 2*(cap(sb.buf)+n)) 91 | } 92 | 93 | func (sb *Builder) last(n int) string { 94 | return UnsafeString(sb.buf[len(sb.buf)-n:]) 95 | } 96 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go121.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine && go1.21 6 | // +build !purego,!appengine,go1.21 7 | 8 | package strs 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "google.golang.org/protobuf/reflect/protoreflect" 14 | ) 15 | 16 | // UnsafeString returns an unsafe string reference of b. 17 | // The caller must treat the input slice as immutable. 18 | // 19 | // WARNING: Use carefully. The returned result must not leak to the end user 20 | // unless the input slice is provably immutable. 21 | func UnsafeString(b []byte) string { 22 | return unsafe.String(unsafe.SliceData(b), len(b)) 23 | } 24 | 25 | // UnsafeBytes returns an unsafe bytes slice reference of s. 26 | // The caller must treat returned slice as immutable. 27 | // 28 | // WARNING: Use carefully. The returned result must not leak to the end user. 29 | func UnsafeBytes(s string) []byte { 30 | return unsafe.Slice(unsafe.StringData(s), len(s)) 31 | } 32 | 33 | // Builder builds a set of strings with shared lifetime. 34 | // This differs from strings.Builder, which is for building a single string. 35 | type Builder struct { 36 | buf []byte 37 | } 38 | 39 | // AppendFullName is equivalent to protoreflect.FullName.Append, 40 | // but optimized for large batches where each name has a shared lifetime. 41 | func (sb *Builder) AppendFullName(prefix protoreflect.FullName, name protoreflect.Name) protoreflect.FullName { 42 | n := len(prefix) + len(".") + len(name) 43 | if len(prefix) == 0 { 44 | n -= len(".") 45 | } 46 | sb.grow(n) 47 | sb.buf = append(sb.buf, prefix...) 48 | sb.buf = append(sb.buf, '.') 49 | sb.buf = append(sb.buf, name...) 50 | return protoreflect.FullName(sb.last(n)) 51 | } 52 | 53 | // MakeString is equivalent to string(b), but optimized for large batches 54 | // with a shared lifetime. 55 | func (sb *Builder) MakeString(b []byte) string { 56 | sb.grow(len(b)) 57 | sb.buf = append(sb.buf, b...) 58 | return sb.last(len(b)) 59 | } 60 | 61 | func (sb *Builder) grow(n int) { 62 | if cap(sb.buf)-len(sb.buf) >= n { 63 | return 64 | } 65 | 66 | // Unlike strings.Builder, we do not need to copy over the contents 67 | // of the old buffer since our builder provides no API for 68 | // retrieving previously created strings. 69 | sb.buf = make([]byte, 0, 2*(cap(sb.buf)+n)) 70 | } 71 | 72 | func (sb *Builder) last(n int) string { 73 | return UnsafeString(sb.buf[len(sb.buf)-n:]) 74 | } 75 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/internal/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package version records versioning information about this module. 6 | package version 7 | 8 | import ( 9 | "fmt" 10 | "strings" 11 | ) 12 | 13 | // These constants determine the current version of this module. 14 | // 15 | // For our release process, we enforce the following rules: 16 | // - Tagged releases use a tag that is identical to String. 17 | // - Tagged releases never reference a commit where the String 18 | // contains "devel". 19 | // - The set of all commits in this repository where String 20 | // does not contain "devel" must have a unique String. 21 | // 22 | // Steps for tagging a new release: 23 | // 24 | // 1. Create a new CL. 25 | // 26 | // 2. Update Minor, Patch, and/or PreRelease as necessary. 27 | // PreRelease must not contain the string "devel". 28 | // 29 | // 3. Since the last released minor version, have there been any changes to 30 | // generator that relies on new functionality in the runtime? 31 | // If yes, then increment RequiredGenerated. 32 | // 33 | // 4. Since the last released minor version, have there been any changes to 34 | // the runtime that removes support for old .pb.go source code? 35 | // If yes, then increment SupportMinimum. 36 | // 37 | // 5. Send out the CL for review and submit it. 38 | // Note that the next CL in step 8 must be submitted after this CL 39 | // without any other CLs in-between. 40 | // 41 | // 6. Tag a new version, where the tag is is the current String. 42 | // 43 | // 7. Write release notes for all notable changes 44 | // between this release and the last release. 45 | // 46 | // 8. Create a new CL. 47 | // 48 | // 9. Update PreRelease to include the string "devel". 49 | // For example: "" -> "devel" or "rc.1" -> "rc.1.devel" 50 | // 51 | // 10. Send out the CL for review and submit it. 52 | const ( 53 | Major = 1 54 | Minor = 34 55 | Patch = 2 56 | PreRelease = "" 57 | ) 58 | 59 | // String formats the version string for this module in semver format. 60 | // 61 | // Examples: 62 | // 63 | // v1.20.1 64 | // v1.21.0-rc.1 65 | func String() string { 66 | v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch) 67 | if PreRelease != "" { 68 | v += "-" + PreRelease 69 | 70 | // TODO: Add metadata about the commit or build hash. 71 | // See https://golang.org/issue/29814 72 | // See https://golang.org/issue/33533 73 | var metadata string 74 | if strings.Contains(PreRelease, "devel") && metadata != "" { 75 | v += "+" + metadata 76 | } 77 | } 78 | return v 79 | } 80 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/checkinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "google.golang.org/protobuf/internal/errors" 9 | "google.golang.org/protobuf/reflect/protoreflect" 10 | "google.golang.org/protobuf/runtime/protoiface" 11 | ) 12 | 13 | // CheckInitialized returns an error if any required fields in m are not set. 14 | func CheckInitialized(m Message) error { 15 | // Treat a nil message interface as an "untyped" empty message, 16 | // which we assume to have no required fields. 17 | if m == nil { 18 | return nil 19 | } 20 | 21 | return checkInitialized(m.ProtoReflect()) 22 | } 23 | 24 | // CheckInitialized returns an error if any required fields in m are not set. 25 | func checkInitialized(m protoreflect.Message) error { 26 | if methods := protoMethods(m); methods != nil && methods.CheckInitialized != nil { 27 | _, err := methods.CheckInitialized(protoiface.CheckInitializedInput{ 28 | Message: m, 29 | }) 30 | return err 31 | } 32 | return checkInitializedSlow(m) 33 | } 34 | 35 | func checkInitializedSlow(m protoreflect.Message) error { 36 | md := m.Descriptor() 37 | fds := md.Fields() 38 | for i, nums := 0, md.RequiredNumbers(); i < nums.Len(); i++ { 39 | fd := fds.ByNumber(nums.Get(i)) 40 | if !m.Has(fd) { 41 | return errors.RequiredNotSet(string(fd.FullName())) 42 | } 43 | } 44 | var err error 45 | m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 46 | switch { 47 | case fd.IsList(): 48 | if fd.Message() == nil { 49 | return true 50 | } 51 | for i, list := 0, v.List(); i < list.Len() && err == nil; i++ { 52 | err = checkInitialized(list.Get(i).Message()) 53 | } 54 | case fd.IsMap(): 55 | if fd.MapValue().Message() == nil { 56 | return true 57 | } 58 | v.Map().Range(func(key protoreflect.MapKey, v protoreflect.Value) bool { 59 | err = checkInitialized(v.Message()) 60 | return err == nil 61 | }) 62 | default: 63 | if fd.Message() == nil { 64 | return true 65 | } 66 | err = checkInitialized(v.Message()) 67 | } 68 | return err == nil 69 | }) 70 | return err 71 | } 72 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package proto provides functions operating on protocol buffer messages. 6 | // 7 | // For documentation on protocol buffers in general, see: 8 | // https://protobuf.dev. 9 | // 10 | // For a tutorial on using protocol buffers with Go, see: 11 | // https://protobuf.dev/getting-started/gotutorial. 12 | // 13 | // For a guide to generated Go protocol buffer code, see: 14 | // https://protobuf.dev/reference/go/go-generated. 15 | // 16 | // # Binary serialization 17 | // 18 | // This package contains functions to convert to and from the wire format, 19 | // an efficient binary serialization of protocol buffers. 20 | // 21 | // - [Size] reports the size of a message in the wire format. 22 | // 23 | // - [Marshal] converts a message to the wire format. 24 | // The [MarshalOptions] type provides more control over wire marshaling. 25 | // 26 | // - [Unmarshal] converts a message from the wire format. 27 | // The [UnmarshalOptions] type provides more control over wire unmarshaling. 28 | // 29 | // # Basic message operations 30 | // 31 | // - [Clone] makes a deep copy of a message. 32 | // 33 | // - [Merge] merges the content of a message into another. 34 | // 35 | // - [Equal] compares two messages. For more control over comparisons 36 | // and detailed reporting of differences, see package 37 | // [google.golang.org/protobuf/testing/protocmp]. 38 | // 39 | // - [Reset] clears the content of a message. 40 | // 41 | // - [CheckInitialized] reports whether all required fields in a message are set. 42 | // 43 | // # Optional scalar constructors 44 | // 45 | // The API for some generated messages represents optional scalar fields 46 | // as pointers to a value. For example, an optional string field has the 47 | // Go type *string. 48 | // 49 | // - [Bool], [Int32], [Int64], [Uint32], [Uint64], [Float32], [Float64], and [String] 50 | // take a value and return a pointer to a new instance of it, 51 | // to simplify construction of optional field values. 52 | // 53 | // Generated enum types usually have an Enum method which performs the 54 | // same operation. 55 | // 56 | // Optional scalar fields are only supported in proto2. 57 | // 58 | // # Extension accessors 59 | // 60 | // - [HasExtension], [GetExtension], [SetExtension], and [ClearExtension] 61 | // access extension field values in a protocol buffer message. 62 | // 63 | // Extension fields are only supported in proto2. 64 | // 65 | // # Related packages 66 | // 67 | // - Package [google.golang.org/protobuf/encoding/protojson] converts messages to 68 | // and from JSON. 69 | // 70 | // - Package [google.golang.org/protobuf/encoding/prototext] converts messages to 71 | // and from the text format. 72 | // 73 | // - Package [google.golang.org/protobuf/reflect/protoreflect] provides a 74 | // reflection interface for protocol buffer data types. 75 | // 76 | // - Package [google.golang.org/protobuf/testing/protocmp] provides features 77 | // to compare protocol buffer messages with the [github.com/google/go-cmp/cmp] 78 | // package. 79 | // 80 | // - Package [google.golang.org/protobuf/types/dynamicpb] provides a dynamic 81 | // message type, suitable for working with messages where the protocol buffer 82 | // type is only known at runtime. 83 | // 84 | // This module contains additional packages for more specialized use cases. 85 | // Consult the individual package documentation for details. 86 | package proto 87 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/encode_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-types. DO NOT EDIT. 6 | 7 | package proto 8 | 9 | import ( 10 | "math" 11 | "unicode/utf8" 12 | 13 | "google.golang.org/protobuf/encoding/protowire" 14 | "google.golang.org/protobuf/internal/errors" 15 | "google.golang.org/protobuf/internal/strs" 16 | "google.golang.org/protobuf/reflect/protoreflect" 17 | ) 18 | 19 | var wireTypes = map[protoreflect.Kind]protowire.Type{ 20 | protoreflect.BoolKind: protowire.VarintType, 21 | protoreflect.EnumKind: protowire.VarintType, 22 | protoreflect.Int32Kind: protowire.VarintType, 23 | protoreflect.Sint32Kind: protowire.VarintType, 24 | protoreflect.Uint32Kind: protowire.VarintType, 25 | protoreflect.Int64Kind: protowire.VarintType, 26 | protoreflect.Sint64Kind: protowire.VarintType, 27 | protoreflect.Uint64Kind: protowire.VarintType, 28 | protoreflect.Sfixed32Kind: protowire.Fixed32Type, 29 | protoreflect.Fixed32Kind: protowire.Fixed32Type, 30 | protoreflect.FloatKind: protowire.Fixed32Type, 31 | protoreflect.Sfixed64Kind: protowire.Fixed64Type, 32 | protoreflect.Fixed64Kind: protowire.Fixed64Type, 33 | protoreflect.DoubleKind: protowire.Fixed64Type, 34 | protoreflect.StringKind: protowire.BytesType, 35 | protoreflect.BytesKind: protowire.BytesType, 36 | protoreflect.MessageKind: protowire.BytesType, 37 | protoreflect.GroupKind: protowire.StartGroupType, 38 | } 39 | 40 | func (o MarshalOptions) marshalSingular(b []byte, fd protoreflect.FieldDescriptor, v protoreflect.Value) ([]byte, error) { 41 | switch fd.Kind() { 42 | case protoreflect.BoolKind: 43 | b = protowire.AppendVarint(b, protowire.EncodeBool(v.Bool())) 44 | case protoreflect.EnumKind: 45 | b = protowire.AppendVarint(b, uint64(v.Enum())) 46 | case protoreflect.Int32Kind: 47 | b = protowire.AppendVarint(b, uint64(int32(v.Int()))) 48 | case protoreflect.Sint32Kind: 49 | b = protowire.AppendVarint(b, protowire.EncodeZigZag(int64(int32(v.Int())))) 50 | case protoreflect.Uint32Kind: 51 | b = protowire.AppendVarint(b, uint64(uint32(v.Uint()))) 52 | case protoreflect.Int64Kind: 53 | b = protowire.AppendVarint(b, uint64(v.Int())) 54 | case protoreflect.Sint64Kind: 55 | b = protowire.AppendVarint(b, protowire.EncodeZigZag(v.Int())) 56 | case protoreflect.Uint64Kind: 57 | b = protowire.AppendVarint(b, v.Uint()) 58 | case protoreflect.Sfixed32Kind: 59 | b = protowire.AppendFixed32(b, uint32(v.Int())) 60 | case protoreflect.Fixed32Kind: 61 | b = protowire.AppendFixed32(b, uint32(v.Uint())) 62 | case protoreflect.FloatKind: 63 | b = protowire.AppendFixed32(b, math.Float32bits(float32(v.Float()))) 64 | case protoreflect.Sfixed64Kind: 65 | b = protowire.AppendFixed64(b, uint64(v.Int())) 66 | case protoreflect.Fixed64Kind: 67 | b = protowire.AppendFixed64(b, v.Uint()) 68 | case protoreflect.DoubleKind: 69 | b = protowire.AppendFixed64(b, math.Float64bits(v.Float())) 70 | case protoreflect.StringKind: 71 | if strs.EnforceUTF8(fd) && !utf8.ValidString(v.String()) { 72 | return b, errors.InvalidUTF8(string(fd.FullName())) 73 | } 74 | b = protowire.AppendString(b, v.String()) 75 | case protoreflect.BytesKind: 76 | b = protowire.AppendBytes(b, v.Bytes()) 77 | case protoreflect.MessageKind: 78 | var pos int 79 | var err error 80 | b, pos = appendSpeculativeLength(b) 81 | b, err = o.marshalMessage(b, v.Message()) 82 | if err != nil { 83 | return b, err 84 | } 85 | b = finishSpeculativeLength(b, pos) 86 | case protoreflect.GroupKind: 87 | var err error 88 | b, err = o.marshalMessage(b, v.Message()) 89 | if err != nil { 90 | return b, err 91 | } 92 | b = protowire.AppendVarint(b, protowire.EncodeTag(fd.Number(), protowire.EndGroupType)) 93 | default: 94 | return b, errors.New("invalid kind %v", fd.Kind()) 95 | } 96 | return b, nil 97 | } 98 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "reflect" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | // Equal reports whether two messages are equal, 14 | // by recursively comparing the fields of the message. 15 | // 16 | // - Bytes fields are equal if they contain identical bytes. 17 | // Empty bytes (regardless of nil-ness) are considered equal. 18 | // 19 | // - Floating-point fields are equal if they contain the same value. 20 | // Unlike the == operator, a NaN is equal to another NaN. 21 | // 22 | // - Other scalar fields are equal if they contain the same value. 23 | // 24 | // - Message fields are equal if they have 25 | // the same set of populated known and extension field values, and 26 | // the same set of unknown fields values. 27 | // 28 | // - Lists are equal if they are the same length and 29 | // each corresponding element is equal. 30 | // 31 | // - Maps are equal if they have the same set of keys and 32 | // the corresponding value for each key is equal. 33 | // 34 | // An invalid message is not equal to a valid message. 35 | // An invalid message is only equal to another invalid message of the 36 | // same type. An invalid message often corresponds to a nil pointer 37 | // of the concrete message type. For example, (*pb.M)(nil) is not equal 38 | // to &pb.M{}. 39 | // If two valid messages marshal to the same bytes under deterministic 40 | // serialization, then Equal is guaranteed to report true. 41 | func Equal(x, y Message) bool { 42 | if x == nil || y == nil { 43 | return x == nil && y == nil 44 | } 45 | if reflect.TypeOf(x).Kind() == reflect.Ptr && x == y { 46 | // Avoid an expensive comparison if both inputs are identical pointers. 47 | return true 48 | } 49 | mx := x.ProtoReflect() 50 | my := y.ProtoReflect() 51 | if mx.IsValid() != my.IsValid() { 52 | return false 53 | } 54 | vx := protoreflect.ValueOfMessage(mx) 55 | vy := protoreflect.ValueOfMessage(my) 56 | return vx.Equal(vy) 57 | } 58 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/extension.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "google.golang.org/protobuf/reflect/protoreflect" 9 | ) 10 | 11 | // HasExtension reports whether an extension field is populated. 12 | // It returns false if m is invalid or if xt does not extend m. 13 | func HasExtension(m Message, xt protoreflect.ExtensionType) bool { 14 | // Treat nil message interface or descriptor as an empty message; no populated 15 | // fields. 16 | if m == nil || xt == nil { 17 | return false 18 | } 19 | 20 | // As a special-case, we reports invalid or mismatching descriptors 21 | // as always not being populated (since they aren't). 22 | mr := m.ProtoReflect() 23 | xd := xt.TypeDescriptor() 24 | if mr.Descriptor() != xd.ContainingMessage() { 25 | return false 26 | } 27 | 28 | return mr.Has(xd) 29 | } 30 | 31 | // ClearExtension clears an extension field such that subsequent 32 | // [HasExtension] calls return false. 33 | // It panics if m is invalid or if xt does not extend m. 34 | func ClearExtension(m Message, xt protoreflect.ExtensionType) { 35 | m.ProtoReflect().Clear(xt.TypeDescriptor()) 36 | } 37 | 38 | // GetExtension retrieves the value for an extension field. 39 | // If the field is unpopulated, it returns the default value for 40 | // scalars and an immutable, empty value for lists or messages. 41 | // It panics if xt does not extend m. 42 | func GetExtension(m Message, xt protoreflect.ExtensionType) any { 43 | // Treat nil message interface as an empty message; return the default. 44 | if m == nil { 45 | return xt.InterfaceOf(xt.Zero()) 46 | } 47 | 48 | return xt.InterfaceOf(m.ProtoReflect().Get(xt.TypeDescriptor())) 49 | } 50 | 51 | // SetExtension stores the value of an extension field. 52 | // It panics if m is invalid, xt does not extend m, or if type of v 53 | // is invalid for the specified extension field. 54 | func SetExtension(m Message, xt protoreflect.ExtensionType, v any) { 55 | xd := xt.TypeDescriptor() 56 | pv := xt.ValueOf(v) 57 | 58 | // Specially treat an invalid list, map, or message as clear. 59 | isValid := true 60 | switch { 61 | case xd.IsList(): 62 | isValid = pv.List().IsValid() 63 | case xd.IsMap(): 64 | isValid = pv.Map().IsValid() 65 | case xd.Message() != nil: 66 | isValid = pv.Message().IsValid() 67 | } 68 | if !isValid { 69 | m.ProtoReflect().Clear(xd) 70 | return 71 | } 72 | 73 | m.ProtoReflect().Set(xd, pv) 74 | } 75 | 76 | // RangeExtensions iterates over every populated extension field in m in an 77 | // undefined order, calling f for each extension type and value encountered. 78 | // It returns immediately if f returns false. 79 | // While iterating, mutating operations may only be performed 80 | // on the current extension field. 81 | func RangeExtensions(m Message, f func(protoreflect.ExtensionType, any) bool) { 82 | // Treat nil message interface as an empty message; nothing to range over. 83 | if m == nil { 84 | return 85 | } 86 | 87 | m.ProtoReflect().Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 88 | if fd.IsExtension() { 89 | xt := fd.(protoreflect.ExtensionTypeDescriptor).Type() 90 | vi := xt.InterfaceOf(v) 91 | return f(xt, vi) 92 | } 93 | return true 94 | }) 95 | } 96 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/merge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "fmt" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | "google.golang.org/protobuf/runtime/protoiface" 12 | ) 13 | 14 | // Merge merges src into dst, which must be a message with the same descriptor. 15 | // 16 | // Populated scalar fields in src are copied to dst, while populated 17 | // singular messages in src are merged into dst by recursively calling Merge. 18 | // The elements of every list field in src is appended to the corresponded 19 | // list fields in dst. The entries of every map field in src is copied into 20 | // the corresponding map field in dst, possibly replacing existing entries. 21 | // The unknown fields of src are appended to the unknown fields of dst. 22 | // 23 | // It is semantically equivalent to unmarshaling the encoded form of src 24 | // into dst with the [UnmarshalOptions.Merge] option specified. 25 | func Merge(dst, src Message) { 26 | // TODO: Should nil src be treated as semantically equivalent to a 27 | // untyped, read-only, empty message? What about a nil dst? 28 | 29 | dstMsg, srcMsg := dst.ProtoReflect(), src.ProtoReflect() 30 | if dstMsg.Descriptor() != srcMsg.Descriptor() { 31 | if got, want := dstMsg.Descriptor().FullName(), srcMsg.Descriptor().FullName(); got != want { 32 | panic(fmt.Sprintf("descriptor mismatch: %v != %v", got, want)) 33 | } 34 | panic("descriptor mismatch") 35 | } 36 | mergeOptions{}.mergeMessage(dstMsg, srcMsg) 37 | } 38 | 39 | // Clone returns a deep copy of m. 40 | // If the top-level message is invalid, it returns an invalid message as well. 41 | func Clone(m Message) Message { 42 | // NOTE: Most usages of Clone assume the following properties: 43 | // t := reflect.TypeOf(m) 44 | // t == reflect.TypeOf(m.ProtoReflect().New().Interface()) 45 | // t == reflect.TypeOf(m.ProtoReflect().Type().Zero().Interface()) 46 | // 47 | // Embedding protobuf messages breaks this since the parent type will have 48 | // a forwarded ProtoReflect method, but the Interface method will return 49 | // the underlying embedded message type. 50 | if m == nil { 51 | return nil 52 | } 53 | src := m.ProtoReflect() 54 | if !src.IsValid() { 55 | return src.Type().Zero().Interface() 56 | } 57 | dst := src.New() 58 | mergeOptions{}.mergeMessage(dst, src) 59 | return dst.Interface() 60 | } 61 | 62 | // mergeOptions provides a namespace for merge functions, and can be 63 | // exported in the future if we add user-visible merge options. 64 | type mergeOptions struct{} 65 | 66 | func (o mergeOptions) mergeMessage(dst, src protoreflect.Message) { 67 | methods := protoMethods(dst) 68 | if methods != nil && methods.Merge != nil { 69 | in := protoiface.MergeInput{ 70 | Destination: dst, 71 | Source: src, 72 | } 73 | out := methods.Merge(in) 74 | if out.Flags&protoiface.MergeComplete != 0 { 75 | return 76 | } 77 | } 78 | 79 | if !dst.IsValid() { 80 | panic(fmt.Sprintf("cannot merge into invalid %v message", dst.Descriptor().FullName())) 81 | } 82 | 83 | src.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 84 | switch { 85 | case fd.IsList(): 86 | o.mergeList(dst.Mutable(fd).List(), v.List(), fd) 87 | case fd.IsMap(): 88 | o.mergeMap(dst.Mutable(fd).Map(), v.Map(), fd.MapValue()) 89 | case fd.Message() != nil: 90 | o.mergeMessage(dst.Mutable(fd).Message(), v.Message()) 91 | case fd.Kind() == protoreflect.BytesKind: 92 | dst.Set(fd, o.cloneBytes(v)) 93 | default: 94 | dst.Set(fd, v) 95 | } 96 | return true 97 | }) 98 | 99 | if len(src.GetUnknown()) > 0 { 100 | dst.SetUnknown(append(dst.GetUnknown(), src.GetUnknown()...)) 101 | } 102 | } 103 | 104 | func (o mergeOptions) mergeList(dst, src protoreflect.List, fd protoreflect.FieldDescriptor) { 105 | // Merge semantics appends to the end of the existing list. 106 | for i, n := 0, src.Len(); i < n; i++ { 107 | switch v := src.Get(i); { 108 | case fd.Message() != nil: 109 | dstv := dst.NewElement() 110 | o.mergeMessage(dstv.Message(), v.Message()) 111 | dst.Append(dstv) 112 | case fd.Kind() == protoreflect.BytesKind: 113 | dst.Append(o.cloneBytes(v)) 114 | default: 115 | dst.Append(v) 116 | } 117 | } 118 | } 119 | 120 | func (o mergeOptions) mergeMap(dst, src protoreflect.Map, fd protoreflect.FieldDescriptor) { 121 | // Merge semantics replaces, rather than merges into existing entries. 122 | src.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool { 123 | switch { 124 | case fd.Message() != nil: 125 | dstv := dst.NewValue() 126 | o.mergeMessage(dstv.Message(), v.Message()) 127 | dst.Set(k, dstv) 128 | case fd.Kind() == protoreflect.BytesKind: 129 | dst.Set(k, o.cloneBytes(v)) 130 | default: 131 | dst.Set(k, v) 132 | } 133 | return true 134 | }) 135 | } 136 | 137 | func (o mergeOptions) cloneBytes(v protoreflect.Value) protoreflect.Value { 138 | return protoreflect.ValueOfBytes(append([]byte{}, v.Bytes()...)) 139 | } 140 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/messageset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "google.golang.org/protobuf/encoding/protowire" 9 | "google.golang.org/protobuf/internal/encoding/messageset" 10 | "google.golang.org/protobuf/internal/errors" 11 | "google.golang.org/protobuf/internal/flags" 12 | "google.golang.org/protobuf/internal/order" 13 | "google.golang.org/protobuf/reflect/protoreflect" 14 | "google.golang.org/protobuf/reflect/protoregistry" 15 | ) 16 | 17 | func (o MarshalOptions) sizeMessageSet(m protoreflect.Message) (size int) { 18 | m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 19 | size += messageset.SizeField(fd.Number()) 20 | size += protowire.SizeTag(messageset.FieldMessage) 21 | size += protowire.SizeBytes(o.size(v.Message())) 22 | return true 23 | }) 24 | size += messageset.SizeUnknown(m.GetUnknown()) 25 | return size 26 | } 27 | 28 | func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]byte, error) { 29 | if !flags.ProtoLegacy { 30 | return b, errors.New("no support for message_set_wire_format") 31 | } 32 | fieldOrder := order.AnyFieldOrder 33 | if o.Deterministic { 34 | fieldOrder = order.NumberFieldOrder 35 | } 36 | var err error 37 | order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 38 | b, err = o.marshalMessageSetField(b, fd, v) 39 | return err == nil 40 | }) 41 | if err != nil { 42 | return b, err 43 | } 44 | return messageset.AppendUnknown(b, m.GetUnknown()) 45 | } 46 | 47 | func (o MarshalOptions) marshalMessageSetField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) { 48 | b = messageset.AppendFieldStart(b, fd.Number()) 49 | b = protowire.AppendTag(b, messageset.FieldMessage, protowire.BytesType) 50 | calculatedSize := o.Size(value.Message().Interface()) 51 | b = protowire.AppendVarint(b, uint64(calculatedSize)) 52 | before := len(b) 53 | b, err := o.marshalMessage(b, value.Message()) 54 | if err != nil { 55 | return b, err 56 | } 57 | if measuredSize := len(b) - before; calculatedSize != measuredSize { 58 | return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) 59 | } 60 | b = messageset.AppendFieldEnd(b) 61 | return b, nil 62 | } 63 | 64 | func (o UnmarshalOptions) unmarshalMessageSet(b []byte, m protoreflect.Message) error { 65 | if !flags.ProtoLegacy { 66 | return errors.New("no support for message_set_wire_format") 67 | } 68 | return messageset.Unmarshal(b, false, func(num protowire.Number, v []byte) error { 69 | err := o.unmarshalMessageSetField(m, num, v) 70 | if err == errUnknown { 71 | unknown := m.GetUnknown() 72 | unknown = protowire.AppendTag(unknown, num, protowire.BytesType) 73 | unknown = protowire.AppendBytes(unknown, v) 74 | m.SetUnknown(unknown) 75 | return nil 76 | } 77 | return err 78 | }) 79 | } 80 | 81 | func (o UnmarshalOptions) unmarshalMessageSetField(m protoreflect.Message, num protowire.Number, v []byte) error { 82 | md := m.Descriptor() 83 | if !md.ExtensionRanges().Has(num) { 84 | return errUnknown 85 | } 86 | xt, err := o.Resolver.FindExtensionByNumber(md.FullName(), num) 87 | if err == protoregistry.NotFound { 88 | return errUnknown 89 | } 90 | if err != nil { 91 | return errors.New("%v: unable to resolve extension %v: %v", md.FullName(), num, err) 92 | } 93 | xd := xt.TypeDescriptor() 94 | if err := o.unmarshalMessage(v, m.Mutable(xd).Message()); err != nil { 95 | return err 96 | } 97 | return nil 98 | } 99 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/proto.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "google.golang.org/protobuf/internal/errors" 9 | "google.golang.org/protobuf/reflect/protoreflect" 10 | ) 11 | 12 | // Message is the top-level interface that all messages must implement. 13 | // It provides access to a reflective view of a message. 14 | // Any implementation of this interface may be used with all functions in the 15 | // protobuf module that accept a Message, except where otherwise specified. 16 | // 17 | // This is the v2 interface definition for protobuf messages. 18 | // The v1 interface definition is [github.com/golang/protobuf/proto.Message]. 19 | // 20 | // - To convert a v1 message to a v2 message, 21 | // use [google.golang.org/protobuf/protoadapt.MessageV2Of]. 22 | // - To convert a v2 message to a v1 message, 23 | // use [google.golang.org/protobuf/protoadapt.MessageV1Of]. 24 | type Message = protoreflect.ProtoMessage 25 | 26 | // Error matches all errors produced by packages in the protobuf module 27 | // according to [errors.Is]. 28 | // 29 | // Example usage: 30 | // 31 | // if errors.Is(err, proto.Error) { ... } 32 | var Error error 33 | 34 | func init() { 35 | Error = errors.Error 36 | } 37 | 38 | // MessageName returns the full name of m. 39 | // If m is nil, it returns an empty string. 40 | func MessageName(m Message) protoreflect.FullName { 41 | if m == nil { 42 | return "" 43 | } 44 | return m.ProtoReflect().Descriptor().FullName() 45 | } 46 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/proto_methods.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The protoreflect build tag disables use of fast-path methods. 6 | //go:build !protoreflect 7 | // +build !protoreflect 8 | 9 | package proto 10 | 11 | import ( 12 | "google.golang.org/protobuf/reflect/protoreflect" 13 | "google.golang.org/protobuf/runtime/protoiface" 14 | ) 15 | 16 | const hasProtoMethods = true 17 | 18 | func protoMethods(m protoreflect.Message) *protoiface.Methods { 19 | return m.ProtoMethods() 20 | } 21 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/proto_reflect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The protoreflect build tag disables use of fast-path methods. 6 | //go:build protoreflect 7 | // +build protoreflect 8 | 9 | package proto 10 | 11 | import ( 12 | "google.golang.org/protobuf/reflect/protoreflect" 13 | "google.golang.org/protobuf/runtime/protoiface" 14 | ) 15 | 16 | const hasProtoMethods = false 17 | 18 | func protoMethods(m protoreflect.Message) *protoiface.Methods { 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/reset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "fmt" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | // Reset clears every field in the message. 14 | // The resulting message shares no observable memory with its previous state 15 | // other than the memory for the message itself. 16 | func Reset(m Message) { 17 | if mr, ok := m.(interface{ Reset() }); ok && hasProtoMethods { 18 | mr.Reset() 19 | return 20 | } 21 | resetMessage(m.ProtoReflect()) 22 | } 23 | 24 | func resetMessage(m protoreflect.Message) { 25 | if !m.IsValid() { 26 | panic(fmt.Sprintf("cannot reset invalid %v message", m.Descriptor().FullName())) 27 | } 28 | 29 | // Clear all known fields. 30 | fds := m.Descriptor().Fields() 31 | for i := 0; i < fds.Len(); i++ { 32 | m.Clear(fds.Get(i)) 33 | } 34 | 35 | // Clear extension fields. 36 | m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool { 37 | m.Clear(fd) 38 | return true 39 | }) 40 | 41 | // Clear unknown fields. 42 | m.SetUnknown(nil) 43 | } 44 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/size.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "google.golang.org/protobuf/encoding/protowire" 9 | "google.golang.org/protobuf/internal/encoding/messageset" 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | "google.golang.org/protobuf/runtime/protoiface" 12 | ) 13 | 14 | // Size returns the size in bytes of the wire-format encoding of m. 15 | func Size(m Message) int { 16 | return MarshalOptions{}.Size(m) 17 | } 18 | 19 | // Size returns the size in bytes of the wire-format encoding of m. 20 | func (o MarshalOptions) Size(m Message) int { 21 | // Treat a nil message interface as an empty message; nothing to output. 22 | if m == nil { 23 | return 0 24 | } 25 | 26 | return o.size(m.ProtoReflect()) 27 | } 28 | 29 | // size is a centralized function that all size operations go through. 30 | // For profiling purposes, avoid changing the name of this function or 31 | // introducing other code paths for size that do not go through this. 32 | func (o MarshalOptions) size(m protoreflect.Message) (size int) { 33 | methods := protoMethods(m) 34 | if methods != nil && methods.Size != nil { 35 | out := methods.Size(protoiface.SizeInput{ 36 | Message: m, 37 | Flags: o.flags(), 38 | }) 39 | return out.Size 40 | } 41 | if methods != nil && methods.Marshal != nil { 42 | // This is not efficient, but we don't have any choice. 43 | // This case is mainly used for legacy types with a Marshal method. 44 | out, _ := methods.Marshal(protoiface.MarshalInput{ 45 | Message: m, 46 | Flags: o.flags(), 47 | }) 48 | return len(out.Buf) 49 | } 50 | return o.sizeMessageSlow(m) 51 | } 52 | 53 | func (o MarshalOptions) sizeMessageSlow(m protoreflect.Message) (size int) { 54 | if messageset.IsMessageSet(m.Descriptor()) { 55 | return o.sizeMessageSet(m) 56 | } 57 | m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { 58 | size += o.sizeField(fd, v) 59 | return true 60 | }) 61 | size += len(m.GetUnknown()) 62 | return size 63 | } 64 | 65 | func (o MarshalOptions) sizeField(fd protoreflect.FieldDescriptor, value protoreflect.Value) (size int) { 66 | num := fd.Number() 67 | switch { 68 | case fd.IsList(): 69 | return o.sizeList(num, fd, value.List()) 70 | case fd.IsMap(): 71 | return o.sizeMap(num, fd, value.Map()) 72 | default: 73 | return protowire.SizeTag(num) + o.sizeSingular(num, fd.Kind(), value) 74 | } 75 | } 76 | 77 | func (o MarshalOptions) sizeList(num protowire.Number, fd protoreflect.FieldDescriptor, list protoreflect.List) (size int) { 78 | sizeTag := protowire.SizeTag(num) 79 | 80 | if fd.IsPacked() && list.Len() > 0 { 81 | content := 0 82 | for i, llen := 0, list.Len(); i < llen; i++ { 83 | content += o.sizeSingular(num, fd.Kind(), list.Get(i)) 84 | } 85 | return sizeTag + protowire.SizeBytes(content) 86 | } 87 | 88 | for i, llen := 0, list.Len(); i < llen; i++ { 89 | size += sizeTag + o.sizeSingular(num, fd.Kind(), list.Get(i)) 90 | } 91 | return size 92 | } 93 | 94 | func (o MarshalOptions) sizeMap(num protowire.Number, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) (size int) { 95 | sizeTag := protowire.SizeTag(num) 96 | 97 | mapv.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool { 98 | size += sizeTag 99 | size += protowire.SizeBytes(o.sizeField(fd.MapKey(), key.Value()) + o.sizeField(fd.MapValue(), value)) 100 | return true 101 | }) 102 | return size 103 | } 104 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/size_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-types. DO NOT EDIT. 6 | 7 | package proto 8 | 9 | import ( 10 | "google.golang.org/protobuf/encoding/protowire" 11 | "google.golang.org/protobuf/reflect/protoreflect" 12 | ) 13 | 14 | func (o MarshalOptions) sizeSingular(num protowire.Number, kind protoreflect.Kind, v protoreflect.Value) int { 15 | switch kind { 16 | case protoreflect.BoolKind: 17 | return protowire.SizeVarint(protowire.EncodeBool(v.Bool())) 18 | case protoreflect.EnumKind: 19 | return protowire.SizeVarint(uint64(v.Enum())) 20 | case protoreflect.Int32Kind: 21 | return protowire.SizeVarint(uint64(int32(v.Int()))) 22 | case protoreflect.Sint32Kind: 23 | return protowire.SizeVarint(protowire.EncodeZigZag(int64(int32(v.Int())))) 24 | case protoreflect.Uint32Kind: 25 | return protowire.SizeVarint(uint64(uint32(v.Uint()))) 26 | case protoreflect.Int64Kind: 27 | return protowire.SizeVarint(uint64(v.Int())) 28 | case protoreflect.Sint64Kind: 29 | return protowire.SizeVarint(protowire.EncodeZigZag(v.Int())) 30 | case protoreflect.Uint64Kind: 31 | return protowire.SizeVarint(v.Uint()) 32 | case protoreflect.Sfixed32Kind: 33 | return protowire.SizeFixed32() 34 | case protoreflect.Fixed32Kind: 35 | return protowire.SizeFixed32() 36 | case protoreflect.FloatKind: 37 | return protowire.SizeFixed32() 38 | case protoreflect.Sfixed64Kind: 39 | return protowire.SizeFixed64() 40 | case protoreflect.Fixed64Kind: 41 | return protowire.SizeFixed64() 42 | case protoreflect.DoubleKind: 43 | return protowire.SizeFixed64() 44 | case protoreflect.StringKind: 45 | return protowire.SizeBytes(len(v.String())) 46 | case protoreflect.BytesKind: 47 | return protowire.SizeBytes(len(v.Bytes())) 48 | case protoreflect.MessageKind: 49 | return protowire.SizeBytes(o.size(v.Message())) 50 | case protoreflect.GroupKind: 51 | return protowire.SizeGroup(num, o.size(v.Message())) 52 | default: 53 | return 0 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/proto/wrappers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | // Bool stores v in a new bool value and returns a pointer to it. 8 | func Bool(v bool) *bool { return &v } 9 | 10 | // Int32 stores v in a new int32 value and returns a pointer to it. 11 | func Int32(v int32) *int32 { return &v } 12 | 13 | // Int64 stores v in a new int64 value and returns a pointer to it. 14 | func Int64(v int64) *int64 { return &v } 15 | 16 | // Float32 stores v in a new float32 value and returns a pointer to it. 17 | func Float32(v float32) *float32 { return &v } 18 | 19 | // Float64 stores v in a new float64 value and returns a pointer to it. 20 | func Float64(v float64) *float64 { return &v } 21 | 22 | // Uint32 stores v in a new uint32 value and returns a pointer to it. 23 | func Uint32(v uint32) *uint32 { return &v } 24 | 25 | // Uint64 stores v in a new uint64 value and returns a pointer to it. 26 | func Uint64(v uint64) *uint64 { return &v } 27 | 28 | // String stores v in a new string value and returns a pointer to it. 29 | func String(v string) *string { return &v } 30 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoreflect 6 | 7 | import ( 8 | "google.golang.org/protobuf/internal/pragma" 9 | ) 10 | 11 | // The following types are used by the fast-path Message.ProtoMethods method. 12 | // 13 | // To avoid polluting the public protoreflect API with types used only by 14 | // low-level implementations, the canonical definitions of these types are 15 | // in the runtime/protoiface package. The definitions here and in protoiface 16 | // must be kept in sync. 17 | type ( 18 | methods = struct { 19 | pragma.NoUnkeyedLiterals 20 | Flags supportFlags 21 | Size func(sizeInput) sizeOutput 22 | Marshal func(marshalInput) (marshalOutput, error) 23 | Unmarshal func(unmarshalInput) (unmarshalOutput, error) 24 | Merge func(mergeInput) mergeOutput 25 | CheckInitialized func(checkInitializedInput) (checkInitializedOutput, error) 26 | } 27 | supportFlags = uint64 28 | sizeInput = struct { 29 | pragma.NoUnkeyedLiterals 30 | Message Message 31 | Flags uint8 32 | } 33 | sizeOutput = struct { 34 | pragma.NoUnkeyedLiterals 35 | Size int 36 | } 37 | marshalInput = struct { 38 | pragma.NoUnkeyedLiterals 39 | Message Message 40 | Buf []byte 41 | Flags uint8 42 | } 43 | marshalOutput = struct { 44 | pragma.NoUnkeyedLiterals 45 | Buf []byte 46 | } 47 | unmarshalInput = struct { 48 | pragma.NoUnkeyedLiterals 49 | Message Message 50 | Buf []byte 51 | Flags uint8 52 | Resolver interface { 53 | FindExtensionByName(field FullName) (ExtensionType, error) 54 | FindExtensionByNumber(message FullName, field FieldNumber) (ExtensionType, error) 55 | } 56 | Depth int 57 | } 58 | unmarshalOutput = struct { 59 | pragma.NoUnkeyedLiterals 60 | Flags uint8 61 | } 62 | mergeInput = struct { 63 | pragma.NoUnkeyedLiterals 64 | Source Message 65 | Destination Message 66 | } 67 | mergeOutput = struct { 68 | pragma.NoUnkeyedLiterals 69 | Flags uint8 70 | } 71 | checkInitializedInput = struct { 72 | pragma.NoUnkeyedLiterals 73 | Message Message 74 | } 75 | checkInitializedOutput = struct { 76 | pragma.NoUnkeyedLiterals 77 | } 78 | ) 79 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoreflect 6 | 7 | import ( 8 | "strconv" 9 | ) 10 | 11 | // SourceLocations is a list of source locations. 12 | type SourceLocations interface { 13 | // Len reports the number of source locations in the proto file. 14 | Len() int 15 | // Get returns the ith SourceLocation. It panics if out of bounds. 16 | Get(int) SourceLocation 17 | 18 | // ByPath returns the SourceLocation for the given path, 19 | // returning the first location if multiple exist for the same path. 20 | // If multiple locations exist for the same path, 21 | // then SourceLocation.Next index can be used to identify the 22 | // index of the next SourceLocation. 23 | // If no location exists for this path, it returns the zero value. 24 | ByPath(path SourcePath) SourceLocation 25 | 26 | // ByDescriptor returns the SourceLocation for the given descriptor, 27 | // returning the first location if multiple exist for the same path. 28 | // If no location exists for this descriptor, it returns the zero value. 29 | ByDescriptor(desc Descriptor) SourceLocation 30 | 31 | doNotImplement 32 | } 33 | 34 | // SourceLocation describes a source location and 35 | // corresponds with the google.protobuf.SourceCodeInfo.Location message. 36 | type SourceLocation struct { 37 | // Path is the path to the declaration from the root file descriptor. 38 | // The contents of this slice must not be mutated. 39 | Path SourcePath 40 | 41 | // StartLine and StartColumn are the zero-indexed starting location 42 | // in the source file for the declaration. 43 | StartLine, StartColumn int 44 | // EndLine and EndColumn are the zero-indexed ending location 45 | // in the source file for the declaration. 46 | // In the descriptor.proto, the end line may be omitted if it is identical 47 | // to the start line. Here, it is always populated. 48 | EndLine, EndColumn int 49 | 50 | // LeadingDetachedComments are the leading detached comments 51 | // for the declaration. The contents of this slice must not be mutated. 52 | LeadingDetachedComments []string 53 | // LeadingComments is the leading attached comment for the declaration. 54 | LeadingComments string 55 | // TrailingComments is the trailing attached comment for the declaration. 56 | TrailingComments string 57 | 58 | // Next is an index into SourceLocations for the next source location that 59 | // has the same Path. It is zero if there is no next location. 60 | Next int 61 | } 62 | 63 | // SourcePath identifies part of a file descriptor for a source location. 64 | // The SourcePath is a sequence of either field numbers or indexes into 65 | // a repeated field that form a path starting from the root file descriptor. 66 | // 67 | // See google.protobuf.SourceCodeInfo.Location.path. 68 | type SourcePath []int32 69 | 70 | // Equal reports whether p1 equals p2. 71 | func (p1 SourcePath) Equal(p2 SourcePath) bool { 72 | if len(p1) != len(p2) { 73 | return false 74 | } 75 | for i := range p1 { 76 | if p1[i] != p2[i] { 77 | return false 78 | } 79 | } 80 | return true 81 | } 82 | 83 | // String formats the path in a humanly readable manner. 84 | // The output is guaranteed to be deterministic, 85 | // making it suitable for use as a key into a Go map. 86 | // It is not guaranteed to be stable as the exact output could change 87 | // in a future version of this module. 88 | // 89 | // Example output: 90 | // 91 | // .message_type[6].nested_type[15].field[3] 92 | func (p SourcePath) String() string { 93 | b := p.appendFileDescriptorProto(nil) 94 | for _, i := range p { 95 | b = append(b, '.') 96 | b = strconv.AppendInt(b, int64(i), 10) 97 | } 98 | return string(b) 99 | } 100 | 101 | type appendFunc func(*SourcePath, []byte) []byte 102 | 103 | func (p *SourcePath) appendSingularField(b []byte, name string, f appendFunc) []byte { 104 | if len(*p) == 0 { 105 | return b 106 | } 107 | b = append(b, '.') 108 | b = append(b, name...) 109 | *p = (*p)[1:] 110 | if f != nil { 111 | b = f(p, b) 112 | } 113 | return b 114 | } 115 | 116 | func (p *SourcePath) appendRepeatedField(b []byte, name string, f appendFunc) []byte { 117 | b = p.appendSingularField(b, name, nil) 118 | if len(*p) == 0 || (*p)[0] < 0 { 119 | return b 120 | } 121 | b = append(b, '[') 122 | b = strconv.AppendUint(b, uint64((*p)[0]), 10) 123 | b = append(b, ']') 124 | *p = (*p)[1:] 125 | if f != nil { 126 | b = f(p, b) 127 | } 128 | return b 129 | } 130 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoreflect 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "math" 11 | "reflect" 12 | 13 | "google.golang.org/protobuf/encoding/protowire" 14 | ) 15 | 16 | // Equal reports whether v1 and v2 are recursively equal. 17 | // 18 | // - Values of different types are always unequal. 19 | // 20 | // - Bytes values are equal if they contain identical bytes. 21 | // Empty bytes (regardless of nil-ness) are considered equal. 22 | // 23 | // - Floating point values are equal if they contain the same value. 24 | // Unlike the == operator, a NaN is equal to another NaN. 25 | // 26 | // - Enums are equal if they contain the same number. 27 | // Since [Value] does not contain an enum descriptor, 28 | // enum values do not consider the type of the enum. 29 | // 30 | // - Other scalar values are equal if they contain the same value. 31 | // 32 | // - [Message] values are equal if they belong to the same message descriptor, 33 | // have the same set of populated known and extension field values, 34 | // and the same set of unknown fields values. 35 | // 36 | // - [List] values are equal if they are the same length and 37 | // each corresponding element is equal. 38 | // 39 | // - [Map] values are equal if they have the same set of keys and 40 | // the corresponding value for each key is equal. 41 | func (v1 Value) Equal(v2 Value) bool { 42 | return equalValue(v1, v2) 43 | } 44 | 45 | func equalValue(x, y Value) bool { 46 | eqType := x.typ == y.typ 47 | switch x.typ { 48 | case nilType: 49 | return eqType 50 | case boolType: 51 | return eqType && x.Bool() == y.Bool() 52 | case int32Type, int64Type: 53 | return eqType && x.Int() == y.Int() 54 | case uint32Type, uint64Type: 55 | return eqType && x.Uint() == y.Uint() 56 | case float32Type, float64Type: 57 | return eqType && equalFloat(x.Float(), y.Float()) 58 | case stringType: 59 | return eqType && x.String() == y.String() 60 | case bytesType: 61 | return eqType && bytes.Equal(x.Bytes(), y.Bytes()) 62 | case enumType: 63 | return eqType && x.Enum() == y.Enum() 64 | default: 65 | switch x := x.Interface().(type) { 66 | case Message: 67 | y, ok := y.Interface().(Message) 68 | return ok && equalMessage(x, y) 69 | case List: 70 | y, ok := y.Interface().(List) 71 | return ok && equalList(x, y) 72 | case Map: 73 | y, ok := y.Interface().(Map) 74 | return ok && equalMap(x, y) 75 | default: 76 | panic(fmt.Sprintf("unknown type: %T", x)) 77 | } 78 | } 79 | } 80 | 81 | // equalFloat compares two floats, where NaNs are treated as equal. 82 | func equalFloat(x, y float64) bool { 83 | if math.IsNaN(x) || math.IsNaN(y) { 84 | return math.IsNaN(x) && math.IsNaN(y) 85 | } 86 | return x == y 87 | } 88 | 89 | // equalMessage compares two messages. 90 | func equalMessage(mx, my Message) bool { 91 | if mx.Descriptor() != my.Descriptor() { 92 | return false 93 | } 94 | 95 | nx := 0 96 | equal := true 97 | mx.Range(func(fd FieldDescriptor, vx Value) bool { 98 | nx++ 99 | vy := my.Get(fd) 100 | equal = my.Has(fd) && equalValue(vx, vy) 101 | return equal 102 | }) 103 | if !equal { 104 | return false 105 | } 106 | ny := 0 107 | my.Range(func(fd FieldDescriptor, vx Value) bool { 108 | ny++ 109 | return true 110 | }) 111 | if nx != ny { 112 | return false 113 | } 114 | 115 | return equalUnknown(mx.GetUnknown(), my.GetUnknown()) 116 | } 117 | 118 | // equalList compares two lists. 119 | func equalList(x, y List) bool { 120 | if x.Len() != y.Len() { 121 | return false 122 | } 123 | for i := x.Len() - 1; i >= 0; i-- { 124 | if !equalValue(x.Get(i), y.Get(i)) { 125 | return false 126 | } 127 | } 128 | return true 129 | } 130 | 131 | // equalMap compares two maps. 132 | func equalMap(x, y Map) bool { 133 | if x.Len() != y.Len() { 134 | return false 135 | } 136 | equal := true 137 | x.Range(func(k MapKey, vx Value) bool { 138 | vy := y.Get(k) 139 | equal = y.Has(k) && equalValue(vx, vy) 140 | return equal 141 | }) 142 | return equal 143 | } 144 | 145 | // equalUnknown compares unknown fields by direct comparison on the raw bytes 146 | // of each individual field number. 147 | func equalUnknown(x, y RawFields) bool { 148 | if len(x) != len(y) { 149 | return false 150 | } 151 | if bytes.Equal([]byte(x), []byte(y)) { 152 | return true 153 | } 154 | 155 | mx := make(map[FieldNumber]RawFields) 156 | my := make(map[FieldNumber]RawFields) 157 | for len(x) > 0 { 158 | fnum, _, n := protowire.ConsumeField(x) 159 | mx[fnum] = append(mx[fnum], x[:n]...) 160 | x = x[n:] 161 | } 162 | for len(y) > 0 { 163 | fnum, _, n := protowire.ConsumeField(y) 164 | my[fnum] = append(my[fnum], y[:n]...) 165 | y = y[n:] 166 | } 167 | return reflect.DeepEqual(mx, my) 168 | } 169 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build purego || appengine 6 | // +build purego appengine 7 | 8 | package protoreflect 9 | 10 | import "google.golang.org/protobuf/internal/pragma" 11 | 12 | type valueType int 13 | 14 | const ( 15 | nilType valueType = iota 16 | boolType 17 | int32Type 18 | int64Type 19 | uint32Type 20 | uint64Type 21 | float32Type 22 | float64Type 23 | stringType 24 | bytesType 25 | enumType 26 | ifaceType 27 | ) 28 | 29 | // value is a union where only one type can be represented at a time. 30 | // This uses a distinct field for each type. This is type safe in Go, but 31 | // occupies more memory than necessary (72B). 32 | type value struct { 33 | pragma.DoNotCompare // 0B 34 | 35 | typ valueType // 8B 36 | num uint64 // 8B 37 | str string // 16B 38 | bin []byte // 24B 39 | iface any // 16B 40 | } 41 | 42 | func valueOfString(v string) Value { 43 | return Value{typ: stringType, str: v} 44 | } 45 | func valueOfBytes(v []byte) Value { 46 | return Value{typ: bytesType, bin: v} 47 | } 48 | func valueOfIface(v any) Value { 49 | return Value{typ: ifaceType, iface: v} 50 | } 51 | 52 | func (v Value) getString() string { 53 | return v.str 54 | } 55 | func (v Value) getBytes() []byte { 56 | return v.bin 57 | } 58 | func (v Value) getIface() any { 59 | return v.iface 60 | } 61 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine && !go1.21 6 | // +build !purego,!appengine,!go1.21 7 | 8 | package protoreflect 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "google.golang.org/protobuf/internal/pragma" 14 | ) 15 | 16 | type ( 17 | stringHeader struct { 18 | Data unsafe.Pointer 19 | Len int 20 | } 21 | sliceHeader struct { 22 | Data unsafe.Pointer 23 | Len int 24 | Cap int 25 | } 26 | ifaceHeader struct { 27 | Type unsafe.Pointer 28 | Data unsafe.Pointer 29 | } 30 | ) 31 | 32 | var ( 33 | nilType = typeOf(nil) 34 | boolType = typeOf(*new(bool)) 35 | int32Type = typeOf(*new(int32)) 36 | int64Type = typeOf(*new(int64)) 37 | uint32Type = typeOf(*new(uint32)) 38 | uint64Type = typeOf(*new(uint64)) 39 | float32Type = typeOf(*new(float32)) 40 | float64Type = typeOf(*new(float64)) 41 | stringType = typeOf(*new(string)) 42 | bytesType = typeOf(*new([]byte)) 43 | enumType = typeOf(*new(EnumNumber)) 44 | ) 45 | 46 | // typeOf returns a pointer to the Go type information. 47 | // The pointer is comparable and equal if and only if the types are identical. 48 | func typeOf(t any) unsafe.Pointer { 49 | return (*ifaceHeader)(unsafe.Pointer(&t)).Type 50 | } 51 | 52 | // value is a union where only one type can be represented at a time. 53 | // The struct is 24B large on 64-bit systems and requires the minimum storage 54 | // necessary to represent each possible type. 55 | // 56 | // The Go GC needs to be able to scan variables containing pointers. 57 | // As such, pointers and non-pointers cannot be intermixed. 58 | type value struct { 59 | pragma.DoNotCompare // 0B 60 | 61 | // typ stores the type of the value as a pointer to the Go type. 62 | typ unsafe.Pointer // 8B 63 | 64 | // ptr stores the data pointer for a String, Bytes, or interface value. 65 | ptr unsafe.Pointer // 8B 66 | 67 | // num stores a Bool, Int32, Int64, Uint32, Uint64, Float32, Float64, or 68 | // Enum value as a raw uint64. 69 | // 70 | // It is also used to store the length of a String or Bytes value; 71 | // the capacity is ignored. 72 | num uint64 // 8B 73 | } 74 | 75 | func valueOfString(v string) Value { 76 | p := (*stringHeader)(unsafe.Pointer(&v)) 77 | return Value{typ: stringType, ptr: p.Data, num: uint64(len(v))} 78 | } 79 | func valueOfBytes(v []byte) Value { 80 | p := (*sliceHeader)(unsafe.Pointer(&v)) 81 | return Value{typ: bytesType, ptr: p.Data, num: uint64(len(v))} 82 | } 83 | func valueOfIface(v any) Value { 84 | p := (*ifaceHeader)(unsafe.Pointer(&v)) 85 | return Value{typ: p.Type, ptr: p.Data} 86 | } 87 | 88 | func (v Value) getString() (x string) { 89 | *(*stringHeader)(unsafe.Pointer(&x)) = stringHeader{Data: v.ptr, Len: int(v.num)} 90 | return x 91 | } 92 | func (v Value) getBytes() (x []byte) { 93 | *(*sliceHeader)(unsafe.Pointer(&x)) = sliceHeader{Data: v.ptr, Len: int(v.num), Cap: int(v.num)} 94 | return x 95 | } 96 | func (v Value) getIface() (x any) { 97 | *(*ifaceHeader)(unsafe.Pointer(&x)) = ifaceHeader{Type: v.typ, Data: v.ptr} 98 | return x 99 | } 100 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine && go1.21 6 | // +build !purego,!appengine,go1.21 7 | 8 | package protoreflect 9 | 10 | import ( 11 | "unsafe" 12 | 13 | "google.golang.org/protobuf/internal/pragma" 14 | ) 15 | 16 | type ( 17 | ifaceHeader struct { 18 | _ [0]any // if interfaces have greater alignment than unsafe.Pointer, this will enforce it. 19 | Type unsafe.Pointer 20 | Data unsafe.Pointer 21 | } 22 | ) 23 | 24 | var ( 25 | nilType = typeOf(nil) 26 | boolType = typeOf(*new(bool)) 27 | int32Type = typeOf(*new(int32)) 28 | int64Type = typeOf(*new(int64)) 29 | uint32Type = typeOf(*new(uint32)) 30 | uint64Type = typeOf(*new(uint64)) 31 | float32Type = typeOf(*new(float32)) 32 | float64Type = typeOf(*new(float64)) 33 | stringType = typeOf(*new(string)) 34 | bytesType = typeOf(*new([]byte)) 35 | enumType = typeOf(*new(EnumNumber)) 36 | ) 37 | 38 | // typeOf returns a pointer to the Go type information. 39 | // The pointer is comparable and equal if and only if the types are identical. 40 | func typeOf(t any) unsafe.Pointer { 41 | return (*ifaceHeader)(unsafe.Pointer(&t)).Type 42 | } 43 | 44 | // value is a union where only one type can be represented at a time. 45 | // The struct is 24B large on 64-bit systems and requires the minimum storage 46 | // necessary to represent each possible type. 47 | // 48 | // The Go GC needs to be able to scan variables containing pointers. 49 | // As such, pointers and non-pointers cannot be intermixed. 50 | type value struct { 51 | pragma.DoNotCompare // 0B 52 | 53 | // typ stores the type of the value as a pointer to the Go type. 54 | typ unsafe.Pointer // 8B 55 | 56 | // ptr stores the data pointer for a String, Bytes, or interface value. 57 | ptr unsafe.Pointer // 8B 58 | 59 | // num stores a Bool, Int32, Int64, Uint32, Uint64, Float32, Float64, or 60 | // Enum value as a raw uint64. 61 | // 62 | // It is also used to store the length of a String or Bytes value; 63 | // the capacity is ignored. 64 | num uint64 // 8B 65 | } 66 | 67 | func valueOfString(v string) Value { 68 | return Value{typ: stringType, ptr: unsafe.Pointer(unsafe.StringData(v)), num: uint64(len(v))} 69 | } 70 | func valueOfBytes(v []byte) Value { 71 | return Value{typ: bytesType, ptr: unsafe.Pointer(unsafe.SliceData(v)), num: uint64(len(v))} 72 | } 73 | func valueOfIface(v any) Value { 74 | p := (*ifaceHeader)(unsafe.Pointer(&v)) 75 | return Value{typ: p.Type, ptr: p.Data} 76 | } 77 | 78 | func (v Value) getString() string { 79 | return unsafe.String((*byte)(v.ptr), v.num) 80 | } 81 | func (v Value) getBytes() []byte { 82 | return unsafe.Slice((*byte)(v.ptr), v.num) 83 | } 84 | func (v Value) getIface() (x any) { 85 | *(*ifaceHeader)(unsafe.Pointer(&x)) = ifaceHeader{Type: v.typ, Data: v.ptr} 86 | return x 87 | } 88 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoiface 6 | 7 | type MessageV1 interface { 8 | Reset() 9 | String() string 10 | ProtoMessage() 11 | } 12 | 13 | type ExtensionRangeV1 struct { 14 | Start, End int32 // both inclusive 15 | } 16 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package protoimpl contains the default implementation for messages 6 | // generated by protoc-gen-go. 7 | // 8 | // WARNING: This package should only ever be imported by generated messages. 9 | // The compatibility agreement covers nothing except for functionality needed 10 | // to keep existing generated messages operational. Breakages that occur due 11 | // to unauthorized usages of this package are not the author's responsibility. 12 | package protoimpl 13 | 14 | import ( 15 | "google.golang.org/protobuf/internal/filedesc" 16 | "google.golang.org/protobuf/internal/filetype" 17 | "google.golang.org/protobuf/internal/impl" 18 | ) 19 | 20 | // UnsafeEnabled specifies whether package unsafe can be used. 21 | const UnsafeEnabled = impl.UnsafeEnabled 22 | 23 | type ( 24 | // Types used by generated code in init functions. 25 | DescBuilder = filedesc.Builder 26 | TypeBuilder = filetype.Builder 27 | 28 | // Types used by generated code to implement EnumType, MessageType, and ExtensionType. 29 | EnumInfo = impl.EnumInfo 30 | MessageInfo = impl.MessageInfo 31 | ExtensionInfo = impl.ExtensionInfo 32 | 33 | // Types embedded in generated messages. 34 | MessageState = impl.MessageState 35 | SizeCache = impl.SizeCache 36 | WeakFields = impl.WeakFields 37 | UnknownFields = impl.UnknownFields 38 | ExtensionFields = impl.ExtensionFields 39 | ExtensionFieldV1 = impl.ExtensionField 40 | 41 | Pointer = impl.Pointer 42 | ) 43 | 44 | var X impl.Export 45 | -------------------------------------------------------------------------------- /docker/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoimpl 6 | 7 | import ( 8 | "google.golang.org/protobuf/internal/version" 9 | ) 10 | 11 | const ( 12 | // MaxVersion is the maximum supported version for generated .pb.go files. 13 | // It is always the current version of the module. 14 | MaxVersion = version.Minor 15 | 16 | // GenVersion is the runtime version required by generated .pb.go files. 17 | // This is incremented when generated code relies on new functionality 18 | // in the runtime. 19 | GenVersion = 20 20 | 21 | // MinVersion is the minimum supported version for generated .pb.go files. 22 | // This is incremented when the runtime drops support for old code. 23 | MinVersion = 0 24 | ) 25 | 26 | // EnforceVersion is used by code generated by protoc-gen-go 27 | // to statically enforce minimum and maximum versions of this package. 28 | // A compilation failure implies either that: 29 | // - the runtime package is too old and needs to be updated OR 30 | // - the generated code is too old and needs to be regenerated. 31 | // 32 | // The runtime package can be upgraded by running: 33 | // 34 | // go get google.golang.org/protobuf 35 | // 36 | // The generated code can be regenerated by running: 37 | // 38 | // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES} 39 | // 40 | // Example usage by generated code: 41 | // 42 | // const ( 43 | // // Verify that this generated code is sufficiently up-to-date. 44 | // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion) 45 | // // Verify that runtime/protoimpl is sufficiently up-to-date. 46 | // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion) 47 | // ) 48 | // 49 | // The genVersion is the current minor version used to generated the code. 50 | // This compile-time check relies on negative integer overflow of a uint 51 | // being a compilation failure (guaranteed by the Go specification). 52 | type EnforceVersion uint 53 | 54 | // This enforces the following invariant: 55 | // 56 | // MinVersion ≤ GenVersion ≤ MaxVersion 57 | const ( 58 | _ = EnforceVersion(GenVersion - MinVersion) 59 | _ = EnforceVersion(MaxVersion - GenVersion) 60 | ) 61 | -------------------------------------------------------------------------------- /docker/vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/google/go-cmp v0.6.0 2 | ## explicit; go 1.13 3 | github.com/google/go-cmp/cmp 4 | github.com/google/go-cmp/cmp/internal/diff 5 | github.com/google/go-cmp/cmp/internal/flags 6 | github.com/google/go-cmp/cmp/internal/function 7 | github.com/google/go-cmp/cmp/internal/value 8 | # github.com/prometheus/client_model v0.6.1 9 | ## explicit; go 1.19 10 | github.com/prometheus/client_model/go 11 | # github.com/prometheus/common v0.55.0 12 | ## explicit; go 1.20 13 | github.com/prometheus/common/model 14 | # google.golang.org/protobuf v1.34.2 15 | ## explicit; go 1.20 16 | google.golang.org/protobuf/encoding/prototext 17 | google.golang.org/protobuf/encoding/protowire 18 | google.golang.org/protobuf/internal/descfmt 19 | google.golang.org/protobuf/internal/descopts 20 | google.golang.org/protobuf/internal/detrand 21 | google.golang.org/protobuf/internal/editiondefaults 22 | google.golang.org/protobuf/internal/encoding/defval 23 | google.golang.org/protobuf/internal/encoding/messageset 24 | google.golang.org/protobuf/internal/encoding/tag 25 | google.golang.org/protobuf/internal/encoding/text 26 | google.golang.org/protobuf/internal/errors 27 | google.golang.org/protobuf/internal/filedesc 28 | google.golang.org/protobuf/internal/filetype 29 | google.golang.org/protobuf/internal/flags 30 | google.golang.org/protobuf/internal/genid 31 | google.golang.org/protobuf/internal/impl 32 | google.golang.org/protobuf/internal/order 33 | google.golang.org/protobuf/internal/pragma 34 | google.golang.org/protobuf/internal/set 35 | google.golang.org/protobuf/internal/strs 36 | google.golang.org/protobuf/internal/version 37 | google.golang.org/protobuf/proto 38 | google.golang.org/protobuf/reflect/protoreflect 39 | google.golang.org/protobuf/reflect/protoregistry 40 | google.golang.org/protobuf/runtime/protoiface 41 | google.golang.org/protobuf/runtime/protoimpl 42 | google.golang.org/protobuf/types/known/timestamppb 43 | -------------------------------------------------------------------------------- /pull_recommendations/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Grafana Adaptive Metrics Auto-apply (Pull Recommendations)' 2 | description: 'Pull your latest Adaptive Metrics recommendations.' 3 | runs: 4 | using: 'docker' 5 | image: '../docker/Dockerfile' 6 | args: 7 | - pull 8 | inputs: 9 | working-dir: 10 | default: './' 11 | description: 'The directory to place the recommendations in.' 12 | --------------------------------------------------------------------------------