Skip to content

Migrates buildpack to use switchblade test harness #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 10 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"stack": "cflinuxfs3",
"stack": "cflinuxfs4",
"oses": [
"linux"
],
"integration": {
"harness": "ginkgo",
"harness": "switchblade",
"matrix": [
{ "cached": false, "parallel": true },
{ "cached": true, "parallel": true }
{
"cached": false,
"parallel": true
},
{
"cached": true,
"parallel": true
}
]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions fixtures/util/dynatrace/fake_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"revision":1234567890,
"properties":
[
{
"section":"fakesection",
"key":"fakekey",
"value":"fakevalue"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module myapp

go 1.13
go 1.17
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand All @@ -12,46 +11,35 @@ import (
)

func main() {
var application struct {
ApplicationURIs []string `json:"application_uris"`
}

err := json.Unmarshal([]byte(os.Getenv("VCAP_APPLICATION")), &application)
if err != nil {
log.Fatalf("failed to parse VCAP_APPLICATION: %s", err)
}

http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
var withoutAgentPath bool
path := req.URL.Path

uri := application.ApplicationURIs[0]

if strings.HasPrefix(path, "/without-agent-path") {
uri = fmt.Sprintf("%s/without-agent-path", uri)
path = strings.TrimPrefix(path, "/without-agent-path")
withoutAgentPath = true
}

switch path {
case "/v1/deployment/installer/agent/unix/paas-sh/latest":
context := struct{ URI string }{URI: uri}
context := struct{ URI string }{URI: req.Host}
t := template.Must(template.New("install.sh").ParseFiles("install.sh"))
err := t.Execute(w, context)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
fmt.Fprint(w, err.Error())
return
}

case "/dynatrace-env.sh", "/liboneagentproc.so", "/ruxitagentproc.conf":
contents, err := ioutil.ReadFile(strings.TrimPrefix(req.URL.Path, "/"))
contents, err := os.ReadFile(strings.TrimPrefix(req.URL.Path, "/"))
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
fmt.Fprint(w, err.Error())
return
}
w.Write(contents)

fmt.Fprintf(w, "%s", contents)

case "/manifest.json":
var payload map[string]interface{}
Expand Down Expand Up @@ -80,7 +68,7 @@ func main() {
json.NewEncoder(w).Encode(payload)

case "/v1/deployment/installer/agent/processmoduleconfig":
fakeConfig, err := ioutil.ReadFile("fake_config.json")
fakeConfig, err := os.ReadFile("fake_config.json")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
Expand Down
19 changes: 17 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,38 +1,53 @@
module github.com/cloudfoundry/nginx-buildpack

go 1.22.5
go 1.23.0

toolchain go1.24.0

require (
github.com/Dynatrace/libbuildpack-dynatrace v1.8.0
github.com/cloudfoundry/libbuildpack v0.0.0-20240717165421-f2ae8069fcba
github.com/cloudfoundry/switchblade v0.9.0
github.com/golang/mock v1.6.0
github.com/miekg/dns v1.1.62
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.36.2
github.com/sclevine/spec v1.4.0
gopkg.in/yaml.v2 v2.4.0
)

require (
code.cloudfoundry.org/lager v2.0.0+incompatible // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elazarl/goproxy v1.2.8 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/paketo-buildpacks/packit v1.3.1 // indirect
github.com/paketo-buildpacks/packit/v2 v2.16.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.29.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading