Skip to content

Commit

Permalink
Update osbuild/image to v0.51.0
Browse files Browse the repository at this point in the history
Extend user customizations to include an expiration date. This allows
users to be configured to require password change on first login.
  • Loading branch information
andremarianiello committed Mar 26, 2024
1 parent f311adf commit bb4f711
Show file tree
Hide file tree
Showing 40 changed files with 518 additions and 179 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/labstack/gommon v0.4.2
github.com/openshift-online/ocm-sdk-go v0.1.398
github.com/oracle/oci-go-sdk/v54 v54.0.0
github.com/osbuild/images v0.47.0
github.com/osbuild/images v0.51.0
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20231117174845-e969a9dc3cd1
github.com/osbuild/pulp-client v0.1.0
github.com/prometheus/client_golang v1.18.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ github.com/openshift-online/ocm-sdk-go v0.1.398 h1:6C1mDcPxzG4jSduOaWixTTI5gSEO+
github.com/openshift-online/ocm-sdk-go v0.1.398/go.mod h1:tke8vKcE7eHKyRbkJv6qo4ljo919zhx04uyQTcgF5cQ=
github.com/oracle/oci-go-sdk/v54 v54.0.0 h1:CDLjeSejv2aDpElAJrhKpi6zvT/zhZCZuXchUUZ+LS4=
github.com/oracle/oci-go-sdk/v54 v54.0.0/go.mod h1:+t+yvcFGVp+3ZnztnyxqXfQDsMlq8U25faBLa+mqCMc=
github.com/osbuild/images v0.47.0 h1:wk0LDcQyTXOb5br8dxBcsgxTDRNnx3N2U0MKXvfN+2g=
github.com/osbuild/images v0.47.0/go.mod h1:eM/J8+hEUH0jrwcy3DtE6SDg+bRMWFZIf5d+YDyhoDY=
github.com/osbuild/images v0.51.0 h1:JXqq596RgNlI0DzRmInHEKhXS71umwArp6BVgziOvFE=
github.com/osbuild/images v0.51.0/go.mod h1:eM/J8+hEUH0jrwcy3DtE6SDg+bRMWFZIf5d+YDyhoDY=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20231117174845-e969a9dc3cd1 h1:UFEJIcPa46W8gtWgOYzriRKYyy1t6SWL0BI7fPTuVvc=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20231117174845-e969a9dc3cd1/go.mod h1:z+WA+dX6qMwc7fqY5jCzESDIlg4WR2sBQezxsoXv9Ik=
github.com/osbuild/pulp-client v0.1.0 h1:L0C4ezBJGTamN3BKdv+rKLuq/WxXJbsFwz/Hj7aEmJ8=
Expand Down
1 change: 1 addition & 0 deletions internal/blueprint/customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type UserCustomization struct {
Groups []string `json:"groups,omitempty" toml:"groups,omitempty"`
UID *int `json:"uid,omitempty" toml:"uid,omitempty"`
GID *int `json:"gid,omitempty" toml:"gid,omitempty"`
ExpireDate *int `json:"expiredate,omitempty" toml:"expiredate,omitempty"`
}

type GroupCustomization struct {
Expand Down
36 changes: 10 additions & 26 deletions internal/blueprint/customizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestCheckAllowed(t *testing.T) {
GID := 321

expectedUsers := []UserCustomization{
UserCustomization{
{
Name: "John",
Description: &Desc,
Password: &Pass,
Expand All @@ -33,7 +33,7 @@ func TestCheckAllowed(t *testing.T) {
},
}

var expectedHostname = "Hostname"
expectedHostname := "Hostname"

x := Customizations{Hostname: &expectedHostname, User: expectedUsers}

Expand All @@ -50,20 +50,17 @@ func TestCheckAllowed(t *testing.T) {
}

func TestGetHostname(t *testing.T) {

var expectedHostname = "Hostname"
expectedHostname := "Hostname"

TestCustomizations := Customizations{
Hostname: &expectedHostname,
}

retHostname := TestCustomizations.GetHostname()
assert.Equal(t, &expectedHostname, retHostname)

}

func TestGetKernel(t *testing.T) {

expectedKernel := KernelCustomization{
Append: "--test",
Name: "kernel",
Expand All @@ -79,9 +76,8 @@ func TestGetKernel(t *testing.T) {
}

func TestSSHKey(t *testing.T) {

expectedSSHKeys := []SSHKeyCustomization{
SSHKeyCustomization{
{
User: "test-user",
Key: "test-key",
},
Expand All @@ -95,11 +91,9 @@ func TestSSHKey(t *testing.T) {

assert.Equal(t, expectedSSHKeys[0].User, retUser)
assert.Equal(t, expectedSSHKeys[0].Key, retKey)

}

func TestGetUsers(t *testing.T) {

Desc := "Test descritpion"
Pass := "testpass"
Key := "testkey"
Expand All @@ -110,9 +104,10 @@ func TestGetUsers(t *testing.T) {
}
UID := 123
GID := 321
ExpireDate := 12345

expectedUsers := []UserCustomization{
UserCustomization{
{
Name: "John",
Description: &Desc,
Password: &Pass,
Expand All @@ -122,6 +117,7 @@ func TestGetUsers(t *testing.T) {
Groups: Groups,
UID: &UID,
GID: &GID,
ExpireDate: &ExpireDate,
},
}

Expand All @@ -135,10 +131,9 @@ func TestGetUsers(t *testing.T) {
}

func TestGetGroups(t *testing.T) {

GID := 1234
expectedGroups := []GroupCustomization{
GroupCustomization{
{
Name: "TestGroup",
GID: &GID,
},
Expand All @@ -154,7 +149,6 @@ func TestGetGroups(t *testing.T) {
}

func TestGetTimezoneSettings(t *testing.T) {

expectedTimezone := "testZONE"
expectedNTPServers := []string{
"server",
Expand All @@ -173,11 +167,9 @@ func TestGetTimezoneSettings(t *testing.T) {

assert.Equal(t, expectedTimezone, *retTimezone)
assert.Equal(t, expectedNTPServers, retNTPServers)

}

func TestGetPrimaryLocale(t *testing.T) {

expectedLanguages := []string{
"enUS",
}
Expand All @@ -199,7 +191,6 @@ func TestGetPrimaryLocale(t *testing.T) {
}

func TestGetFirewall(t *testing.T) {

expectedPorts := []string{"22", "9090"}

expectedServices := FirewallServicesCustomization{
Expand All @@ -224,7 +215,6 @@ func TestGetFirewall(t *testing.T) {
}

func TestGetServices(t *testing.T) {

expectedServices := ServicesCustomization{
Enabled: []string{"cockpit", "osbuild-composer"},
Disabled: []string{"sshd", "ftp"},
Expand All @@ -250,12 +240,10 @@ func TestError(t *testing.T) {
retError := expectedError.Error()

assert.Equal(t, expectedError.Message, retError)

}

// This tests calling all the functions on a Blueprint with no Customizations
func TestNoCustomizationsInBlueprint(t *testing.T) {

TestBP := Blueprint{}

assert.Nil(t, TestBP.Customizations.GetHostname())
Expand All @@ -276,16 +264,15 @@ func TestNoCustomizationsInBlueprint(t *testing.T) {

// This tests additional scenarios where GetPrimaryLocale() returns nil values
func TestNilGetPrimaryLocale(t *testing.T) {

//Case empty Customization
// Case empty Customization
TestCustomizationsEmpty := Customizations{}

retLanguage, retKeyboard := TestCustomizationsEmpty.GetPrimaryLocale()

assert.Nil(t, retLanguage)
assert.Nil(t, retKeyboard)

//Case empty Languages
// Case empty Languages
expectedKeyboard := "en"
expectedLocaleCustomization := LocaleCustomization{
Keyboard: &expectedKeyboard,
Expand All @@ -299,12 +286,10 @@ func TestNilGetPrimaryLocale(t *testing.T) {

assert.Nil(t, retLanguage)
assert.Equal(t, expectedKeyboard, *retKeyboard)

}

// This tests additional scenario where GetTimezoneSEtting() returns nil values
func TestNilGetTimezoneSettings(t *testing.T) {

TestCustomizationsEmpty := Customizations{}

retTimezone, retNTPServers := TestCustomizationsEmpty.GetTimezoneSettings()
Expand All @@ -314,7 +299,6 @@ func TestNilGetTimezoneSettings(t *testing.T) {
}

func TestGetOpenSCAPConfig(t *testing.T) {

expectedOscap := OpenSCAPCustomization{
DataStream: "test-data-stream.xml",
ProfileID: "test_profile",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/osbuild/images/pkg/distro/distro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions vendor/github.com/osbuild/images/pkg/distro/fedora/distro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bb4f711

Please sign in to comment.