...

Text file src/cuelang.org/go/internal/mod/modresolve/schema.cue

Documentation: cuelang.org/go/internal/mod/modresolve

     1// Copyright 2024 CUE Authors
     2//
     3// Licensed under the Apache License, Version 2.0 (the "License");
     4// you may not use this file except in compliance with the License.
     5// You may obtain a copy of the License at
     6//
     7//     http://www.apache.org/licenses/LICENSE-2.0
     8//
     9// Unless required by applicable law or agreed to in writing, software
    10// distributed under the License is distributed on an "AS IS" BASIS,
    11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12// See the License for the specific language governing permissions and
    13// limitations under the License.
    14
    15// This aspect of #registry encodes the defaults used by the resolver
    16// parser. It's kept separate because it's technically bad practice to
    17// define regular fields as part of a schema, and by defining it this
    18// way, the pure schema can be read independently as such.
    19//
    20// TODO work out a nice way of doing this such that we don't have to
    21// mirror the fields in #file that mention #registry
    22#registry: {
    23	pathEncoding: *"path" | _
    24}
    25
    26// Note: public part of schema (included in help output) starts
    27// at "// #file" below.
    28
    29// #file represents the registry configuration schema.
    30#file: {
    31	// moduleRegistries specifies a mapping from module path prefix
    32	// (excluding any version suffix) to the registry to be used for
    33	// all modules under that path.
    34	//
    35	// A prefix is considered to match if a non-zero number of
    36	// initial path elements (sequences of non-slash characters) in
    37	// a module path match the prefix.
    38	//
    39	// If there are multiple matching prefixes, the longest
    40	// is chosen.
    41	moduleRegistries?: [#modulePath]: #registry
    42
    43	// defaultRegistry specifies a fallback registry to be used if no
    44	// prefix from moduleRegistry matches.
    45	// If it's not present, a system default will be used.
    46	defaultRegistry?: #registry
    47}
    48
    49#registry: {
    50	// registry specifies the registry host name and optionally, the
    51	// repository prefix to use for all modules in the repository,
    52	// and the security to use when accessing the host.
    53	//
    54	// It is in the form:
    55	// 	hostname[:port][/repoPrefix][+insecure]
    56	//
    57	// The hostname must be specified in square brackets if it's an
    58	// IPv6 address.
    59	//
    60	// Connections will be secure unless explicitly specified
    61	// otherwise, except for localhost connections which default to
    62	// insecure.
    63	//
    64	// See the doc comment on pathEncoding for details as to how
    65	// repoPrefix is used to determine the repository to use for a
    66	// specific module.
    67	//
    68	// Examples:
    69	//	"localhost:1234"
    70	//	"myregistry.example/my-modules+secure"
    71	registry!: string
    72
    73	// pathEncoding specifies how module versions map to
    74	// repositories within a registry.
    75	// Possible values are:
    76	// - "path": the repository is used as a prefix to the unencoded
    77	// module path. The version of the module is used as a tag.
    78	// - "hashAsPath": the hex-encoded SHA256 hash of the path is
    79	// used as a suffix to the above repository value. The version
    80	// of the module is used as a tag.
    81	// - "hashAsTag": the repository is used as is: the hex-encoded
    82	// SHA256 hash of the path followed by a hyphen and the version
    83	// is used as a tag.
    84	pathEncoding?: "path" | "hashAsRepo" | "hashAsTag"
    85
    86	// prefixForTags specifies an arbitrary prefix that's added to
    87	// all tags. This can be used to disambiguate tags when there
    88	// might be some possibility of confusion with tags in use for
    89	// other purposes.
    90	prefixForTags?: #tag
    91
    92	// TODO we could encode the invariant below in CUE but that
    93	// would result in poor error messages. With an error builtin,
    94	// that could perhaps be improved.
    95
    96	// stripPrefix specifies that the pattern prefix should be
    97	// stripped from the module path before using as a repository
    98	// path. This only applies when pathEncoding is "path".
    99	stripPrefix?: bool
   100}
   101
   102// TODO more specific schemas below
   103#modulePath: string
   104#tag: string

View as plain text