Skip to content

Commit

Permalink
Merge pull request #361 from fluxcd/go-1.19
Browse files Browse the repository at this point in the history
Update Go and internal packages
  • Loading branch information
stefanprodan authored Sep 26, 2022
2 parents 262bb5c + 352f3a2 commit daa2fc2
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
# https://github.com/actions/setup-go/blob/main/docs/adrs/0000-caching-dependencies.md#example-of-real-use-cases
cache: true
cache-dependency-path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
- id: go-env
run: |
echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: ${{ steps.filter.outputs.git == 'true' || steps.filter.outputs.e2e == 'true' || github.event_name == 'workflow_dispatch' }}
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Run tests
if: ${{ steps.filter.outputs.git == 'true' || steps.filter.outputs.e2e == 'true' || github.event_name == 'workflow_dispatch' }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all:
$(MAKE) $(targets)

tidy-%:
cd $(subst :,/,$*); go mod tidy -compat=1.18
cd $(subst :,/,$*); go mod tidy -compat=1.19

fmt-%:
cd $(subst :,/,$*); go fmt ./...
Expand Down
8 changes: 4 additions & 4 deletions apis/meta/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func ReconcileAnnotationValue(annotations map[string]string) (string, bool) {
// ReconcileRequestStatus is a struct to embed in a status type, so that all types using the mechanism have the same
// field. Use it like this:
//
// type FooStatus struct {
// meta.ReconcileRequestStatus `json:",inline"`
// // other status fields...
// }
// type FooStatus struct {
// meta.ReconcileRequestStatus `json:",inline"`
// // other status fields...
// }
type ReconcileRequestStatus struct {
// LastHandledReconcileAt holds the value of the most recent
// reconcile request value, so a change of the annotation value
Expand Down
4 changes: 2 additions & 2 deletions gittestserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (s *GitServer) KeyDir(dir string) *GitServer {
// InstallUpdateHook installs a hook script that will run running
// _before_ a push is accepted, as described at
//
// https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
// https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
//
// The provided string is written as an executable script to the hooks
// directory; start with a hashbang to make sure it'll run, e.g.,
//
// #!/bin/bash
// #!/bin/bash
func (s *GitServer) InstallUpdateHook(script string) *GitServer {
if s.config.Hooks == nil {
s.config.Hooks = &gitkit.HookScripts{}
Expand Down
2 changes: 1 addition & 1 deletion kustomize/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/fluxcd/pkg/apis/kustomize => ../apis/kustomize

require (
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46
github.com/fluxcd/pkg/apis/kustomize v0.5.0
github.com/fluxcd/pkg/apis/kustomize v0.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/onsi/gomega v1.20.2
k8s.io/api v0.25.2
Expand Down
7 changes: 4 additions & 3 deletions kustomize/kustomize_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func WithSaveOriginalKustomization() SavingOptions {
// It is the caller responsability to clean up the directory by use the provided function CleanDirectory.
// example:
// err := CleanDirectory(dirPath, action)
// if err != nil {
// log.Fatal(err)
// }
//
// if err != nil {
// log.Fatal(err)
// }
func (g *Generator) WriteFile(dirPath string, opts ...SavingOptions) (Action, error) {
action, err := g.generateKustomization(dirPath)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions runtime/conditions/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type localizedCondition struct {
// - P2 - Status=True, NegativePolarity=False
// - P3 - Status=False, NegativePolarity=True
// - P4 - Status=Unknown
//
// 3. The group with highest priority is used to determine status, and other info of the target condition.
// 4. If the polarity of the highest priority and target priority differ, it is inverted.
// 5. If the observed generation is considered, the condition groups with the latest generation get the highest
Expand Down
16 changes: 8 additions & 8 deletions runtime/conditions/unstructured.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ type unstructuredWrapper struct {
//
// NOTE: Due to the constraints of JSON-unmarshal, this operation is to be considered best effort.
// In more details:
// - Errors during JSON-unmarshal are ignored and a empty collection list is returned.
// - It's not possible to detect if the object has an empty condition list or if it does not implement conditions;
// in both cases the operation returns an empty slice.
// - If the object doesn't implement status conditions as defined in GitOps Toolkit API,
// JSON-unmarshal matches incoming object keys to the keys; this can lead to to conditions values partially set.
// - Errors during JSON-unmarshal are ignored and a empty collection list is returned.
// - It's not possible to detect if the object has an empty condition list or if it does not implement conditions;
// in both cases the operation returns an empty slice.
// - If the object doesn't implement status conditions as defined in GitOps Toolkit API,
// JSON-unmarshal matches incoming object keys to the keys; this can lead to to conditions values partially set.
func (c *unstructuredWrapper) GetConditions() []metav1.Condition {
conditions := []metav1.Condition{}
if err := UnstructuredUnmarshalField(c.Unstructured, &conditions, "status", "conditions"); err != nil {
Expand All @@ -98,9 +98,9 @@ func (c *unstructuredWrapper) GetConditions() []metav1.Condition {
//
// NOTE: Due to the constraints of JSON-unmarshal, this operation is to be considered best effort.
// In more details:
// - Errors during JSON-unmarshal are ignored and a empty collection list is returned.
// - It's not possible to detect if the object has an empty condition list or if it does not implement conditions;
// in both cases the operation returns an empty slice is returned.
// - Errors during JSON-unmarshal are ignored and a empty collection list is returned.
// - It's not possible to detect if the object has an empty condition list or if it does not implement conditions;
// in both cases the operation returns an empty slice is returned.
func (c *unstructuredWrapper) SetConditions(conditions []metav1.Condition) {
v := make([]interface{}, 0, len(conditions))
for i := range conditions {
Expand Down
10 changes: 5 additions & 5 deletions runtime/controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import (
//
// Use it by embedding it in your reconciler struct:
//
// type MyTypeReconciler {
// client.Client
// // ... etc.
// controller.Metrics
// }
// type MyTypeReconciler {
// client.Client
// // ... etc.
// controller.Metrics
// }
//
// Following the GitOps Toolkit conventions, API types used in GOTK SHOULD implement conditions.Getter to work with
// status condition types, and this convention MUST be followed to be able to record metrics using this helper.
Expand Down
20 changes: 10 additions & 10 deletions runtime/events/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ import (
//
// Use it by embedding EventRecorder in reconciler struct:
//
// import (
// ...
// kuberecorder "k8s.io/client-go/tools/record"
// ...
// )
// import (
// ...
// kuberecorder "k8s.io/client-go/tools/record"
// ...
// )
//
// type MyTypeReconciler {
// client.Client
// // ... etc.
// kuberecorder.EventRecorder
// }
// type MyTypeReconciler {
// client.Client
// // ... etc.
// kuberecorder.EventRecorder
// }
//
// Use NewRecorder to create a working Recorder.
type Recorder struct {
Expand Down
2 changes: 1 addition & 1 deletion runtime/events/recorder_fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion runtime/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ replace (
require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20220903154154-e8044f6e4c72
github.com/fluxcd/pkg/apis/acl v0.1.0
github.com/fluxcd/pkg/apis/meta v0.15.0
github.com/fluxcd/pkg/apis/meta v0.16.0
github.com/go-logr/logr v1.2.3
github.com/google/go-cmp v0.5.9
github.com/hashicorp/go-retryablehttp v0.7.1
Expand Down
2 changes: 1 addition & 1 deletion runtime/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (
// return ctrl.Result{}, client.IgnoreNotFound(err)
// }
//
// // Initialise the patch helper
// // Initialise the patch helper
// patchHelper, err := patch.NewHelper(obj, r.Client)
// if err != nil {
// return ctrl.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion runtime/pprof/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var Endpoints = map[string]http.Handler{
// os.Exit(1)
// }
// pprof.SetupHandlers(mgr, log)
// }
// }
func SetupHandlers(mgr ctrl.Manager, log logr.Logger) {
// Only set the fraction if there is no existing setting
if runtime.SetMutexProfileFraction(-1) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion runtime/predicates/reconcile_requested.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
//
// Controller.Watch(
// &source.Kind{Type: v1.MyCustomKind},
// &handler.EnqueueRequestForObject{},
// &handler.EnqueueRequestForObject{},
// predicate.Or(predicate.GenerationChangedPredicate{}, predicates.ReconcileRequestedPredicate{}))
type ReconcileRequestedPredicate struct {
predicate.Funcs
Expand Down
16 changes: 8 additions & 8 deletions runtime/probes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import (
//
// The func can be used in the main.go file of your controller, after initialisation of the manager:
//
// func main() {
// mgr, err := ctrl.NewManager(cfg, ctrl.Options{})
// if err != nil {
// log.Error(err, "unable to start manager")
// os.Exit(1)
// }
// probes.SetupChecks(mgr, log)
// }
// func main() {
// mgr, err := ctrl.NewManager(cfg, ctrl.Options{})
// if err != nil {
// log.Error(err, "unable to start manager")
// os.Exit(1)
// }
// probes.SetupChecks(mgr, log)
// }
func SetupChecks(mgr ctrl.Manager, log logr.Logger) {
if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil {
log.Error(err, "unable to create ready check")
Expand Down
25 changes: 12 additions & 13 deletions runtime/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,21 @@ func WithCRDPath(path ...string) Option {
// order to override this behavior, the controller-runtime logger can be
// initialized before creating testenv Environment.
//
// import (
// "testing"
// import (
// "testing"
//
// "github.com/fluxcd/pkg/runtime/testenv"
// ctrl "sigs.k8s.io/controller-runtime"
// "sigs.k8s.io/controller-runtime/pkg/log/zap"
// }
// "github.com/fluxcd/pkg/runtime/testenv"
// ctrl "sigs.k8s.io/controller-runtime"
// "sigs.k8s.io/controller-runtime/pkg/log/zap"
// }
//
// func TestMain(m *testing.M) {
// zlog := zap.New(zap.UseDevMode(true))
// ctrl.SetLogger(zlog)
//
// testEnv = testenv.New()
// ...
// }
// func TestMain(m *testing.M) {
// zlog := zap.New(zap.UseDevMode(true))
// ctrl.SetLogger(zlog)
//
// testEnv = testenv.New()
// ...
// }
func New(o ...Option) *Environment {
// Set a default logger if not set already.
log.SetLogger(klogr.New())
Expand Down
5 changes: 3 additions & 2 deletions ssa/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ func (m *ResourceManager) Client() client.Client {

// SetOwnerLabels adds the ownership labels to the given objects.
// The ownership labels are in the format:
// <owner.group>/name: <name>
// <owner.group>/namespace: <namespace>
//
// <owner.group>/name: <name>
// <owner.group>/namespace: <namespace>
func (m *ResourceManager) SetOwnerLabels(objects []*unstructured.Unstructured, name, namespace string) {
for _, object := range objects {
labels := object.GetLabels()
Expand Down

0 comments on commit daa2fc2

Please sign in to comment.