osbuild2: new stage authconfig

This stage was introduced in osbuild 41. Add support into
osbuild-composer.
This commit is contained in:
Martin Sehnoutka 2021-11-09 14:11:47 +01:00 committed by Tomáš Hozza
parent 85df63ce52
commit 59be127daf
4 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,13 @@
package osbuild2
type AuthconfigStageOptions struct {
}
func (AuthconfigStageOptions) isStageOptions() {}
func NewAuthconfigStage(options *AuthconfigStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.authconfig",
Options: options,
}
}

View file

@ -0,0 +1,16 @@
package osbuild2
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewAuthconfigStage(t *testing.T) {
expectedStage := &Stage{
Type: "org.osbuild.authconfig",
Options: &AuthconfigStageOptions{},
}
actualStage := NewAuthconfigStage(&AuthconfigStageOptions{})
assert.Equal(t, expectedStage, actualStage)
}

View file

@ -148,6 +148,8 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
inputs = new(FilesInputs)
case "org.osbuild.sshd.config":
options = new(SshdConfigStageOptions)
case "org.osbuild.authconfig":
options = new(AuthconfigStageOptions)
default:
return fmt.Errorf("unexpected stage type: %s", rawStage.Type)
}

View file

@ -647,6 +647,16 @@ func TestStage_UnmarshalJSON(t *testing.T) {
data: []byte(`{"type":"org.osbuild.sshd.config","options":{"config":{}}}`),
},
},
{
name: "authconfig",
fields: fields{
Type: "org.osbuild.authconfig",
Options: &AuthconfigStageOptions{},
},
args: args{
data: []byte(`{"type":"org.osbuild.authconfig","options":{}}`),
},
},
}
for idx, tt := range tests {
t.Run(tt.name, func(t *testing.T) {