-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
t/l/f/store: make the fake store aware of components (#14882)
* daemon, s/snaptest: remove errant .comp suffix that was resulting in files being named <name>.comp.comp * t/l/f/store: make the fake store aware of components * t/l/f/store: remove some dead code * tests: add new store-state make-component-installable command * t/l/f/c/fakestore: make help text on command args more clear * t/l/f/store: remove superfluous .String() call
- Loading branch information
1 parent
d2e08bc
commit 192ed07
Showing
10 changed files
with
699 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/lib/fakestore/cmd/fakestore/cmd_new_snap_resource_pair.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/snapcore/snapd/tests/lib/fakestore/refresh" | ||
) | ||
|
||
type cmdNewSnapResourcePair struct { | ||
Positional struct { | ||
Component string `description:"Path to a component blob file"` | ||
SnapResourcePairJSONPath string `description:"Path to a json encoded snap resource pair revision subset"` | ||
} `positional-args:"yes" required:"yes"` | ||
|
||
TopDir string `long:"dir" description:"Directory to be used by the store to keep and serve snaps, <dir>/asserts is used for assertions"` | ||
} | ||
|
||
func (x *cmdNewSnapResourcePair) Execute(args []string) error { | ||
content, err := os.ReadFile(x.Positional.SnapResourcePairJSONPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
headers := make(map[string]interface{}) | ||
if err := json.Unmarshal(content, &headers); err != nil { | ||
return err | ||
} | ||
|
||
p, err := refresh.NewSnapResourcePair(x.TopDir, x.Positional.Component, headers) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(p) | ||
return nil | ||
} | ||
|
||
var shortNewSnapResourcePairHelp = "Make a new snap resource pair" | ||
|
||
var longNewSnapResourcePairHelp = ` | ||
Generate a new snap resource pair signed with test keys. Snap ID, snap revision, | ||
and component revision must be provided in the given JSON file. All other | ||
headers are either derived from the component file or optional, but can be | ||
overridden via the given JSON file. | ||
` | ||
|
||
func init() { | ||
parser.AddCommand("new-snap-resource-pair", shortNewSnapResourcePairHelp, longNewSnapResourcePairHelp, | ||
&cmdNewSnapResourcePair{}) | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/lib/fakestore/cmd/fakestore/cmd_new_snap_resource_revision.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/snapcore/snapd/tests/lib/fakestore/refresh" | ||
) | ||
|
||
type cmdNewSnapResourceRevision struct { | ||
Positional struct { | ||
Component string `description:"Path to a component blob file"` | ||
SnapResourceRevJsonPath string `description:"Path to a json encoded snap resource revision subset"` | ||
} `positional-args:"yes" required:"yes"` | ||
|
||
TopDir string `long:"dir" description:"Directory to be used by the store to keep and serve snaps, <dir>/asserts is used for assertions"` | ||
} | ||
|
||
func (x *cmdNewSnapResourceRevision) Execute(args []string) error { | ||
content, err := os.ReadFile(x.Positional.SnapResourceRevJsonPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
headers := make(map[string]interface{}) | ||
if err := json.Unmarshal(content, &headers); err != nil { | ||
return err | ||
} | ||
|
||
p, err := refresh.NewSnapResourceRevision(x.TopDir, x.Positional.Component, headers) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(p) | ||
return nil | ||
} | ||
|
||
var shortNewSnapResourceRevisionHelp = "Make a new snap resource revision" | ||
|
||
var longNewSnapResourceRevisionHelp = ` | ||
Generate a new snap resource revision signed with test keys. Snap ID and | ||
revision must be provided in the given JSON file. All other headers are either | ||
derived from the component file or optional, but can be overridden via the given | ||
JSON file. | ||
` | ||
|
||
func init() { | ||
parser.AddCommand("new-snap-resource-revision", shortNewSnapResourceRevisionHelp, longNewSnapResourceRevisionHelp, | ||
&cmdNewSnapResourceRevision{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.