Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoCMoraes committed May 23, 2024
1 parent 97bd586 commit 9dcafaa
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 26 deletions.
4 changes: 3 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ func generateFakePlugins(dirname string, pluginNames []string) (string, []string
return dir, plugins, cleanUpFunc, nil
}

/* generateFakePackerConfigData creates a collection of mock plugins along with a basic packerconfig.
/*
generateFakePackerConfigData creates a collection of mock plugins along with a basic packerconfig.
The return packerConfigData is a valid packerconfig file that can be used for configuring external plugins, cleanUpFunc is a function that should be called for cleaning up any generated mock data.
This function will only clean up if there is an error, on successful runs the caller
is responsible for cleaning up the data via cleanUpFunc().
Expand Down
7 changes: 4 additions & 3 deletions hcl2template/addrs/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ func IsPluginPartNormalized(str string) (bool, error) {
// This is intended primarily to parse the FQN-like strings
//
// The following are valid source string formats:
// name
// namespace/name
// hostname/namespace/name
//
// name
// namespace/name
// hostname/namespace/name
func ParsePluginSourceString(str string) (*Plugin, hcl.Diagnostics) {
ret := &Plugin{
Hostname: "",
Expand Down
1 change: 0 additions & 1 deletion hcl2template/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
//
// Checkout the files in testdata/complete/ to see what a packer config could
// look like.
//
package hcl2template
1 change: 0 additions & 1 deletion hcl2template/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
// basedir is used with file functions and allows a user to reference a file
// using local path. Usually basedir is the directory in which the config file
// is located
//
func Functions(basedir string) map[string]function.Function {

funcs := map[string]function.Function{
Expand Down
11 changes: 6 additions & 5 deletions hcl2template/types.source.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ func (b *SourceUseBlock) ctyValues() map[string]cty.Value {
}

// decodeBuildSource reads a used source block from a build:
// build {
// source "type.example" {
// name = "local_name"
// }
// }
//
// build {
// source "type.example" {
// name = "local_name"
// }
// }
func (p *Parser) decodeBuildSource(block *hcl.Block) (SourceUseBlock, hcl.Diagnostics) {
ref := sourceRefFromString(block.Labels[0])
out := SourceUseBlock{SourceRef: ref}
Expand Down
12 changes: 6 additions & 6 deletions internal/hcp/api/mock_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"google.golang.org/grpc/status"
)

//MockPackerClientService represents a basic mock of the Cloud Packer Service.
//Upon calling a service method a boolean is set to true to indicate that a method has been called.
//To skip the setting of these booleans set TrackCalledServiceMethods to false; defaults to true in NewMockPackerClientService().
// MockPackerClientService represents a basic mock of the Cloud Packer Service.
// Upon calling a service method a boolean is set to true to indicate that a method has been called.
// To skip the setting of these booleans set TrackCalledServiceMethods to false; defaults to true in NewMockPackerClientService().
type MockPackerClientService struct {
CreateBucketCalled, UpdateBucketCalled, BucketAlreadyExist bool
CreateIterationCalled, GetIterationCalled, IterationAlreadyExist, IterationCompleted bool
Expand All @@ -36,9 +36,9 @@ type MockPackerClientService struct {
packerSvc.ClientService
}

//NewMockPackerClientService returns a basic mock of the Cloud Packer Service.
//Upon calling a service method a boolean is set to true to indicate that a method has been called.
//To skip the setting of these booleans set TrackCalledServiceMethods to false. By default it is true.
// NewMockPackerClientService returns a basic mock of the Cloud Packer Service.
// Upon calling a service method a boolean is set to true to indicate that a method has been called.
// To skip the setting of these booleans set TrackCalledServiceMethods to false. By default it is true.
func NewMockPackerClientService() *MockPackerClientService {
m := MockPackerClientService{
ExistingBuilds: make([]string, 0),
Expand Down
6 changes: 3 additions & 3 deletions internal/hcp/registry/types.iterations.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ func GetGitFingerprint(opts IterationOptions) (string, error) {
return ref.Hash().String(), nil
}

//StoreBuild stores a build for buildName to an active iteration.
// StoreBuild stores a build for buildName to an active iteration.
func (i *Iteration) StoreBuild(buildName string, build *Build) {
i.builds.Store(buildName, build)
}

//Build gets the store build associated with buildName in the active iteration.
// Build gets the store build associated with buildName in the active iteration.
func (i *Iteration) Build(buildName string) (*Build, error) {
build, ok := i.builds.Load(buildName)
if !ok {
Expand All @@ -117,7 +117,7 @@ func (i *Iteration) Build(buildName string) (*Build, error) {
return b, nil
}

//HasBuild checks if iteration has a stored build associated with buildName.
// HasBuild checks if iteration has a stored build associated with buildName.
func (i *Iteration) HasBuild(buildName string) bool {
_, ok := i.builds.Load(buildName)

Expand Down
2 changes: 1 addition & 1 deletion packer/plugin-getter/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ func (e ChecksumFileEntry) Os() string { return e.os }
func (e ChecksumFileEntry) Arch() string { return e.arch }

// a file inside will look like so:
// packer-plugin-comment_v0.2.12_x5.0_freebsd_amd64.zip
//
// packer-plugin-comment_v0.2.12_x5.0_freebsd_amd64.zip
func (e *ChecksumFileEntry) init(req *Requirement) (err error) {
filename := e.Filename
res := strings.TrimPrefix(filename, req.FilenamePrefix())
Expand Down
2 changes: 1 addition & 1 deletion provisioner/windows-shell/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/tmp"
)

//FIXME query remote host or use %SYSTEMROOT%, %TEMP% and more creative filename
// FIXME query remote host or use %SYSTEMROOT%, %TEMP% and more creative filename
const DefaultRemotePath = "c:/Windows/Temp/script.bat"

type Config struct {
Expand Down
8 changes: 4 additions & 4 deletions scripts/generate-plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ type plugin struct {
// makeMap creates a map named Name with type packer.Name that looks something
// like this:
//
// var Builders = map[string]packersdk.Builder{
// "amazon-chroot": new(chroot.Builder),
// "amazon-ebs": new(ebs.Builder),
// "amazon-instance": new(instance.Builder),
// var Builders = map[string]packersdk.Builder{
// "amazon-chroot": new(chroot.Builder),
// "amazon-ebs": new(ebs.Builder),
// "amazon-instance": new(instance.Builder),
func makeMap(varName, varType string, items []plugin) string {
output := ""

Expand Down

0 comments on commit 9dcafaa

Please sign in to comment.