Skip to content

Commit

Permalink
Bump Go to 1.21.3 and upgrade backend dependencies (#3431)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz authored Oct 17, 2023
1 parent 54774c4 commit c1686f4
Show file tree
Hide file tree
Showing 12 changed files with 420 additions and 626 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
aws-region: us-east-2
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag and push hub image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ah/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build ah
FROM golang:1.21.1-alpine3.18 AS ah-builder
FROM golang:1.21.3-alpine3.18 AS ah-builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/artifacthub/ah
Expand Down
2 changes: 1 addition & 1 deletion cmd/hub/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build backend
FROM golang:1.21.1-alpine3.18 AS backend-builder
FROM golang:1.21.3-alpine3.18 AS backend-builder
WORKDIR /go/src/github.com/artifacthub/hub
COPY go.* ./
COPY cmd/hub cmd/hub
Expand Down
2 changes: 1 addition & 1 deletion cmd/scanner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build scanner
FROM golang:1.21.1-alpine3.18 AS scanner-builder
FROM golang:1.21.3-alpine3.18 AS scanner-builder
WORKDIR /go/src/github.com/artifacthub/scanner
COPY go.* ./
COPY cmd/scanner cmd/scanner
Expand Down
2 changes: 1 addition & 1 deletion cmd/tracker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build tracker
FROM golang:1.21.1-bullseye AS builder
FROM golang:1.21.3-bullseye AS builder
WORKDIR /tmp
ENV LIBTENSORFLOW_TGZ libtensorflow-cpu-linux-x86_64-2.11.0.tar.gz
RUN wget -q --no-check-certificate https://storage.googleapis.com/tensorflow/libtensorflow/$LIBTENSORFLOW_TGZ
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build tern
FROM golang:1.21.1-alpine3.18 AS tern
FROM golang:1.21.3-alpine3.18 AS tern
RUN apk --no-cache add git
RUN go install github.com/jackc/tern@latest

Expand Down
2 changes: 1 addition & 1 deletion database/tests/Dockerfile-db-tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build tern
FROM golang:1.21.1-alpine3.18 AS tern
FROM golang:1.21.3-alpine3.18 AS tern
RUN apk --no-cache add git
RUN go get -u github.com/jackc/tern

Expand Down
243 changes: 119 additions & 124 deletions go.mod

Large diffs are not rendered by default.

724 changes: 250 additions & 474 deletions go.sum

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions internal/tracker/source/generic/gatekeeper.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package generic

// Based on: https://github.com/open-policy-agent/gatekeeper/blob/a1f01f40ed89db0ae0cb0b84dcc498b76c6fa448/pkg/gator/verify/suite.go#L8
type GKSuite struct {
Tests []GKTest `yaml:"tests"`
}

// Based on: https://github.com/open-policy-agent/gatekeeper/blob/a1f01f40ed89db0ae0cb0b84dcc498b76c6fa448/pkg/gator/verify/suite.go#L27
type GKTest struct {
Name string `yaml:"name"`
Constraint string `yaml:"constraint"`
Cases []*GKCase `yaml:"cases"`
}

// Based on: https://github.com/open-policy-agent/gatekeeper/blob/a1f01f40ed89db0ae0cb0b84dcc498b76c6fa448/pkg/gator/verify/suite.go#L53
type GKCase struct {
Name string `yaml:"name"`
Object string `yaml:"object"`
}

// GKExample represents an example in a Gatekeeper policy.
type GKExample struct {
Name string `json:"name"`
Expand Down
20 changes: 13 additions & 7 deletions internal/tracker/source/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/artifacthub/hub/internal/oci"
"github.com/artifacthub/hub/internal/pkg"
"github.com/artifacthub/hub/internal/util"
gk "github.com/open-policy-agent/gatekeeper/v3/pkg/gator/verify"
ignore "github.com/sabhiram/go-gitignore"
"gopkg.in/yaml.v3"
)

const (
Expand Down Expand Up @@ -282,13 +282,19 @@ func prepareGatekeeperData(pkgPath string) (map[string]interface{}, error) {
}

// Read examples
suites, err := gk.ReadSuites(os.DirFS(pkgPath), ".", ".", false)
if err != nil {
return nil, fmt.Errorf("error reading gatekeeper suite: %w", err)
}
var examples []*GKExample
if len(suites) == 1 {
for _, t := range suites[0].Tests {
suitePath := path.Join(pkgPath, "suite.yaml")
suiteYaml, err := util.ReadRegularFile(suitePath)
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("error reading gatekeeper suite: %w", err)
}
} else {
var suite *GKSuite
if err := yaml.Unmarshal(suiteYaml, &suite); err != nil {
return nil, fmt.Errorf("error reading parsing suite file: %w", err)
}
for _, t := range suite.Tests {
var cases []*GKExampleCase
if t.Constraint != "" {
content, err := util.ReadRegularFile(path.Join(pkgPath, t.Constraint))
Expand Down
27 changes: 13 additions & 14 deletions internal/tracker/source/tekton/tekton.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/hashicorp/go-multierror"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
pipelinerun "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources"
taskrun "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources"
)
Expand Down Expand Up @@ -288,9 +288,9 @@ func GetManifest(kind hub.RepositoryKind, pkgName, pkgPath string) (interface{},
var manifest interface{}
switch kind {
case hub.TektonTask:
manifest = &v1beta1.Task{}
manifest = &v1.Task{}
case hub.TektonPipeline:
manifest = &v1beta1.Pipeline{}
manifest = &v1.Pipeline{}
}
if err := yaml.Unmarshal(manifestData, &manifest); err != nil {
return nil, nil, err
Expand All @@ -308,11 +308,11 @@ func validateManifest(manifest interface{}) error {
// Extract some information from package manifest
var name, version, description string
switch m := manifest.(type) {
case *v1beta1.Task:
case *v1.Task:
name = m.Name
version = m.Labels[versionLabelTKey]
description = m.Spec.Description
case *v1beta1.Pipeline:
case *v1.Pipeline:
name = m.Name
version = m.Labels[versionLabelTKey]
description = m.Spec.Description
Expand Down Expand Up @@ -354,32 +354,31 @@ func PreparePackage(i *PreparePackageInput) (*hub.Package, error) {
var name, version, description, tektonKind string
var annotations map[string]string
var tasks []map[string]interface{}
var steps []v1beta1.Step
var steps []v1.Step

switch m := i.Manifest.(type) {
case *v1beta1.Task:
case *v1.Task:
tektonKind = "task"
name = m.Name
version = m.Labels[versionLabelTKey]
description = m.Spec.Description
annotations = m.Annotations

ts := m.TaskSpec()
var defaults []v1beta1.ParamSpec
if len(ts.Params) > 0 {
defaults = append(defaults, ts.Params...)
var defaults []v1.ParamSpec
if len(m.Spec.Params) > 0 {
defaults = append(defaults, m.Spec.Params...)
}
mts := taskrun.ApplyParameters(context.Background(), &ts, &v1beta1.TaskRun{}, defaults...)
mts := taskrun.ApplyParameters(context.Background(), &m.Spec, &v1.TaskRun{}, defaults...)
steps = mts.Steps
case *v1beta1.Pipeline:
case *v1.Pipeline:
tektonKind = "pipeline"
name = m.Name
version = m.Labels[versionLabelTKey]
description = m.Spec.Description
annotations = m.Annotations

ps := m.PipelineSpec()
mps := pipelinerun.ApplyParameters(context.Background(), &ps, &v1beta1.PipelineRun{})
mps := pipelinerun.ApplyParameters(context.Background(), &ps, &v1.PipelineRun{})
for _, mts := range mps.Tasks {
if mts.TaskSpec != nil {
steps = append(steps, mts.TaskSpec.Steps...)
Expand Down

0 comments on commit c1686f4

Please sign in to comment.