Skip to content

Commit

Permalink
Update to go 1.22
Browse files Browse the repository at this point in the history
Update go to 1.22
Update other back-end build dependencies:
- ko 0.15
- kustomize 5.3
- golangci-lint 1.57
  • Loading branch information
AlanGreene authored and tekton-robot committed Mar 27, 2024
1 parent 2e2fb39 commit ac3c95f
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 66 deletions.
1 change: 0 additions & 1 deletion .generated_files
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@

file-name package-lock.json
file-name go.sum
path-prefix pkg/client
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
* text=auto eol=lf
**/zz_generated.*.go linguist-generated=true
/pkg/client/** linguist-generated=true
go.sum linguist-generated=true
90 changes: 84 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,102 @@ linters-settings:
errcheck:
exclude: .errcheck.txt
linters:
disable-all: true
enable:
- deadcode
- bodyclose
- containedctx
- decorder
- dogsled
- dupword
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- goconst
- gocritic
- gofmt
- goimports
- gomodguard
- gosec
- gocritic
- revive
- gosimple
- govet
- maintidx
- makezero
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- thelper
- typecheck
- unconvert
- unused
- usestdlibvars
- whitespace
disable:
- contextcheck
- cyclop
- depguard
- dupl
- exhaustruct
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- gocyclo
- godot
- godox
- goerr113
- gofumpt
- gomnd
- gomoddirectives
- ireturn
- lll
- mirror
- nestif
- nlreturn
- nonamedreturns
- paralleltest
- prealloc
- predeclared
- revive
- staticcheck
- stylecheck
- tagliatelle
- testpackage
- tparallel
- unparam
- varnamelen
- wastedassign
- wrapcheck
- wsl
# Enabling presets means that new linters that we automatically adopt new
# linters that augment a preset. This also opts us in for replacement linters
# when a linter is deprecated.
presets:
- bugs
- comment
- complexity
- error
- format
- import
- metalinter
- module
- performance
- sql
- style
- test
- unused
output:
uniq-by-line: false
issues:
exclude-dirs:
- vendor
exclude-rules:
- path: _test\.go
linters:
Expand All @@ -33,7 +113,5 @@ run:
issues-exit-code: 1
build-tags:
- e2e
skip-dirs:
- vendor
timeout: 10m
modules-download-mode: mod
28 changes: 2 additions & 26 deletions cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package main

import (
"flag"
"fmt"
"os"
"strings"

Expand All @@ -24,14 +23,11 @@ import (
"github.com/tektoncd/dashboard/pkg/router"
k8sclientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

var (
help = flag.Bool("help", false, "Prints defaults")
pipelinesNamespace = flag.String("pipelines-namespace", "", "Namespace where Tekton pipelines is installed (assumes same namespace as dashboard if not specified)")
triggersNamespace = flag.String("triggers-namespace", "", "Namespace where Tekton triggers is installed (assumes same namespace as dashboard if not specified)")
kubeConfigPath = flag.String("kube-config", "", "Path to kube config file")
portNumber = flag.Int("port", 8080, "Dashboard port number")
readOnly = flag.Bool("read-only", true, "Enable or disable read-only mode")
logoutURL = flag.String("logout-url", "", "If set, enables logout on the frontend and binds the logout button to this URL")
Expand All @@ -46,33 +42,13 @@ var (

func main() {
flag.Parse()

installNamespace := os.Getenv("INSTALLED_NAMESPACE")

if *help {
fmt.Println("dashboard starts Tekton dashboard backend.")
fmt.Println()
fmt.Println("find more information at: https://github.com/tektoncd/dashboard")
fmt.Println()
fmt.Println("options:")
fmt.Println()
flag.PrintDefaults()
return
}

logging.InitLogger(*logLevel, *logFormat)

var cfg *rest.Config
var err error
if *kubeConfigPath != "" {
cfg, err = clientcmd.BuildConfigFromFlags("", *kubeConfigPath)
if err != nil {
logging.Log.Errorf("Error building kubeconfig from %s: %s", *kubeConfigPath, err.Error())
}
} else {
if cfg, err = rest.InClusterConfig(); err != nil {
logging.Log.Errorf("Error building kubeconfig: %s", err.Error())
}
if cfg, err = rest.InClusterConfig(); err != nil {
logging.Log.Errorf("Error building kubeconfig: %s", err.Error())
}

k8sClient, err := k8sclientset.NewForConfig(cfg)
Expand Down
21 changes: 3 additions & 18 deletions docs/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ This guide explains how to build, deploy and test the Tekton Dashboard. It cover
In order to run the Tekton Dashboard, please make sure the requirements in [the install doc](../install.md) are met.

You will also need the following tools in order to build the Dashboard locally and deploy it:
1. [`go`](https://golang.org/doc/install): The language the Tekton Dashboard backend is built in. `go` version 1.20.x
1. [`go`](https://golang.org/doc/install): The language the Tekton Dashboard backend is built in. `go` version 1.22.x
1. [`git`](https://help.github.com/articles/set-up-git/): For source control
1. [Node.js & npm](https://nodejs.org/): For building and running the frontend locally. See [`.nvmrc`](/.nvmrc) for version, or run `nvm use`
1. [`ko`](https://github.com/google/ko): For building the backend locally. `ko` version v0.14.x
1. [`ko`](https://github.com/google/ko): For building the backend locally. `ko` version v0.15.x
1. [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/): For interacting with your kube cluster
1. [`kustomize`](https://kubectl.docs.kubernetes.io/installation/kustomize/): For building the Dashboard manifests. v4.5.4 is known to work
1. [`kustomize`](https://kubectl.docs.kubernetes.io/installation/kustomize/): For building the Dashboard manifests. v5.3.0 is known to work

## Checkout your fork

Expand Down Expand Up @@ -75,20 +75,6 @@ npm run preview

**Note**: To help ensure the build process is efficient and content is transformed as required for current browser support, JSX processing is only performed on files with a `.jsx` extension. This means that if a file contains JSX expressions (e.g. `<MyComponent … />` or `<span>…</span>`), it must be named with a `.jsx` extension. This applies to all files containing JSX, including tests, stories, etc.

## Build the backend (optional: for local debugging)

The backend uses `go modules` to manage its dependencies. To build the go backend, run:

```bash
go build ./cmd/dashboard
```

This generates a binary named `dashboard` which you can run on your local computer by invoking it with the `--kube-config` flag:

```bash
./dashboard --kube-config $HOME/.kube/config
```

### Command line arguments

The dashboard backend supports a number of options through command line arguments.
Expand All @@ -98,7 +84,6 @@ These options are documented below:
| Argument | Description | Type | Default value |
|---|---|---|---|
| `--help` | Print help message and exit | `bool` | `false` |
| `--kube-config` | Path to kube config file, uses in cluster config if empty | `string` | `""` |
| `--pipelines-namespace` | Namespace where Tekton pipelines is installed (assumes same namespace as dashboard if not set) | `string` | `""` |
| `--triggers-namespace` | Namespace where Tekton triggers is installed (assumes same namespace as dashboard if not set) | `string` | `""` |
| `--port` | Dashboard port number | `int` | `8080` |
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/tektoncd/dashboard

go 1.20
go 1.22

toolchain go1.22.0

require (
github.com/tektoncd/plumbing v0.0.0-20221005125931-631bdcbca245
Expand All @@ -21,15 +23,13 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.11 // 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/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
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
Expand Down
11 changes: 10 additions & 1 deletion go.sum

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

8 changes: 4 additions & 4 deletions pkg/csrf/csrf.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023 The Tekton Authors
Copyright 2021-2024 The Tekton Authors
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
Expand All @@ -20,8 +20,8 @@ import (
)

var (
errorNoHeader = errors.New("CSRF header not found in request")
headerName = "Tekton-Client"
errNoHeader = errors.New("CSRF header not found in request")
headerName = "Tekton-Client"
// Idempotent (safe) methods as defined by RFC7231 section 4.2.2.
safeMethods = map[string]bool{
"GET": true,
Expand Down Expand Up @@ -76,7 +76,7 @@ func (cs *csrf) ServeHTTP(w http.ResponseWriter, r *http.Request) {

func unauthorizedHandler(w http.ResponseWriter, _ *http.Request) {
http.Error(w, fmt.Sprintf("%s - %s",
http.StatusText(http.StatusForbidden), errorNoHeader),
http.StatusText(http.StatusForbidden), errNoHeader),
http.StatusForbidden)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
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
Expand Down Expand Up @@ -33,7 +33,7 @@ import (

const webResourcesDir = "/var/run/ko"

var webResourcesStaticPattern = regexp.MustCompile("^/([[:alnum:]]+\\.)?[[:alnum:]]+\\.(js)|(css)|(png)$")
var webResourcesStaticPattern = regexp.MustCompile(`^/([[:alnum:]]+\.)?[[:alnum:]]+\.(js)|(css)|(png)$`)
var webResourcesStaticExcludePattern = regexp.MustCompile("^/favicon.png$")

func registerWeb(resource endpoints.Resource, mux *http.ServeMux) {
Expand Down
Loading

0 comments on commit ac3c95f

Please sign in to comment.