Skip to content

Commit

Permalink
Merge pull request #47 from bgilbert/go
Browse files Browse the repository at this point in the history
Drop Go 1.15 and 1.16, add Go 1.19, fix tests, drop vendor directory
  • Loading branch information
bgilbert authored Aug 10, 2022
2 parents f3a1ef6 + 151c506 commit e83b531
Show file tree
Hide file tree
Showing 48 changed files with 43 additions and 18,454 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ jobs:
name: test build
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x]
go-version: [1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest]
include:
- go-version: 1.18.x
- go-version: 1.19.x
os: macos-latest
- go-version: 1.18.x
- go-version: 1.19.x
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Build
run: make
- name: Test
run: make test
- name: Run linter
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
version: v1.45.0
version: v1.48.0
args: -E=gofmt --timeout=30m0s
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
PKGS := arch release stream stream/rhcos release/rhcos fedoracoreos

build:
for pkg in $(PKGS); do (cd $$pkg && go build -mod=vendor); done
BUILD_PKGS = $(foreach pkg,$(PKGS),build-$(pkg))
TEST_PKGS = $(foreach pkg,$(PKGS),test-$(pkg))

build: $(BUILD_PKGS)
.PHONY: build

test:
for pkg in $(PKGS); do (cd $$pkg && go test); done
$(BUILD_PKGS): build-%:
cd $* && go build
.PHONY: $(BUILD_PKGS)

test: $(TEST_PKGS)
.PHONY: test

$(TEST_PKGS): test-%:
cd $* && go test
.PHONY: $(TEST_PKGS)
4 changes: 2 additions & 2 deletions fedoracoreos/fcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package fedoracoreos
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand Down Expand Up @@ -35,7 +35,7 @@ func getStream(u url.URL) (*stream.Stream, error) {
if err != nil {
return nil, err
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module github.com/coreos/stream-metadata-go

go 1.15
go 1.17

require github.com/stretchr/testify v1.6.1

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
8 changes: 4 additions & 4 deletions release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package release

import (
"encoding/json"
"io/ioutil"
"os"
"testing"
"time"

Expand All @@ -15,7 +15,7 @@ const (
)

func TestParseFCR(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-release.json")
d, err := os.ReadFile("fixtures/fcos-release.json")
assert.Nil(t, err)
release := Release{}
err = json.Unmarshal(d, &release)
Expand All @@ -25,7 +25,7 @@ func TestParseFCR(t *testing.T) {
}

func TestParseFCRIndex(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-releases.json")
d, err := os.ReadFile("fixtures/fcos-releases.json")
assert.Nil(t, err)
idx := Index{}
err = json.Unmarshal(d, &idx)
Expand All @@ -38,7 +38,7 @@ func TestParseFCRIndex(t *testing.T) {
}

func TestTranslate(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-release.json")
d, err := os.ReadFile("fixtures/fcos-release.json")
assert.Nil(t, err)
rel := Release{}
err = json.Unmarshal(d, &rel)
Expand Down
15 changes: 7 additions & 8 deletions stream/artifact_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -42,8 +41,8 @@ func (a *Artifact) Fetch(w io.Writer) error {
return nil
}

/// Name returns the "basename" of the artifact, i.e. the contents
/// after the last `/`. This can be useful when downloading to a file.
// Name returns the "basename" of the artifact, i.e. the contents
// after the last `/`. This can be useful when downloading to a file.
func (a *Artifact) Name() (string, error) {
loc, err := url.Parse(a.Location)
if err != nil {
Expand All @@ -53,17 +52,17 @@ func (a *Artifact) Name() (string, error) {
return path.Base(loc.Path), nil
}

/// Download fetches the specified artifact and saves it to the target
/// directory. The full file path will be returned as a string.
/// If the target file path exists, it will be overwritten.
/// If the download fails, the temporary file will be deleted.
// Download fetches the specified artifact and saves it to the target
// directory. The full file path will be returned as a string.
// If the target file path exists, it will be overwritten.
// If the download fails, the temporary file will be deleted.
func (a *Artifact) Download(destdir string) (string, error) {
name, err := a.Name()
if err != nil {
return "", err
}
destfile := filepath.Join(destdir, name)
w, err := ioutil.TempFile(destdir, ".coreos-artifact-")
w, err := os.CreateTemp(destdir, ".coreos-artifact-")
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package stream

import (
"encoding/json"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestParseFCS(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-stream.json")
d, err := os.ReadFile("fixtures/fcos-stream.json")
assert.Nil(t, err)
stream := Stream{}
err = json.Unmarshal(d, &stream)
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestParseFCS(t *testing.T) {

assert.Equal(t, stream.Architectures["x86_64"].Images.KubeVirt, &ContainerImage{
Release: "33.20211201.3.0",
Image: "quay.io/openshift-release-dev/rhcos@latest",
Image: "quay.io/openshift-release-dev/rhcos:latest",
DigestRef: "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773",
})
assert.Equal(t, stream.Architectures["x86_64"].Artifacts["kubevirt"].Formats["qcow2.xz"].Disk.Sha256, "2be55c5aa1f53eb9a869826dacbab75706ee6bd59185b935ac9be546cc132a85")
Expand Down
15 changes: 0 additions & 15 deletions vendor/github.com/davecgh/go-spew/LICENSE

This file was deleted.

152 changes: 0 additions & 152 deletions vendor/github.com/davecgh/go-spew/spew/bypass.go

This file was deleted.

Loading

0 comments on commit e83b531

Please sign in to comment.