Skip to content

Commit

Permalink
Merge pull request #3 from amp-buildpacks/rename
Browse files Browse the repository at this point in the history
Rename sway to forc
  • Loading branch information
wangeguo authored Sep 12, 2024
2 parents 56d1742 + 9b9ed44 commit 266c7bb
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ github:
token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}

package:
repositories: ["ghcr.io/amp-buildpacks/sway"]
repositories: ["ghcr.io/amp-buildpacks/forc"]
register: false
registry_token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pb-create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
--format "${FORMAT}" $([ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ] && echo "--publish")
fi
env:
PACKAGES: ghcr.io/amp-buildpacks/sway
PACKAGES: ghcr.io/amp-buildpacks/forc
PUBLISH: "true"
VERSION: ${{ steps.version.outputs.version }}
VERSION_MAJOR: ${{ steps.version.outputs.version-major }}
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
- if: ${{ false }}
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.7.2
with:
address: ghcr.io/amp-buildpacks/sway@${{ steps.package.outputs.digest }}
id: amp-buildpacks/sway
address: ghcr.io/amp-buildpacks/forc@${{ steps.package.outputs.digest }}
id: amp-buildpacks/forc
token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}
version: ${{ steps.version.outputs.version }}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# `ghcr.io/amp-buildpacks/sway`
# `ghcr.io/amp-buildpacks/forc`

A Cloud Native Buildpack that provides the Sway Tool Suite
A Cloud Native Buildpack that provides the Forc Tool Suite

## Configuration

| Environment Variable | Description |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$BP_SWAY_VERSION` | Configure the version of Sway to install. It can be a specific version or a wildcard like `1.*`. It defaults to the latest `1.*` version. |
| `$BP_FORC_VERSION` | Configure the version of Forc to install. It can be a specific version or a wildcard like `1.*`. It defaults to the latest `1.*` version. |


## Usage
Expand All @@ -15,17 +15,17 @@ A Cloud Native Buildpack that provides the Sway Tool Suite

```shell
pack build <image-name> \
--path <sway-samples-path> \
--buildpack ghcr.io/amp-buildpacks/sway \
--path <forc-samples-path> \
--buildpack ghcr.io/amp-buildpacks/forc \
--builder paketobuildpacks/builder-jammy-base
```

For example:

```shell
pack build sway-sample \
--path ./samples/sway \
--buildpack ghcr.io/amp-buildpacks/sway \
pack build forc-sample \
--path ./samples/forc \
--buildpack ghcr.io/amp-buildpacks/forc \
--builder paketobuildpacks/builder-jammy-base
```

Expand All @@ -38,7 +38,7 @@ docker run -u <uid>:<gid> -it <image-name>
For example:

```shell
docker run -u 1001:cnb -e HOME=/layers/amp-buildpacks_sway/forc-amd64/fuel -it sway-sample
docker run -u 1001:cnb -e HOME=/layers/amp-buildpacks_forc/forc-amd64/fuel -it forc-sample
```

## Contributing
Expand Down
12 changes: 6 additions & 6 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
api = "0.8"

[buildpack]
description = "A Cloud Native Buildpack that provides the Sway Tool Suite"
homepage = "https://github.com/amp-buildpacks/sway"
id = "amp-buildpacks/sway"
keywords = ["Sway"]
description = "A Cloud Native Buildpack that provides the Forc Tool Suite"
homepage = "https://github.com/amp-buildpacks/forc"
id = "amp-buildpacks/forc"
keywords = ["Forc"]
sbom-formats = ["application/vnd.cyclonedx+json", "application/vnd.syft+json"]
name = "AMP Buildpack for Sway"
name = "AMP Buildpack for Forc"
version = "{{ .version }}"

[[buildpack.licenses]]
type = "Apache-2.0"
uri = "https://github.com/amp-buildpacks/sway/blob/main/LICENSE"
uri = "https://github.com/amp-buildpacks/forc/blob/main/LICENSE"

[metadata]
include-files = ["LICENSE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "buildpack.toml"]
Expand Down
6 changes: 3 additions & 3 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ package main
import (
"os"

sway "github.com/amp-buildpacks/sway/sway"
forc "github.com/amp-buildpacks/forc/forc"
"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libpak/bard"
)

func main() {
libcnb.Main(
sway.Detect{},
sway.Build{Logger: bard.NewLogger(os.Stdout)},
forc.Detect{},
forc.Build{Logger: bard.NewLogger(os.Stdout)},
)
}
12 changes: 6 additions & 6 deletions sway/build.go → forc/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sway
package forc

import (
"fmt"
Expand All @@ -33,7 +33,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
pr := libpak.PlanEntryResolver{Plan: context.Plan}

if _, ok, err := pr.Resolve(PlanEntryForc); err != nil {
return libcnb.BuildResult{}, fmt.Errorf("unable to resolve Sway plan entry\n%w", err)
return libcnb.BuildResult{}, fmt.Errorf("unable to resolve %s plan entry\n%w", PlanEntryForc, err)
} else if ok {
cr, err := libpak.NewConfigurationResolver(context.Buildpack, &b.Logger)
if err != nil {
Expand All @@ -59,14 +59,14 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
return libcnb.BuildResult{}, fmt.Errorf("unable to find dependency\n%w", err)
}

swayLayer := NewSway(dependency, dc, cr)
swayLayer.Logger = b.Logger
forcLayer := NewForc(dependency, dc, cr)
forcLayer.Logger = b.Logger

result.Processes, err = swayLayer.BuildProcessTypes(cr, context.Application)
result.Processes, err = forcLayer.BuildProcessTypes(cr, context.Application)
if err != nil {
return libcnb.BuildResult{}, fmt.Errorf("unable to build list of process types\n%w", err)
}
result.Layers = append(result.Layers, swayLayer)
result.Layers = append(result.Layers, forcLayer)
}

return result, nil
Expand Down
8 changes: 4 additions & 4 deletions sway/detect.go → forc/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sway
package forc

import (
"fmt"
Expand All @@ -30,9 +30,9 @@ type Detect struct {
}

func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
found, err := d.swayProject(context.Application.Path)
found, err := d.forcProject(context.Application.Path)
if err != nil {
return libcnb.DetectResult{Pass: false}, fmt.Errorf("unable to detect Sway requirements\n%w", err)
return libcnb.DetectResult{Pass: false}, fmt.Errorf("unable to detect %s requirements\n%w", PlanEntryForc, err)
}

if !found {
Expand All @@ -54,7 +54,7 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
}, nil
}

func (d Detect) swayProject(appDir string) (bool, error) {
func (d Detect) forcProject(appDir string) (bool, error) {
filename := "Forc.toml"
_, err := os.Stat(filepath.Join(appDir, filename))
if os.IsNotExist(err) || err != nil {
Expand Down
20 changes: 10 additions & 10 deletions sway/sway.go → forc/forc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sway
package forc

import (
"bytes"
Expand All @@ -30,26 +30,26 @@ import (
"github.com/paketo-buildpacks/libpak/sherpa"
)

type Sway struct {
type Forc struct {
LayerContributor libpak.DependencyLayerContributor
configResolver libpak.ConfigurationResolver
Logger bard.Logger
Executor effect.Executor
}

func NewSway(dependency libpak.BuildpackDependency, cache libpak.DependencyCache, configResolver libpak.ConfigurationResolver) Sway {
func NewForc(dependency libpak.BuildpackDependency, cache libpak.DependencyCache, configResolver libpak.ConfigurationResolver) Forc {
contributor := libpak.NewDependencyLayerContributor(dependency, cache, libcnb.LayerTypes{
Cache: true,
Launch: true,
})
return Sway{
return Forc{
LayerContributor: contributor,
configResolver: configResolver,
Executor: effect.NewExecutor(),
}
}

func (r Sway) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
func (r Forc) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
r.LayerContributor.Logger = r.Logger
return r.LayerContributor.Contribute(layer, func(artifact *os.File) (libcnb.Layer, error) {
bin := filepath.Join(layer.Path, "bin")
Expand Down Expand Up @@ -107,7 +107,7 @@ func (r Sway) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
})
}

func (r Sway) Execute(command string, args []string) (*bytes.Buffer, error) {
func (r Forc) Execute(command string, args []string) (*bytes.Buffer, error) {
buf := &bytes.Buffer{}
if err := r.Executor.Execute(effect.Execution{
Command: command,
Expand All @@ -120,7 +120,7 @@ func (r Sway) Execute(command string, args []string) (*bytes.Buffer, error) {
return buf, nil
}

func (r Sway) BuildProcessTypes(cr libpak.ConfigurationResolver, app libcnb.Application) ([]libcnb.Process, error) {
func (r Forc) BuildProcessTypes(cr libpak.ConfigurationResolver, app libcnb.Application) ([]libcnb.Process, error) {
processes := []libcnb.Process{}

enableDeploy := cr.ResolveBool("BP_ENABLE_FORC_DEPLOY")
Expand All @@ -135,7 +135,7 @@ func (r Sway) BuildProcessTypes(cr libpak.ConfigurationResolver, app libcnb.Appl
return processes, nil
}

func (r Sway) InitializeWallet(walletDir string) (bool, error) {
func (r Forc) InitializeWallet(walletDir string) (bool, error) {
r.Logger.Bodyf("Initializing deploy wallet and save to dir: %s", walletDir)
os.MkdirAll(walletDir, os.ModePerm)

Expand All @@ -153,7 +153,7 @@ func (r Sway) InitializeWallet(walletDir string) (bool, error) {
return true, nil
}

func (r Sway) BuildContract() error {
func (r Forc) BuildContract() error {
args := []string{"build", "--release"}
_, err := r.Execute(PlanEntryForc, args)
if err != nil {
Expand All @@ -163,7 +163,7 @@ func (r Sway) BuildContract() error {
return nil
}

func (r Sway) Name() string {
func (r Forc) Name() string {
return r.LayerContributor.LayerName()
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/amp-buildpacks/sway
module github.com/amp-buildpacks/forc

go 1.22

Expand Down

0 comments on commit 266c7bb

Please sign in to comment.