Skip to content

Commit

Permalink
Merge pull request #1490 from paketo-buildpacks/remove-install
Browse files Browse the repository at this point in the history
Simplify tools installation & pipelines
  • Loading branch information
anthonydahanne authored Feb 21, 2024
2 parents ab85b0c + b7e510f commit 73e9a0c
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 157 deletions.
5 changes: 2 additions & 3 deletions actions/graalvm-dependency/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -169,7 +168,7 @@ func GetVersion(uri string) string {
continue
}

b, err := ioutil.ReadAll(t)
b, err := io.ReadAll(t)
if err != nil {
panic(fmt.Errorf("unable to read %s\n%w", f.Name, err))
}
Expand Down
10 changes: 6 additions & 4 deletions buildpack/rewriteLayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"archive/tar"
"bytes"
"fmt"
"io/ioutil"
"io"
"path"
"strings"

Expand Down Expand Up @@ -37,7 +37,7 @@ func rewriteLayer(layer v1.Layer, oldID, newID, oldVersion, newVersion string) (

// replace buildpack id and version in buildpack.toml
if strings.HasSuffix(path.Clean(header.Name), "buildpack.toml") {
buf, err := ioutil.ReadAll(tr)
buf, err := io.ReadAll(tr)
if err != nil {
return nil, fmt.Errorf("unable to read buildpack.toml\n%w", err)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func rewriteLayer(layer v1.Layer, oldID, newID, oldVersion, newVersion string) (
return nil, fmt.Errorf("unable to write header\n%w", err)
}

buf, err := ioutil.ReadAll(tr)
buf, err := io.ReadAll(tr)
if err != nil {
return nil, fmt.Errorf("unable to read contents\n%w", err)
}
Expand All @@ -88,7 +88,9 @@ func rewriteLayer(layer v1.Layer, oldID, newID, oldVersion, newVersion string) (
}
}

return tarball.LayerFromReader(b)
return tarball.LayerFromOpener(func() (io.ReadCloser, error) {
return io.NopCloser(b), nil
})
}

type BuildpackDescriptor struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/statik/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"os"
"sort"
"time"
Expand Down Expand Up @@ -58,7 +58,7 @@ func main() {
return fmt.Errorf("unable to open file %s", path)
}

b, err := ioutil.ReadAll(fp)
b, err := io.ReadAll(fp)
if err != nil {
return fmt.Errorf("unable to read file %s", path)
}
Expand Down
11 changes: 5 additions & 6 deletions drafts/drafts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -198,7 +197,7 @@ func (d Drafter) CreatePayload(inputs actions.Inputs, buildpackPath string) (Pay
}

func loadBuildpackTOMLFromFile(buildpackPath string) (*Buildpack, error) {
rawTOML, err := ioutil.ReadFile(filepath.Join(buildpackPath, "buildpack.toml"))
rawTOML, err := os.ReadFile(filepath.Join(buildpackPath, "buildpack.toml"))
if err != nil && os.IsNotExist(err) {
return nil, nil
} else if err != nil {
Expand Down Expand Up @@ -277,7 +276,7 @@ func asString(m map[string]interface{}, key string) string {
}

func loadPackage(buildpackPath string) (*Package, error) {
rawTOML, err := ioutil.ReadFile(filepath.Join(buildpackPath, "package.toml"))
rawTOML, err := os.ReadFile(filepath.Join(buildpackPath, "package.toml"))
if err != nil && os.IsNotExist(err) {
return nil, nil
} else if err != nil {
Expand All @@ -293,7 +292,7 @@ func loadPackage(buildpackPath string) (*Package, error) {
}

func loadBuilderTOML(buildpackPath string) (*Builder, error) {
rawTOML, err := ioutil.ReadFile(filepath.Join(buildpackPath, "builder.toml"))
rawTOML, err := os.ReadFile(filepath.Join(buildpackPath, "builder.toml"))
if err != nil && os.IsNotExist(err) {
return nil, nil
} else if err != nil {
Expand Down Expand Up @@ -512,7 +511,7 @@ func (r RegistryBuildpackLoader) LoadBuildpack(uri string) (Buildpack, error) {
return Buildpack{}, fmt.Errorf("unable to create /tmp\n%w", err)
}

tarFile, err := ioutil.TempFile("/tmp", "tarfiles")
tarFile, err := os.CreateTemp("/tmp", "tarfiles")
if err != nil {
return Buildpack{}, fmt.Errorf("unable to create tempfile\n%w", err)
}
Expand Down
17 changes: 2 additions & 15 deletions drafts/drafts_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@ package drafts_test

import (
"bytes"
"io/ioutil"
"os"
"testing"

Expand All @@ -36,22 +35,10 @@ func testDrafts(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect

dir string

bpLoader mocks.BuildpackLoader
)

context("draft a release", func() {
it.Before(func() {
var err error
dir, err = ioutil.TempDir("", "drafts")
Expect(err).To(Not(HaveOccurred()))
})

it.After(func() {
Expect(os.RemoveAll(dir)).To(Succeed())
})

context("payloads", func() {
it("creates a payload for a component buildpack", func() {
d := drafts.Drafter{Loader: &bpLoader}
Expand Down Expand Up @@ -246,7 +233,7 @@ func testDrafts(t *testing.T, context spec.G, it spec.S) {
var templateContent string

it.Before(func() {
tc, err := ioutil.ReadFile("../actions/draft-release/draft.template")
tc, err := os.ReadFile("../actions/draft-release/draft.template")
Expect(err).ToNot(HaveOccurred())
templateContent = string(tc)
})
Expand Down
2 changes: 1 addition & 1 deletion drafts/mocks/buildpack_loader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion octo/actions/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Step struct {
type Strategy struct {
Matrix Matrix `yaml:",omitempty"`
FailFast bool `yaml:"fail-fast,omitempty"`
MaxParallel int `yaml:"max-parallel:omitempty"`
MaxParallel int `yaml:"max-parallel,omitempty"`
}

type Container struct {
Expand Down
21 changes: 10 additions & 11 deletions octo/builder_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,11 @@ func contributeBuildImage(descriptor Descriptor, image string, classifier string
Run: StatikString("/install-update-build-image-dependency.sh"),
},
{
Name: "Install crane",
Run: StatikString("/install-crane.sh"),
Env: map[string]string{"CRANE_VERSION": CraneVersion},
},
{
Name: "Install yj",
Run: StatikString("/install-yj.sh"),
Env: map[string]string{"YJ_VERSION": YJVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Uses: "actions/checkout@v4",
Expand Down Expand Up @@ -164,9 +161,11 @@ func contributeLifecycle(descriptor Descriptor) (Contribution, error) {
Run: StatikString("/install-update-lifecycle-dependency.sh"),
},
{
Name: "Install yj",
Run: StatikString("/install-yj.sh"),
Env: map[string]string{"YJ_VERSION": YJVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Uses: "actions/checkout@v4",
Expand Down
8 changes: 5 additions & 3 deletions octo/buildpack_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func ContributeBuildpackDependencies(descriptor Descriptor) ([]Contribution, err
Run: StatikString("/install-update-buildpack-dependency.sh"),
},
{
Name: "Install yj",
Run: StatikString("/install-yj.sh"),
Env: map[string]string{"YJ_VERSION": YJVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Uses: "actions/checkout@v4",
Expand Down
17 changes: 11 additions & 6 deletions octo/create_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package octo

import (
"fmt"

"github.com/paketo-buildpacks/pipeline-builder/octo/actions"
"github.com/paketo-buildpacks/pipeline-builder/octo/actions/event"
)
Expand Down Expand Up @@ -45,14 +47,17 @@ func ContributeCreateBuilder(descriptor Descriptor) (*Contribution, error) {
With: map[string]interface{}{"go-version": GoVersion},
},
{
Name: "Install crane",
Run: StatikString("/install-crane.sh"),
Env: map[string]string{"CRANE_VERSION": CraneVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Name: "Install pack",
Run: StatikString("/install-pack.sh"),
Env: map[string]string{"PACK_VERSION": PackVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-pack@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"pack-version": PackVersion,
},
},
{
Uses: "actions/checkout@v4",
Expand Down
15 changes: 9 additions & 6 deletions octo/create_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ func ContributeCreatePackage(descriptor Descriptor) (*Contribution, error) {
Run: StatikString("/install-create-package.sh"),
},
{
Name: "Install crane",
Run: StatikString("/install-crane.sh"),
Env: map[string]string{"CRANE_VERSION": CraneVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Name: "Install pack",
Run: StatikString("/install-pack.sh"),
Env: map[string]string{"PACK_VERSION": PackVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-pack@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"pack-version": PackVersion,
},
},
{
Name: "Enable pack Experimental",
Expand Down
15 changes: 0 additions & 15 deletions octo/install-crane.sh

This file was deleted.

15 changes: 0 additions & 15 deletions octo/install-pack.sh

This file was deleted.

17 changes: 0 additions & 17 deletions octo/install-yj.sh

This file was deleted.

8 changes: 5 additions & 3 deletions octo/lite_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ func contributeLitePackage(descriptor Descriptor, republishImage RepublishImage)
RunsOn: []actions.VirtualEnvironment{actions.UbuntuLatest},
Steps: []actions.Step{
{
Name: "Install crane",
Run: StatikString("/install-crane.sh"),
Env: map[string]string{"CRANE_VERSION": CraneVersion},
Uses: fmt.Sprintf("buildpacks/github-actions/setup-tools@v%s", BuildpackActionsVersion),
With: map[string]interface{}{
"crane-version": CraneVersion,
"yj-version": YJVersion,
},
},
{
Uses: "actions/checkout@v4",
Expand Down
Loading

0 comments on commit 73e9a0c

Please sign in to comment.