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