// getStage1Hash will try to fetch stage1 from store if it is a // default one. If that fails it will try to get via usual fetching // from disk or network. // // As a special case, if stage1 image path is a default and not // overriden by --stage1-image flag and it is has no scheme, it will // try to fetch it from two places on disk - from the path directly if // it is absolute and then from the same directory where rkt binary // resides. // // The passed command must have "stage1-image" string flag registered. func getStage1Hash(s *store.Store, cmd *cobra.Command) (*types.Hash, error) { fn := &finder{ imageActionData: imageActionData{ s: s, }, storeOnly: false, noStore: false, withDeps: false, } imageFlag := cmd.Flags().Lookup(stage1ImageFlagName) if imageFlag == nil { panic(fmt.Sprintf("Expected flag --%s to be registered in command %s", stage1ImageFlagName, cmd.Name())) } path := imageFlag.Value.String() if path == defaultStage1Image { return getDefaultStage1Hash(fn, imageFlag.Changed) } return getCustomStage1Hash(fn, path) }
// getStage1Hash will try to fetch stage1 from store if it is a // default one. If that fails it will try to get via usual fetching // from disk or network. // // As a special case, if stage1 image path is a default and not // overriden by --stage1-image flag and it is has no scheme, it will // try to fetch it from two places on disk - from the path directly if // it is absolute and then from the same directory where rkt binary // resides. // // The passed command must have "stage1-image" string flag registered. func getStage1Hash(s *store.Store, cmd *cobra.Command) (*types.Hash, error) { fn := &image.Finder{ S: s, InsecureFlags: globalFlags.InsecureFlags, TrustKeysFromHttps: globalFlags.TrustKeysFromHttps, StoreOnly: false, NoStore: false, WithDeps: false, } imageFlag := cmd.Flags().Lookup(stage1ImageFlagName) if imageFlag == nil { panic(fmt.Sprintf("Expected flag --%s to be registered in command %s", stage1ImageFlagName, cmd.Name())) } path := imageFlag.Value.String() if path == defaultStage1Image { return getDefaultStage1Hash(fn, imageFlag.Changed) } return getCustomStage1Hash(fn, path) }