Skip to content

Commit

Permalink
Change WAR to JAR file upload (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Jul 11, 2024
1 parent 0134688 commit 2ece32b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .web-docs/components/provisioner/webservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
be helpful to a user. See https://www.packer.io/docs/provisioner/null
-->

The `webservice` provisioner is used to install Jersey-Jetty webservice WAR file in AWS AMI image
The `webservice` provisioner is used to install Spring Boot webservice JAR file in AWS AMI image


<!-- Provisioner Configuration Fields -->

**Required**

- `warSource` (string) - The path to a local WAR file to upload to the machine. The path can be absolute or relative. If
- `jarSource` (string) - The path to a local JAR file to upload to the machine. The path can be absolute or relative. If
it is relative, it is relative to the working directory when Packer is executed.


Expand Down Expand Up @@ -76,7 +76,7 @@ build {
provisioner "paion-data-webservice-provisioner" {
homeDir = "/home/ubuntu"
warSource = "my-webservice.war"
jarSource = "my-webservice.jar"
}
}
```
6 changes: 3 additions & 3 deletions docs/provisioners/webservice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Type: `webservice`
be helpful to a user. See https://www.packer.io/docs/provisioners/null
-->

The `webservice` provisioner is used to install Jersey-Jetty webservice WAR file in AWS AMI image
The `webservice` provisioner is used to install Spring Boot webservice JAR file in AWS AMI image


<!-- Provisioner Configuration Fields -->

**Required**

- `warSource` (string) - The path to a local WAR file to upload to the machine. The path can be absolute or relative. If
- `jarSource` (string) - The path to a local JAR file to upload to the machine. The path can be absolute or relative. If
it is relative, it is relative to the working directory when Packer is executed.


Expand Down Expand Up @@ -79,7 +79,7 @@ build {

provisioner "paion-data-webservice-provisioner" {
homeDir = "/home/ubuntu"
warSource = "my-webservice.war"
jarSource = "my-webservice.jar"
}
}
```
6 changes: 3 additions & 3 deletions provisioner/webservice/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

type Config struct {
WarSource string `mapstructure:"warSource" required:"true"`
JarSource string `mapstructure:"jarSource" required:"true"`
HomeDir string `mapstructure:"homeDir" required:"false"`

ctx interpolate.Context
Expand All @@ -45,9 +45,9 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, communicator packersdk.Communicator, generatedData map[string]interface{}) error {
p.config.HomeDir = ssl.GetHomeDir(p.config.HomeDir)

warFileDst := fmt.Sprintf(filepath.Join(p.config.HomeDir, "ROOT.war"))
jarFileDst := fmt.Sprintf(filepath.Join(p.config.HomeDir, "webservice.jar"))

err := file.Provision(p.config.ctx, ui, communicator, p.config.WarSource, warFileDst)
err := file.Provision(p.config.ctx, ui, communicator, p.config.JarSource, jarFileDst)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions provisioner/webservice/provisioner.hcl2spec.go

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

4 changes: 2 additions & 2 deletions provisioner/webservice/provisioner_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
var testProvisionerHCL2Docker string

func TestAccWebserviceProvisioner(t *testing.T) {
tempFile, err := os.CreateTemp(t.TempDir(), "my-webservice.war")
tempFile, err := os.CreateTemp(t.TempDir(), "my-webservice.jar")
if err != nil {
return
}
Expand All @@ -33,7 +33,7 @@ func TestAccWebserviceProvisioner(t *testing.T) {
Teardown: func() error {
return nil
},
Template: strings.Replace(testProvisionerHCL2Docker, "my-webservice.war", tempFile.Name(), -1),
Template: strings.Replace(testProvisionerHCL2Docker, "my-webservice.jar", tempFile.Name(), -1),
Type: "paion-data-webservice-provisioner",
Check: func(buildCommand *exec.Cmd, logfile string) error {
if buildCommand.ProcessState != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ build {

provisioner "paion-data-webservice-provisioner" {
homeDir = "/"
warSource = "my-webservice.war"
jarSource = "my-webservice.jar"
}
}

0 comments on commit 2ece32b

Please sign in to comment.