-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from amp-buildpacks/feat/issue-3
issue(#3): Rewrite using Go
- Loading branch information
Showing
11 changed files
with
458 additions
and
68 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) The Amphitheatre Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
bin/ | ||
dependencies/ | ||
package/ | ||
scratch/ |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,21 +1,57 @@ | ||
api = "0.10" | ||
# Copyright (c) The Amphitheatre Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
api = "0.8" | ||
|
||
[buildpack] | ||
description = "A Cloud Native Buildpack with an order definition suitable for solc applications" | ||
description = "A Cloud Native Buildpack with an order definition suitable for Solc applications" | ||
homepage = "https://github.com/amp-buildpacks/solc" | ||
id = "amp-buildpacks/solc" | ||
keywords = ["solc", "composite"] | ||
name = "Solc Build Pack" | ||
keywords = ["solc", "Solidity"] | ||
sbom-formats = ["application/vnd.cyclonedx+json", "application/vnd.syft+json"] | ||
name = "Paketo Buildpack for Solc" | ||
version = "0.1.0" | ||
|
||
[[buildpack.licenses]] | ||
type = "Apache-2.0" | ||
uri = "https://github.com/amp-buildpacks/solc/blob/main/LICENSE" | ||
|
||
# Targets the buildpack will work with | ||
[[targets]] | ||
os = "linux" | ||
[metadata] | ||
include-files = ["LICENSE", "README.md", "bin/build", "bin/detect", "bin/main", "buildpack.toml"] | ||
pre-package = "scripts/build.sh" | ||
|
||
[[metadata.configurations]] | ||
build = true | ||
default = "false" | ||
description = "enable the Solidity run process" | ||
name = "BP_ENABLE_SOLC_PROCESS" | ||
|
||
# from https://github.com/paketo-buildpacks/node-engine/blob/main/buildpack.toml | ||
[[metadata.dependencies]] | ||
checksum = "sha256:3fe4ec5d70c8b4ffc1461dec83ab23fc70124e137c4cbbe1ccc9d6ae6ec04a7d" | ||
cpe = "cpe:2.3:a:nodejs:node.js:20.10.0:*:*:*:*:*:*:*" | ||
deprecation_date = "2026-04-30T00:00:00Z" | ||
id = "node" | ||
licenses = ["0BSD", "Apache-2.0", "Artistic-2.0", "BSD-2-Clause", "BSD-3-Clause", "BSD-4-Clause", "BSD-Source-Code", "CC0-1.0", "ECL-2.0", "ICU", "MIT", "MIT-0", "SHL-0.5", "SHL-0.51", "Unicode-TOU"] | ||
name = "Node Engine" | ||
purl = "pkg:generic/node@v20.10.0?checksum=3fe4ec5d70c8b4ffc1461dec83ab23fc70124e137c4cbbe1ccc9d6ae6ec04a7d&download_url=https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz" | ||
source = "https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz" | ||
source-checksum = "sha256:3fe4ec5d70c8b4ffc1461dec83ab23fc70124e137c4cbbe1ccc9d6ae6ec04a7d" | ||
stacks = ["io.buildpacks.stacks.jammy", "*"] | ||
strip-components = 1 | ||
uri = "https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz" | ||
version = "20.10.0" | ||
|
||
# Stacks (deprecated) the buildpack will work with | ||
[[stacks]] | ||
id = "io.buildpacks.samples.stacks.jammy" | ||
id = "*" |
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,30 @@ | ||
// Copyright (c) The Amphitheatre Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
solc "github.com/amp-buildpacks/solc/solc" | ||
"github.com/buildpacks/libcnb" | ||
"github.com/paketo-buildpacks/libpak/bard" | ||
) | ||
|
||
func main() { | ||
libcnb.Main( | ||
solc.Detect{}, | ||
solc.Build{Logger: bard.NewLogger(os.Stdout)}, | ||
) | ||
} |
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,23 @@ | ||
module github.com/amp-buildpacks/solc | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/buildpacks/libcnb v1.30.1 | ||
github.com/paketo-buildpacks/libpak v1.68.0 | ||
) | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.3.2 // indirect | ||
github.com/Masterminds/semver/v3 v3.2.1 // indirect | ||
github.com/creack/pty v1.1.20 // indirect | ||
github.com/h2non/filetype v1.1.3 // indirect | ||
github.com/heroku/color v0.0.6 // indirect | ||
github.com/imdario/mergo v0.3.16 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect | ||
github.com/onsi/gomega v1.30.0 // indirect | ||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect | ||
golang.org/x/sys v0.14.0 // indirect | ||
) |
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,47 @@ | ||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= | ||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= | ||
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= | ||
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= | ||
github.com/buildpacks/libcnb v1.30.1 h1:airpkZzh8Mlt+SQEMTj0B1r5agDHZvgfpwzpKVMEgZQ= | ||
github.com/buildpacks/libcnb v1.30.1/go.mod h1:JU2fam/ECXw6I5iRnZbfKgjWsrZbzbgvZHR6WBSVHRc= | ||
github.com/creack/pty v1.1.20 h1:VIPb/a2s17qNeQgDnkfZC35RScx+blkKF8GV68n80J4= | ||
github.com/creack/pty v1.1.20/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= | ||
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= | ||
github.com/heroku/color v0.0.6 h1:UTFFMrmMLFcL3OweqP1lAdp8i1y/9oHqkeHjQ/b/Ny0= | ||
github.com/heroku/color v0.0.6/go.mod h1:ZBvOcx7cTF2QKOv4LbmoBtNl5uB17qWxGuzZrsi1wLU= | ||
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= | ||
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= | ||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= | ||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= | ||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= | ||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | ||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= | ||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= | ||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= | ||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= | ||
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= | ||
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= | ||
github.com/paketo-buildpacks/libpak v1.68.0 h1:unfJscVujFT8WZgUONMh4vp64x+LvAz6kwpPdagYibM= | ||
github.com/paketo-buildpacks/libpak v1.68.0/go.mod h1:Np94HbeUNYcMmaJEnaP5VgqGgaz86RhWA9nONRCN96U= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= | ||
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= | ||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= | ||
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= | ||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= | ||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/amp-buildpacks/solc/cmd/main | ||
|
||
if [ "${STRIP:-false}" != "false" ]; then | ||
strip bin/main | ||
fi | ||
|
||
if [ "${COMPRESS:-none}" != "none" ]; then | ||
$COMPRESS bin/main | ||
fi | ||
|
||
ln -fs main bin/build | ||
ln -fs main bin/detect |
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,66 @@ | ||
// Copyright (c) The Amphitheatre Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package solc | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/buildpacks/libcnb" | ||
"github.com/paketo-buildpacks/libpak" | ||
"github.com/paketo-buildpacks/libpak/bard" | ||
) | ||
|
||
type Build struct { | ||
Logger bard.Logger | ||
} | ||
|
||
func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) { | ||
b.Logger.Title(context.Buildpack) | ||
result := libcnb.NewBuildResult() | ||
|
||
cr, err := libpak.NewConfigurationResolver(context.Buildpack, &b.Logger) | ||
if err != nil { | ||
return libcnb.BuildResult{}, fmt.Errorf("unable to create configuration resolver\n%w", err) | ||
} | ||
|
||
dc, err := libpak.NewDependencyCache(context) | ||
if err != nil { | ||
return libcnb.BuildResult{}, fmt.Errorf("unable to create dependency cache\n%w", err) | ||
} | ||
dc.Logger = b.Logger | ||
|
||
dr, err := libpak.NewDependencyResolver(context) | ||
if err != nil { | ||
return libcnb.BuildResult{}, fmt.Errorf("unable to create dependency resolver\n%w", err) | ||
} | ||
|
||
// install solc | ||
nodeDependency, err := dr.Resolve("node", "") | ||
if err != nil { | ||
return libcnb.BuildResult{}, fmt.Errorf("unable to find dependency\n%w", err) | ||
} | ||
|
||
solcLayer := NewSolc(nodeDependency, dc) | ||
solcLayer.Logger = b.Logger | ||
|
||
enableProcess, _ := cr.Resolve("BP_ENABLE_SOLC_PROCESS") | ||
result.Processes, err = solcLayer.BuildProcessTypes(enableProcess) | ||
if err != nil { | ||
return libcnb.BuildResult{}, fmt.Errorf("unable to build list of process types\n%w", err) | ||
} | ||
result.Layers = append(result.Layers, solcLayer) | ||
|
||
return result, nil | ||
} |
Oops, something went wrong.