deps: update osbuild/images to 157e798fdf8d
Update the osbuild/images dependency from 246b718310ea to 157e798fdf8d.
This commit is contained in:
parent
4c7b3dd25a
commit
a4798ea64d
55 changed files with 42304 additions and 41796 deletions
107
vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go
generated
vendored
107
vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go
generated
vendored
|
|
@ -1,15 +1,6 @@
|
|||
// Package blueprint contains primitives for representing weldr blueprints
|
||||
package blueprint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/osbuild/images/pkg/crypt"
|
||||
|
||||
"github.com/coreos/go-semver/semver"
|
||||
)
|
||||
|
||||
// A Blueprint is a high-level description of an image.
|
||||
type Blueprint struct {
|
||||
Name string `json:"name" toml:"name"`
|
||||
|
|
@ -49,71 +40,6 @@ type Container struct {
|
|||
TLSVerify *bool `json:"tls-verify,omitempty" toml:"tls-verify,omitempty"`
|
||||
}
|
||||
|
||||
// DeepCopy returns a deep copy of the blueprint
|
||||
// This uses json.Marshal and Unmarshal which are not very efficient
|
||||
func (b *Blueprint) DeepCopy() Blueprint {
|
||||
bpJSON, err := json.Marshal(b)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var bp Blueprint
|
||||
err = json.Unmarshal(bpJSON, &bp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bp
|
||||
}
|
||||
|
||||
// Initialize ensures that the blueprint has sane defaults for any missing fields
|
||||
func (b *Blueprint) Initialize() error {
|
||||
if len(b.Name) == 0 {
|
||||
return fmt.Errorf("empty blueprint name not allowed")
|
||||
}
|
||||
|
||||
if b.Packages == nil {
|
||||
b.Packages = []Package{}
|
||||
}
|
||||
if b.Modules == nil {
|
||||
b.Modules = []Package{}
|
||||
}
|
||||
if b.Groups == nil {
|
||||
b.Groups = []Group{}
|
||||
}
|
||||
if b.Containers == nil {
|
||||
b.Containers = []Container{}
|
||||
}
|
||||
if b.Version == "" {
|
||||
b.Version = "0.0.0"
|
||||
}
|
||||
// Return an error if the version is not valid
|
||||
_, err := semver.NewVersion(b.Version)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid 'version', must use Semantic Versioning: %s", err.Error())
|
||||
}
|
||||
|
||||
err = b.CryptPasswords()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error hashing passwords: %s", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BumpVersion increments the previous blueprint's version
|
||||
// If the old version string is not vaild semver it will use the new version as-is
|
||||
// This assumes that the new blueprint's version has already been validated via Initialize
|
||||
func (b *Blueprint) BumpVersion(old string) {
|
||||
var ver *semver.Version
|
||||
ver, err := semver.NewVersion(old)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ver.BumpPatch()
|
||||
b.Version = ver.String()
|
||||
}
|
||||
|
||||
// packages, modules, and groups all resolve to rpm packages right now. This
|
||||
// function returns a combined list of "name-version" strings.
|
||||
func (b *Blueprint) GetPackages() []string {
|
||||
|
|
@ -149,36 +75,3 @@ func (p Package) ToNameVersion() string {
|
|||
|
||||
return p.Name + "-" + p.Version
|
||||
}
|
||||
|
||||
// CryptPasswords ensures that all blueprint passwords are hashed
|
||||
func (b *Blueprint) CryptPasswords() error {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Any passwords for users?
|
||||
for i := range b.Customizations.User {
|
||||
// Missing or empty password
|
||||
if b.Customizations.User[i].Password == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Prevent empty password from being hashed
|
||||
if len(*b.Customizations.User[i].Password) == 0 {
|
||||
b.Customizations.User[i].Password = nil
|
||||
continue
|
||||
}
|
||||
|
||||
if !crypt.PasswordIsCrypted(*b.Customizations.User[i].Password) {
|
||||
pw, err := crypt.CryptSHA512(*b.Customizations.User[i].Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Replace the password with the
|
||||
b.Customizations.User[i].Password = &pw
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue