Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
toolchain go1.22.7

require (
github.com/Masterminds/sprig/v3 v3.3.0
github.com/ghodss/yaml v1.0.0
github.com/openshift/ci-tools v0.0.0-20231129005518-2ec9d62902e9
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -19,7 +20,10 @@ require (
cloud.google.com/go/storage v1.29.0 // indirect
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/GoogleCloudPlatform/testgrid v0.0.123 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/andygrunwald/go-jira v1.14.0 // indirect
github.com/aws/aws-sdk-go v1.44.116 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -50,13 +54,13 @@ require (
github.com/gomodule/redigo v1.8.5 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.15.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.1-0.20210504230335-f78f29fc09ea // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/s2a-go v0.1.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/google/wire v0.4.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go v2.0.2+incompatible // indirect
Expand All @@ -67,13 +71,16 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-zglob v0.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand All @@ -86,9 +93,11 @@ require (
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prometheus/statsd_exporter v0.21.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228 // indirect
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tektoncd/pipeline v0.48.0 // indirect
github.com/trivago/tgo v1.0.7 // indirect
Expand All @@ -98,14 +107,14 @@ require (
go.uber.org/zap v1.24.0 // indirect
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
gocloud.dev v0.19.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
Expand Down
60 changes: 40 additions & 20 deletions go.sum

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions hack/release-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ ROOT="$(dirname "$SCRIPT_DIR")"
source $SCRIPT_DIR/common-functions.sh

# Default values
ACTION="update-upstream-versions"
VERSION="next"
ENVIRONMENT="dev"
DEFAULT_ACTION="update-upstream-versions"
DEFAULT_VERSION="next"
ACTION=""
VERSION=""


help() {
Expand Down Expand Up @@ -56,10 +57,6 @@ while [[ $# -gt 0 ]]; do
VERSION="$2"
shift 2
;;
--env|--environment | -e)
ENVIRONMENT="$2"
shift 2
;;
--help|-h)
help
;;
Expand All @@ -70,10 +67,14 @@ while [[ $# -gt 0 ]]; do
esac
done

# Validate required params
if [[ -z "$ACTION" || -z "$VERSION" ]]; then
echo "Missing required parameters!"
help
# Use Default Values for required params
if [[ -z "$ACTION" ]]; then
echo "Using default action $DEFAULT_ACTION!"
ACTION=$DEFAULT_ACTION
fi
if [[ -z "$VERSION" ]]; then
echo "Using default version $DEFAULT_VERSION!"
VERSION=$DEFAULT_VERSION
fi

# Call specific function based on ACTION
Expand Down
19 changes: 10 additions & 9 deletions internal/konflux/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ func cloneAndCheckout(ctx context.Context, repo Repository, targetDir string) (s
}
if exists {
// Repository exists, fetch the latest changes
if out, err := run(ctx, dir, "rm", "-rf", dir); err != nil {
return dir, fmt.Errorf("failed to delete exisiting dir: %s, Error: %v, Output: %v", dir, err, out)
if out, err := run(ctx, dir, "git", "fetch", "--all"); err != nil {
return dir, fmt.Errorf("failed to fetch repository: %s, %s", err, out)
}
} else {
// Repository does not exist, clone the repository
if err := os.MkdirAll(dir, 0755); err != nil {
return "", err
}
if out, err := run(ctx, dir, "git", "clone", repo.Url, "."); err != nil {
return dir, fmt.Errorf("failed to clone repository: %s, %s", err, out)
}
}
// Repository does not exist, clone the repository
if err := os.MkdirAll(dir, 0755); err != nil {
return "", err
}
if out, err := run(ctx, dir, "git", "clone", repo.Url, "."); err != nil {
return dir, fmt.Errorf("failed to clone repository: %s, %s", err, out)
}

if out, err := run(ctx, dir, "git", "reset", "--hard", "HEAD", "--"); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions internal/konflux/go-templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"regexp"
"strings"
"text/template"

"github.com/Masterminds/sprig/v3"
)

//go:embed templates/*/*.yaml templates/*/*/*.yaml
Expand Down Expand Up @@ -43,6 +45,10 @@ func generateFileFromTemplate(templateFile string, data interface{}, filePath st
"contains": strings.Contains,
"eval": Eval,
}
// merge Sprig funcs into your map
for k, v := range sprig.FuncMap() {
funcMap[k] = v
}
tmpl, err := template.New(templateFile).Funcs(funcMap).ParseFS(templateFS, "templates/*/*.yaml", "templates/*/*/*.yaml")
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: update-sources-{{.Name}}

{{- $minorVersion := "0" -}}
{{- $versionParts := splitList "." .Application.Release.Version }}
{{- if ge (len $versionParts) 2 }}
{{- $minorVersion = index $versionParts 1 -}}
{{- end }}
on:
workflow_dispatch: {}
schedule:
- cron: "0 1 * * *" # At 1AM everyday
- cron: "0 {{add (mod $minorVersion 23) 1}} * * *" # At {{add (mod $minorVersion 24) 1}}:00 everyday

jobs:

Expand Down
2 changes: 1 addition & 1 deletion internal/konflux/templates/konflux/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
name: application
params:
- name: POLICY_CONFIGURATION
value: {{- if not (contains .Name "index") }} tekton-ecosystem-tenant/tekton-ecosystem-tenant-containers {{- else}} tekton-ecosystem-tenant/tekton-ecosystem-tenant-indexes {{- end}}
value: {{- if not (contains "index" .Name ) }} tekton-ecosystem-tenant/tekton-ecosystem-tenant-containers {{- else}} tekton-ecosystem-tenant/tekton-ecosystem-tenant-indexes {{- end}}
- name: TIMEOUT
value: "15m0s"
- name: SINGLE_COMPONENT
Expand Down
8 changes: 4 additions & 4 deletions internal/konflux/templates/tekton/component-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: PipelineRun
metadata:
annotations:
pipelinesascode.tekton.dev/cancel-in-progress: "true" # Cancel in-progress pipelines
{{- if and (ne .Repository.Branch.Name "main") (contains .Name "index") }}
{{- if and (ne .Repository.Branch.Name "main") (contains "index" .Name ) }}
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/openshift-pipelines/operator/refs/heads/main/.tekton/fbc-build.yaml"
{{- else }}{{- if or (ne .Repository.Branch.Name "main") (ne .Repository.Name "tektoncd-operator") }}
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/openshift-pipelines/operator/refs/heads/main/.tekton/docker-build-ta.yaml"
Expand Down Expand Up @@ -45,18 +45,18 @@ spec:
- name: build-platforms
value:
- linux/x86_64
{{- if eq .Name "bundle" }}
{{- if eq "bundle" .Name }}
- name: build-image-index
value: false
{{end }}
{{- if not (contains .Name "index") }}
{{- if not (contains "index" .Name) }}
- name: prefetch-input
value: |
{{.PrefetchInput}}
{{- end }}
pipelineRef:
name:
{{- if not (contains .Name "index") }} docker-build-ta
{{- if not (contains "index" .Name) }} docker-build-ta
{{- else}} fbc-build {{- end }}
taskRunTemplate:
serviceAccountName: build-pipeline-{{basename .Repository.Name | hyphenize}}-{{hyphenize .Name}}-{{hyphenize .Version.Version}}
Expand Down
8 changes: 4 additions & 4 deletions internal/konflux/templates/tekton/component-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: PipelineRun
metadata:
annotations:
pipelinesascode.tekton.dev/cancel-in-progress: "true" # Cancel in-progress pipelines
{{- if and (ne .Repository.Branch.Name "main") (contains .Name "index") }}
{{- if and (ne .Repository.Branch.Name "main") (contains "index" .Name) }}
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/openshift-pipelines/operator/refs/heads/main/.tekton/fbc-build.yaml"
{{- else }}{{- if or (ne .Repository.Branch.Name "main") (ne .Repository.Name "operator") }}
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/openshift-pipelines/operator/refs/heads/main/.tekton/docker-build-ta.yaml"
Expand Down Expand Up @@ -43,20 +43,20 @@ spec:
value:
- "{{- .Version.Version}}"
- "{{- .Application.Release.PatchVersion}}"
{{- if contains (printf "%s-%s-%s" (basename .Repository.Name | hyphenize) (hyphenize .Version.Version) .Name) "bundle" }}
{{- if contains "bundle" .Name }}
- name: build-platforms
value:
- linux/x86_64
- name: build-image-index
value: false
{{- end }}
{{- if not (contains .Name "index") }}
{{- if not (contains "index" .Name) }}
- name: prefetch-input
value: |
{{.PrefetchInput}}
{{- end }}
pipelineRef:
name: {{- if not (contains .Name "index") }} docker-build-ta {{- else}} fbc-build {{- end }}
name: {{- if not (contains "index" .Name ) }} docker-build-ta {{- else}} fbc-build {{- end }}
taskRunTemplate:
serviceAccountName: build-pipeline-{{basename .Repository.Name | hyphenize}}-{{hyphenize .Name}}-{{hyphenize .Version.Version}}
workspaces:
Expand Down