xref: /aosp_15_r20/external/skia/infra/bots/deps/deps.go (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1// Copyright 2024 Google LLC
2//
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5
6//go:generate bazelisk run //:go -- run ./generate.go
7package deps
8
9import (
10	"go.skia.org/infra/go/depot_tools/deps_parser"
11	"go.skia.org/infra/go/skerr"
12)
13
14// Get retrieves the given dependency. Returns an error of the given dependency
15// does not exist.
16func Get(dep string) (*deps_parser.DepsEntry, error) {
17	entry := deps.Get(dep)
18	if entry == nil {
19		return nil, skerr.Fmt("unknown dependency %q (normalized as %q)", dep, deps_parser.NormalizeDep(dep))
20	}
21	// Return a copy to prevent modification of the package-local entries.
22	return &deps_parser.DepsEntry{
23		Id:      entry.Id,
24		Version: entry.Version,
25		Path:    entry.Path,
26	}, nil
27}
28