Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builder/bsu/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (b *Builder) Run(
state.Put("ui", ui)

steps := []multistep.Step{
&osccommon.StepCheckAuth{},
&osccommon.StepPreValidate{
DestOmiName: b.config.OMIName,
ForceDeregister: b.config.OMIForceDeregister,
Expand Down
1 change: 1 addition & 0 deletions builder/bsusurrogate/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (b *Builder) Run(
launchOSCDevices := b.config.BuildOSCLaunchDevices()

steps := []multistep.Step{
&osccommon.StepCheckAuth{},
&osccommon.StepPreValidate{
DestOmiName: b.config.OMIName,
ForceDeregister: b.config.OMIForceDeregister,
Expand Down
1 change: 1 addition & 0 deletions builder/bsuvolume/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (b *Builder) Run(

// Build the steps
steps := []multistep.Step{
&osccommon.StepCheckAuth{},
&osccommon.StepSourceOMIInfo{
SourceOmi: b.config.SourceOmi,
OmiFilters: b.config.SourceOmiFilter,
Expand Down
1 change: 1 addition & 0 deletions builder/chroot/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (b *Builder) Run(

// Build the steps
steps := []multistep.Step{
&osccommon.StepCheckAuth{},
&osccommon.StepPreValidate{
DestOmiName: b.config.OMIName,
ForceDeregister: b.config.OMIForceDeregister,
Expand Down
33 changes: 33 additions & 0 deletions builder/common/step_check_auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package common

import (
"context"
"errors"

"github.com/hashicorp/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/outscale/goutils/sdk/auth"
)

// StepCheckAuth validates that the authentication is valid
type StepCheckAuth struct{}

var checkCredentials = auth.CheckCredentials

func (s *StepCheckAuth) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packersdk.Ui)
conn := state.Get("osc").(*OscClient)

ui.Say("Validating configured credentials")

err := checkCredentials(ctx, conn)
if err != nil {
state.Put("error", errors.New("OUTSCALE API authentication failed; verify your credentials and region configuration"))
ui.Error(err.Error())
return multistep.ActionHalt
}

return multistep.ActionContinue
}

func (s *StepCheckAuth) Cleanup(multistep.StateBag) {}
2 changes: 1 addition & 1 deletion datasource/omi/data_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestAccDatasource_OutscaleOmi(t *testing.T) {
const testBuilderAccBasicDataSource = `
data "outscale-omi" "test" {
filters = {
image-name = "RockyLinux-8-*"
image-name = "RockyLinux-10-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/hashicorp/hcl/v2 v2.24.0
github.com/hashicorp/packer-plugin-sdk v0.6.8
github.com/mitchellh/mapstructure v1.5.0
github.com/outscale/goutils/sdk v0.0.3
github.com/outscale/goutils/sdk v0.0.5
github.com/outscale/osc-sdk-go/v3 v3.0.0-rc.2
github.com/zclconf/go-cty v1.18.1
golang.org/x/sys v0.45.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ github.com/nywilken/go-cty v1.13.3 h1:03U99oXf3j3g9xgqAE3YGpixCjM8Mg09KZ0Ji9LzX0
github.com/nywilken/go-cty v1.13.3/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
github.com/oapi-codegen/runtime v1.3.1 h1:RgDY6J4OGQLbRXhG/Xpt3vSVqYpHQS7hN4m85+5xB9g=
github.com/oapi-codegen/runtime v1.3.1/go.mod h1:kOdeacKy7t40Rclb1je37ZLFboFxh+YLy0zaPCMibPY=
github.com/outscale/goutils/sdk v0.0.3 h1:LnMuNUhQW8YgKDFH9vHTtstND3igHDbHDHPsaFsKFZ0=
github.com/outscale/goutils/sdk v0.0.3/go.mod h1:2Ae3lIQmdOC+n/VnOABrzS+kpjq/Hm0PJQhABpiFW8M=
github.com/outscale/goutils/sdk v0.0.5 h1:UVu7uC38VOSCPqeCORsw1rKWaoHrsv+TTp6TGUHenjo=
github.com/outscale/goutils/sdk v0.0.5/go.mod h1:LiXmAIA3CAXCdanEARKQ3Q/Lb8n8dKeGSbPRxIe43kc=
github.com/outscale/osc-sdk-go/v3 v3.0.0-rc.2 h1:uj8s4jaqqzq2hFqQVAB6PTVwuPm43e5Ti/ZFQqvCAB0=
github.com/outscale/osc-sdk-go/v3 v3.0.0-rc.2/go.mod h1:Yi0j2XAZ0/8g0ObVFofMSL5+IuNIDp/AiEI6gXc7txc=
github.com/packer-community/winrmcp v0.0.0-20221126162354-6e900dd2c68f h1:sWm3fnjG6kxvDuGiQf46Io5xCTj3QJfNJIeICJ4g1kw=
Expand Down
8 changes: 1 addition & 7 deletions internal/testacc/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testacc

import (
"fmt"
"os"
"os/exec"
)

Expand All @@ -11,10 +10,5 @@ func CheckWithLogs(buildCommand *exec.Cmd, logfile string) error {
return nil
}

logs, err := os.ReadFile(logfile) //nolint:gosec
if err != nil {
return fmt.Errorf("bad exit code. logfile: %s (failed to read logs: %w)", logfile, err)
}

return fmt.Errorf("bad exit code. logfile: %s\n%s", logfile, string(logs))
return fmt.Errorf("bad exit code. logfile: %s", logfile)
}
Loading