-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from jumppad-labs/f-copy-go-getter
Add the capability to the copy resource to copy from remote sources
- Loading branch information
Showing
10 changed files
with
164 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ jobs: | |
'/certificates', | ||
'/terraform', | ||
'/registries', | ||
"/copy" | ||
] | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource "copy" "local" { | ||
source = "${dir()}/files/foo" | ||
destination = "${data("copy")}/local" | ||
} | ||
|
||
resource "copy" "local_relative" { | ||
source = "./files/foo" | ||
destination = "${data("copy")}/local_relative" | ||
} | ||
|
||
|
||
resource "copy" "http" { | ||
source = "https://www.foundanimals.org/wp-content/uploads/2023/02/twenty20_b4e89a76-af70-4567-b92a-9c3bbf335cb3.jpg" | ||
destination = "${data("copy")}/http" | ||
} | ||
|
||
resource "copy" "git" { | ||
source = "github.com/jumppad-labs/examples" | ||
destination = "${data("copy")}/git" | ||
} | ||
|
||
resource "copy" "zip" { | ||
source = "https://releases.hashicorp.com/nomad/1.6.3/nomad_1.6.3_linux_amd64.zip" | ||
destination = "${data("copy")}/zip" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Feature: Copying files | ||
In order to test copy capabilities | ||
I should apply a blueprint | ||
And check that the files have been copied | ||
|
||
Scenario: Copy files from multiple sources | ||
Given I have a running blueprint | ||
When I run the script | ||
``` | ||
#!/bin/bash | ||
if [ ! -f $HOME/.jumppad/data/copy/local/foo ]; then | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f $HOME/.jumppad/data/copy/http/twenty20_b4e89a76-af70-4567-b92a-9c3bbf335cb3.jpg ]; then | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f $HOME/.jumppad/data/copy/git/README.md ]; then | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f $HOME/.jumppad/data/copy/zip/nomad ]; then | ||
exit 1 | ||
fi | ||
``` | ||
Then I expect the exit code to be 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"strconv" | ||
|
||
"github.com/jumppad-labs/jumppad/pkg/utils" | ||
) | ||
|
||
func customHCLFuncJumppad() (string, error) { | ||
return utils.JumppadHome(), nil | ||
} | ||
|
||
// returns the docker host ip address | ||
func customHCLFuncDockerIP() (string, error) { | ||
return utils.GetDockerIP(), nil | ||
} | ||
|
||
func customHCLFuncDockerHost() (string, error) { | ||
return utils.GetDockerHost(), nil | ||
} | ||
|
||
func customHCLFuncDataFolderWithPermissions(name string, permissions int) (string, error) { | ||
if permissions > 0 && permissions < 778 { | ||
return "", fmt.Errorf("permissions must be a three digit number less than 777") | ||
} | ||
|
||
// convert the permissions to an octal e.g. 777 to 0777 | ||
strInt := fmt.Sprintf("0%d", permissions) | ||
oInt, _ := strconv.ParseInt(strInt, 8, 32) | ||
|
||
perms := os.FileMode(uint32(oInt)) | ||
return utils.DataFolder(name, perms), nil | ||
} | ||
|
||
func customHCLFuncDataFolder(name string) (string, error) { | ||
perms := os.FileMode(0775) | ||
return utils.DataFolder(name, perms), nil | ||
} | ||
|
||
func customHCLFuncSystem(property string) (string, error) { | ||
switch property { | ||
case "os": | ||
return runtime.GOOS, nil | ||
case "arch": | ||
return runtime.GOARCH, nil | ||
default: | ||
return "", fmt.Errorf("unknown system property %s", property) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters