github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/bootloader/assets/assetstesting.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 // +build withbootassetstesting 3 4 /* 5 * Copyright (C) 2021 Canonical Ltd 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 3 as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 package assets 22 23 import ( 24 "github.com/snapcore/snapd/logger" 25 ) 26 27 // InjectInternal injects an internal asset under the given name. 28 func InjectInternal(name string, data []byte) { 29 logger.Noticef("injecting bootloader asset %q", name) 30 registeredAssets[name] = data 31 } 32 33 func SnippetsForEditions(name string) []ForEditions { 34 return registeredEditionSnippets[name] 35 } 36 37 // InjectSnippetForEditions injects a set of snippets under a given key. 38 func InjectSnippetsForEditions(name string, snippets []ForEditions) { 39 logger.Noticef("injecting bootloader asset edition snippets for %q", name) 40 41 if err := sanitizeSnippets(snippets); err != nil { 42 panic(err) 43 } 44 registeredEditionSnippets[name] = snippets 45 }