Allow product-specific release configs.
Bug: 343794062 Test: manual Change-Id: Ifdfab5978221f1396681a2c851bad7be502b6ea7
This commit is contained in:
parent
5f2be11396
commit
b4f866c73c
3 changed files with 23 additions and 5 deletions
|
@ -48,6 +48,11 @@ type Flags struct {
|
|||
|
||||
// Panic on errors.
|
||||
debug bool
|
||||
|
||||
// Allow missing release config.
|
||||
// If true, and we cannot find the named release config, values for
|
||||
// `trunk_staging` will be used.
|
||||
allowMissing bool
|
||||
}
|
||||
|
||||
type CommandFunc func(*rc_lib.ReleaseConfigs, Flags, string, []string) error
|
||||
|
@ -284,7 +289,7 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a
|
|||
}
|
||||
|
||||
// Reload the release configs.
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, commonFlags.targetReleases[0], commonFlags.useGetBuildVar)
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, commonFlags.targetReleases[0], commonFlags.useGetBuildVar, commonFlags.allowMissing)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -307,6 +312,7 @@ func main() {
|
|||
flag.Var(&commonFlags.maps, "map", "path to a release_config_map.textproto. may be repeated")
|
||||
flag.StringVar(&commonFlags.outDir, "out-dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created")
|
||||
flag.Var(&commonFlags.targetReleases, "release", "TARGET_RELEASE for this build")
|
||||
flag.BoolVar(&commonFlags.allowMissing, "allow-missing", false, "Use trunk_staging values if release not found")
|
||||
flag.BoolVar(&commonFlags.allReleases, "all-releases", false, "operate on all releases. (Ignored for set command)")
|
||||
flag.BoolVar(&commonFlags.useGetBuildVar, "use-get-build-var", true, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS to get needed maps")
|
||||
flag.BoolVar(&commonFlags.debug, "debug", false, "turn on debugging output for errors")
|
||||
|
@ -342,7 +348,7 @@ func main() {
|
|||
if relName == "--all" || relName == "-all" {
|
||||
commonFlags.allReleases = true
|
||||
}
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName, commonFlags.useGetBuildVar)
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName, commonFlags.useGetBuildVar, commonFlags.allowMissing)
|
||||
if err != nil {
|
||||
errorExit(err)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func main() {
|
|||
var json, pb, textproto, inheritance bool
|
||||
var product string
|
||||
var allMake bool
|
||||
var useBuildVar bool
|
||||
var useBuildVar, allowMissing bool
|
||||
var guard bool
|
||||
|
||||
defaultRelease := os.Getenv("TARGET_RELEASE")
|
||||
|
@ -47,6 +47,7 @@ func main() {
|
|||
flag.BoolVar(&quiet, "quiet", false, "disable warning messages")
|
||||
flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated")
|
||||
flag.StringVar(&targetRelease, "release", defaultRelease, "TARGET_RELEASE for this build")
|
||||
flag.BoolVar(&allowMissing, "allow-missing", false, "Use trunk_staging values if release not found")
|
||||
flag.StringVar(&outputDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created")
|
||||
flag.BoolVar(&textproto, "textproto", true, "write artifacts as text protobuf")
|
||||
flag.BoolVar(&json, "json", true, "write artifacts as json")
|
||||
|
@ -65,7 +66,7 @@ func main() {
|
|||
if err = os.Chdir(top); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease, useBuildVar)
|
||||
configs, err = rc_lib.ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease, useBuildVar, allowMissing)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -76,6 +76,11 @@ type ReleaseConfigs struct {
|
|||
// A map from the config directory to its order in the list of config
|
||||
// directories.
|
||||
configDirIndexes ReleaseConfigDirMap
|
||||
|
||||
// True if we should allow a missing primary release config. In this
|
||||
// case, we will substitute `trunk_staging` values, but the release
|
||||
// config will not be in ALL_RELEASE_CONFIGS_FOR_PRODUCT.
|
||||
allowMissing bool
|
||||
}
|
||||
|
||||
func (configs *ReleaseConfigs) WriteInheritanceGraph(outFile string) error {
|
||||
|
@ -374,6 +379,11 @@ func (configs *ReleaseConfigs) GetReleaseConfig(name string) (*ReleaseConfig, er
|
|||
if config, ok := configs.ReleaseConfigs[name]; ok {
|
||||
return config, nil
|
||||
}
|
||||
if configs.allowMissing {
|
||||
if config, ok := configs.ReleaseConfigs["trunk_staging"]; ok {
|
||||
return config, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Missing config %s. Trace=%v", name, trace)
|
||||
}
|
||||
|
||||
|
@ -521,7 +531,7 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string, useBuildVar bool) (*ReleaseConfigs, error) {
|
||||
func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string, useBuildVar, allowMissing bool) (*ReleaseConfigs, error) {
|
||||
var err error
|
||||
|
||||
if len(releaseConfigMapPaths) == 0 {
|
||||
|
@ -538,6 +548,7 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin
|
|||
}
|
||||
|
||||
configs := ReleaseConfigsFactory()
|
||||
configs.allowMissing = allowMissing
|
||||
mapsRead := make(map[string]bool)
|
||||
var idx int
|
||||
for _, releaseConfigMapPath := range releaseConfigMapPaths {
|
||||
|
|
Loading…
Reference in a new issue