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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ winrm_insecure | bool | Optional | If true, do not check server certificate chai
winrm_use_ssl | bool | Optional | If true, use HTTPS for WinRM.
| |
timeout | string | Optional | The amount of time to wait before considering that the provisioner failed. Optional.
logging | string | Optional | to turn debug log on, pass "debug" as value. Optional.

***********

Expand Down
1 change: 1 addition & 0 deletions builder/ibmcloud/vpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Config struct {
//The format to use for the exported image. If the image is encrypted, only qcow2 is supported.
Format string `mapstructure:"format"`
SkipReboot bool `mapstructure:"skip_reboot"`
VPCLog string `mapstructure:"logging"`
}

// Prepare processes the build configuration parameters.
Expand Down
2 changes: 2 additions & 0 deletions builder/ibmcloud/vpc/config.hcl2spec.go

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

36 changes: 31 additions & 5 deletions builder/ibmcloud/vpc/step_create_vpc_service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vpc
import (
"context"
"fmt"
"log"

"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/vpc-go-sdk/vpcv1"
Expand All @@ -20,12 +21,36 @@ func (step *StepCreateVPCServiceInstance) Run(_ context.Context, state multistep

ui.Say("Creating VPC service...")

// Enable logging for IBM Cloud Go SDK core based on logging configuration
if config.VPCLog != "" {
var logLevel core.LogLevel
switch config.VPCLog {
case "error":
logLevel = core.LevelError
case "warn":
logLevel = core.LevelWarn
case "info":
logLevel = core.LevelInfo
case "debug":
logLevel = core.LevelDebug
default:
ui.Error(fmt.Sprintf("Invalid logging value '%s'. Valid values are: error, warn, info, debug", config.VPCLog))
logLevel = core.LevelError
}

logDestination := log.Writer()
goLogger := log.New(logDestination, "", log.LstdFlags)
core.SetLogger(core.NewLogger(logLevel, goLogger, goLogger))
}

authenticator := &core.IamAuthenticator{
ApiKey: client.IBMApiKey,
URL: config.IAMEndpoint,
}

options := &vpcv1.VpcV1Options{
Authenticator: &core.IamAuthenticator{
ApiKey: client.IBMApiKey,
URL: config.IAMEndpoint,
},
URL: config.Endpoint,
Authenticator: authenticator,
URL: config.Endpoint,
}
vpcService, serviceErr := vpcv1.NewVpcV1(options)

Expand All @@ -35,6 +60,7 @@ func (step *StepCreateVPCServiceInstance) Run(_ context.Context, state multistep
ui.Error(err.Error())
return multistep.ActionHalt
}

state.Put("vpcService", vpcService)
ui.Say("VPC service creation successful!")
return multistep.ActionContinue
Expand Down
32 changes: 17 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module packer-plugin-ibmcloud
go 1.25.0

require (
github.com/IBM/go-sdk-core/v5 v5.19.0
github.com/IBM/platform-services-go-sdk v0.37.4
github.com/IBM/vpc-go-sdk v0.68.0
github.com/IBM/go-sdk-core/v5 v5.21.2
github.com/IBM/platform-services-go-sdk v0.97.4
github.com/IBM/vpc-go-sdk v0.83.2
github.com/hashicorp/hcl/v2 v2.14.1
github.com/hashicorp/packer-plugin-sdk v0.2.9
github.com/zclconf/go-cty v1.9.1
golang.org/x/crypto v0.49.0
golang.org/x/crypto v0.51.0
)

require (
Expand All @@ -20,18 +20,18 @@ require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-metrics v0.3.9 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go v1.40.34 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/dylanmei/iso8601 v0.1.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
github.com/go-openapi/errors v0.22.4 // indirect
github.com/go-openapi/strfmt v0.25.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.24.0 // indirect
github.com/go-playground/validator/v10 v10.28.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -48,7 +48,7 @@ require (
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
Expand Down Expand Up @@ -82,14 +82,15 @@ require (
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
go.mongodb.org/mongo-driver v1.17.2 // indirect
go.mongodb.org/mongo-driver v1.17.6 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.51.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/term v0.41.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/term v0.43.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/api v0.56.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand All @@ -98,4 +99,5 @@ require (
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading