Loading cmd/release_config/build_flag/main.go +1 −1 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a return fmt.Errorf("Unknown build flag %s", name) } if valueDir == "" { mapDir, err := GetMapDir(*flagArtifact.Traces[len(flagArtifact.Traces)-1].Source) mapDir, err := configs.GetFlagValueDirectory(release, flagArtifact) if err != nil { return err } Loading cmd/release_config/release_config_lib/release_config.go +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import ( // One directory's contribution to the a release config. type ReleaseConfigContribution struct { // Paths to files providing this config. // Path of the file providing this config contribution. path string // The index of the config directory where this release config Loading cmd/release_config/release_config_lib/release_configs.go +26 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,32 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { return m } // Find the top of the release config contribution directory. // Returns the parent of the flag_declarations and flag_values directories. func (configs *ReleaseConfigs) GetDirIndex(path string) (int, error) { for p := path; p != "."; p = filepath.Dir(p) { if idx, ok := configs.configDirIndexes[p]; ok { return idx, nil } } return -1, fmt.Errorf("Could not determine release config directory from %s", path) } // Determine the default directory for writing a flag value. // // Returns the path of the highest-Indexed one of: // - Where the flag is declared // - Where the release config is first declared // - The last place the value is being written. func (configs *ReleaseConfigs) GetFlagValueDirectory(config *ReleaseConfig, flag *FlagArtifact) (string, error) { current, err := configs.GetDirIndex(*flag.Traces[len(flag.Traces)-1].Source) if err != nil { return "", err } index := max(flag.DeclarationIndex, config.DeclarationIndex, current) return configs.configDirs[index], nil } func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { if _, err := os.Stat(path); err != nil { return fmt.Errorf("%s does not exist\n", path) Loading Loading
cmd/release_config/build_flag/main.go +1 −1 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a return fmt.Errorf("Unknown build flag %s", name) } if valueDir == "" { mapDir, err := GetMapDir(*flagArtifact.Traces[len(flagArtifact.Traces)-1].Source) mapDir, err := configs.GetFlagValueDirectory(release, flagArtifact) if err != nil { return err } Loading
cmd/release_config/release_config_lib/release_config.go +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import ( // One directory's contribution to the a release config. type ReleaseConfigContribution struct { // Paths to files providing this config. // Path of the file providing this config contribution. path string // The index of the config directory where this release config Loading
cmd/release_config/release_config_lib/release_configs.go +26 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,32 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { return m } // Find the top of the release config contribution directory. // Returns the parent of the flag_declarations and flag_values directories. func (configs *ReleaseConfigs) GetDirIndex(path string) (int, error) { for p := path; p != "."; p = filepath.Dir(p) { if idx, ok := configs.configDirIndexes[p]; ok { return idx, nil } } return -1, fmt.Errorf("Could not determine release config directory from %s", path) } // Determine the default directory for writing a flag value. // // Returns the path of the highest-Indexed one of: // - Where the flag is declared // - Where the release config is first declared // - The last place the value is being written. func (configs *ReleaseConfigs) GetFlagValueDirectory(config *ReleaseConfig, flag *FlagArtifact) (string, error) { current, err := configs.GetDirIndex(*flag.Traces[len(flag.Traces)-1].Source) if err != nil { return "", err } index := max(flag.DeclarationIndex, config.DeclarationIndex, current) return configs.configDirs[index], nil } func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { if _, err := os.Stat(path); err != nil { return fmt.Errorf("%s does not exist\n", path) Loading