Update dagger new cmd to specify architecture when creating an environment

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-10-22 21:54:18 +02:00
parent caa03a37cc
commit e9de597654
3 changed files with 12 additions and 5 deletions

View File

@@ -240,7 +240,7 @@ func (w *Project) Save(ctx context.Context, st *State) error {
return nil
}
func (w *Project) Create(ctx context.Context, name string, plan Plan) (*State, error) {
func (w *Project) Create(ctx context.Context, name string, plan Plan, arch string) (*State, error) {
if _, err := w.Get(ctx, name); err == nil {
return nil, ErrExist
}
@@ -262,6 +262,10 @@ func (w *Project) Create(ctx context.Context, name string, plan Plan) (*State, e
manifestPath := path.Join(envPath, manifestFile)
if arch == "" {
arch = platforms.Format(platforms.DefaultSpec())
}
st := &State{
Path: envPath,
Project: w.Path,
@@ -269,7 +273,7 @@ func (w *Project) Create(ctx context.Context, name string, plan Plan) (*State, e
Package: pkg,
},
Name: name,
Architecture: platforms.DefaultString(),
Architecture: arch,
}
data, err := yaml.Marshal(st)

View File

@@ -32,9 +32,10 @@ func TestProject(t *testing.T) {
// Create
st, err := project.Create(ctx, "test", Plan{
Module: ".",
})
}, "linux/amd64")
require.NoError(t, err)
require.Equal(t, "test", st.Name)
require.Equal(t, "linux/amd64", st.Architecture)
// Open
project, err = Open(ctx, root)
@@ -51,6 +52,7 @@ func TestProject(t *testing.T) {
env, err := project.Get(ctx, "test")
require.NoError(t, err)
require.Equal(t, "test", env.Name)
require.Equal(t, "linux/amd64", env.Architecture)
// Save
require.NoError(t, env.SetInput("foo", TextInput("bar")))
@@ -82,7 +84,7 @@ func TestEncryption(t *testing.T) {
_, err = project.Create(ctx, "test", Plan{
Module: ".",
})
}, "linux/amd64")
require.NoError(t, err)
// Set a plaintext input, make sure it is not encrypted