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
8 changes: 4 additions & 4 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
tile: ${{ github.job_id }}
title: ${{ github.job_id }}
description: "Build application"

functional_test_docker:
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
tile: ${{ github.job_id }}
title: ${{ github.job_id }}
description: "Functional tests for docker: ${{matrix.folder}}"

functional_test_podman:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
tile: ${{ github.job_id }}
title: ${{ github.job_id }}
description: "Functional tests for ${{matrix.folder}}"

release:
Expand Down Expand Up @@ -228,6 +228,6 @@ jobs:
uses: sarisia/actions-status-discord@v1
if: always()
with:
tile: ${{ github.job_id }}
title: ${{ github.job_id }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
description: "Push new version ${{ needs.github_release.outputs.version }} to Winget"
4 changes: 2 additions & 2 deletions examples/registries/build.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resource "container" "noauth" {
}

volume {
source = data("certs")
source = resource.certificate_leaf.registry.output
destination = "/certs"
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ resource "container" "auth" {
}

volume {
source = data("certs")
source = resource.certificate_leaf.registry.output
destination = "/certs"
}
}
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ module github.com/jumppad-labs/jumppad
// https://github.com/docker/cli/issues/4437
// fixed it by using docker v23.0.7-0.20230714215826-f00e7af96042+incompatible
// switch to v24.0.4+incompatible once github actions updates their docker version
go 1.23.0

toolchain go1.23.5
go 1.24.3

require (
github.com/Masterminds/semver v1.5.0
Expand Down Expand Up @@ -36,7 +34,7 @@ require (
github.com/infinytum/raymond/v2 v2.0.5
github.com/jumppad-labs/connector v0.4.0
github.com/jumppad-labs/gohup v0.4.0
github.com/jumppad-labs/hclconfig v0.28.0
github.com/jumppad-labs/hclconfig v0.29.0
github.com/jumppad-labs/plugin-sdk v0.4.0
github.com/kennygrant/sanitize v1.2.4
github.com/mattn/go-isatty v0.0.20
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,8 @@ github.com/jumppad-labs/go-cty v0.0.0-20230804061424-9e985cb751f6 h1:1ADItCWr5pr
github.com/jumppad-labs/go-cty v0.0.0-20230804061424-9e985cb751f6/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
github.com/jumppad-labs/gohup v0.4.0 h1:0OplHvnKnOLkqWm417sRHLSiJ4xGeb8LiSSAJ51QrYg=
github.com/jumppad-labs/gohup v0.4.0/go.mod h1:JYvZnemxJlWDyx8RbDNcCBLZSvIrYlYLnkQqR1BKFW4=
github.com/jumppad-labs/hclconfig v0.26.0 h1:Qg/tC2WlhKwoTW0acAY/vyUXHwCuyr4NmshKLS81How=
github.com/jumppad-labs/hclconfig v0.26.0/go.mod h1:AOzW0btnKiqUKYVi3ioGzSPNCWsTzsJxKcqzVORccvk=
github.com/jumppad-labs/hclconfig v0.28.0 h1:6V6dMrTufkLHgyFdtJHiEcDM5hp9ItVNDZf98wGpVKs=
github.com/jumppad-labs/hclconfig v0.28.0/go.mod h1:mrKi8iCDAqLwmhbOa5k1K56R4+ctsVuYveQ/sMaWYio=
github.com/jumppad-labs/hclconfig v0.29.0 h1:ZJKsei7agJ8wEx+r0iZQsOKWYxWvN8Wldd5/897xBxk=
github.com/jumppad-labs/hclconfig v0.29.0/go.mod h1:UiDq9kWaSsw5MQp0iDej2oxvo0E+Xwx7UVuEDlzetnw=
github.com/jumppad-labs/log v0.0.0-20240827082827-4404884e31a7 h1:tuoFYWXAqT5BheDlQNumY1DxvkW8bjG9JOzoxpFneZs=
github.com/jumppad-labs/log v0.0.0-20240827082827-4404884e31a7/go.mod h1:S9jhxE2C1+jv2PlLTAow3h+ZILzvXRhd6eBjFAUcfgI=
github.com/jumppad-labs/plugin-sdk v0.4.0 h1:deNk7h8W+6dsxj2ADP63o07Dv313vcBI8C4d1aBUO/c=
Expand Down Expand Up @@ -1536,8 +1534,6 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/crypto v0.34.0 h1:+/C6tk6rf/+t5DhUketUbD1aNGqiSX3j15Z6xuIDlBA=
golang.org/x/crypto v0.34.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down
2 changes: 1 addition & 1 deletion pkg/clients/container/docker_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ func copyDir(src string, dest string) error {
return err
}
if !file.IsDir() {
return fmt.Errorf("Source " + file.Name() + " is not a directory!")
return fmt.Errorf("source %s is not a directory", file.Name())
}

err = os.Mkdir(dest, 0755)
Expand Down
14 changes: 13 additions & 1 deletion pkg/config/resources/exec/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/jumppad-labs/hclconfig/convert"
htypes "github.com/jumppad-labs/hclconfig/types"
"github.com/jumppad-labs/jumppad/pkg/clients"
cmdClient "github.com/jumppad-labs/jumppad/pkg/clients/command"
Expand All @@ -18,6 +19,7 @@ import (
"github.com/jumppad-labs/jumppad/pkg/clients/logger"
"github.com/jumppad-labs/jumppad/pkg/utils"
sdk "github.com/jumppad-labs/plugin-sdk"
"github.com/zclconf/go-cty/cty"
)

// checks Provider implements the sdk.Provider interface
Expand Down Expand Up @@ -361,7 +363,17 @@ func (p *Provider) generateOutput() error {
output[parts[0]] = parts[1]
}

p.config.Output = output
values := map[string]cty.Value{}
for k, v := range output {
value, err := convert.GoToCtyValue(v)
if err != nil {
return fmt.Errorf("unable to convert output value to cty: %w", err)
}

values[k] = value
}

p.config.Output = cty.ObjectVal(values)

return nil
}
2 changes: 1 addition & 1 deletion pkg/config/resources/exec/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestParsesOutput(t *testing.T) {
err := p.Create(context.Background())
require.NoError(t, err)

require.True(t, e.Output["FOO"] == "BAR")
require.True(t, e.Output.AsValueMap()["FOO"].AsString() == "BAR")
}

func TestDeletesOutput(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions pkg/config/resources/exec/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/jumppad-labs/jumppad/pkg/config"
ctypes "github.com/jumppad-labs/jumppad/pkg/config/resources/container"
"github.com/jumppad-labs/jumppad/pkg/utils"
"github.com/zclconf/go-cty/cty"
)

// TypeExec is the resource string for an Exec resource
Expand All @@ -33,10 +34,10 @@ type Exec struct {
RunAs *ctypes.User `hcl:"run_as,block" json:"run_as,omitempty"` // User block for mapping the user id and group id inside the container

// output
PID int `hcl:"pid,optional" json:"pid,omitempty"` // PID stores the ID of the created connector service if it is a local exec
ExitCode int `hcl:"exit_code,optional" json:"exit_code,omitempty"` // Exit code of the process
Output map[string]string `hcl:"output,optional" json:"output,omitempty"` // output values returned from exec
Checksum string `hcl:"checksum,optional" json:"checksum,omitempty"` // Checksum of the script
PID int `hcl:"pid,optional" json:"pid,omitempty"` // PID stores the ID of the created connector service if it is a local exec
ExitCode int `hcl:"exit_code,optional" json:"exit_code,omitempty"` // Exit code of the process
Output cty.Value `hcl:"output,optional" json:"output,omitempty"` // output values returned from exec
Checksum string `hcl:"checksum,optional" json:"checksum,omitempty"` // Checksum of the script
}

func (e *Exec) Process() error {
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/resources/terraform/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ func (p *TerraformProvider) terraformApply(containerid string) error {
wd := path.Join("/config", p.config.WorkingDirectory)

script := `#!/bin/sh
set -e

terraform init \
-no-color
terraform apply \
Expand Down Expand Up @@ -421,6 +423,8 @@ func (p *TerraformProvider) terraformDestroy(containerid string) error {
tfvarFlag := getTerraformVarsFlag(p.config)

script := `#!/bin/sh
set -e

terraform init \
-no-color
terraform destroy \
Expand Down
20 changes: 14 additions & 6 deletions pkg/jumppad/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"
"path/filepath"
"sync"

"github.com/jumppad-labs/hclconfig"
hclerrors "github.com/jumppad-labs/hclconfig/errors"
Expand Down Expand Up @@ -43,18 +44,20 @@ type Engine interface {

// EngineImpl is responsible for creating and destroying resources
type EngineImpl struct {
providers config.Providers
log logger.Logger
config *hclconfig.Config
ctx context.Context
force bool
providers config.Providers
log logger.Logger
config *hclconfig.Config
ctx context.Context
force bool
cacheMutex sync.Mutex
}

// New creates a new Jumppad engine
func New(p config.Providers, l logger.Logger) (Engine, error) {
e := &EngineImpl{}
e.log = l
e.providers = p
e.cacheMutex = sync.Mutex{}

// Set the standard writer to our logger as the DAG uses the standard library log.
log.SetOutput(l.StandardWriter())
Expand Down Expand Up @@ -534,6 +537,7 @@ func (e *EngineImpl) createCallback(r types.Resource) error {
// to the network and set the dependency
if r.Metadata().Type == network.TypeNetwork && r.Metadata().Properties[constants.PropertyStatus] == constants.StatusCreated {
// get the image cache
e.cacheMutex.Lock()
ic, err := e.config.FindResource("resource.image_cache.default")
if err == nil {
e.log.Debug("Attaching image cache to network", "network", ic.Metadata().ID)
Expand All @@ -545,10 +549,12 @@ func (e *EngineImpl) createCallback(r types.Resource) error {
} else {
e.log.Error("Unable to find Image Cache", "error", err)
}
e.cacheMutex.Unlock()
}

if r.Metadata().Type == cache.TypeRegistry && r.Metadata().Properties[constants.PropertyStatus] == constants.StatusCreated {
// get the image cache
e.cacheMutex.Lock()
ic, err := e.config.FindResource("resource.image_cache.default")
if err == nil {
// append the registry if not all ready present and not in the default list
Expand All @@ -570,11 +576,13 @@ func (e *EngineImpl) createCallback(r types.Resource) error {
ic.(*cache.ImageCache).Registries = append(ic.(*cache.ImageCache).Registries, *r.(*cache.Registry))
}

e.log.Debug("Adding registy to image cache", "registry", r.(*cache.Registry).Hostname)
e.log.Debug("Adding registry to image cache", "registry", r.(*cache.Registry).Hostname)

// we now need to stop and restart the container to pick up the new registry changes
np := e.providers.GetProvider(ic)

e.cacheMutex.Unlock()

err := np.Destroy(e.ctx, e.force)
if err != nil {
e.log.Error("Unable to destroy Image Cache", "error", err)
Expand Down
Loading