Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Add presubmit_tests.sh file for ci #13

Merged
1 commit merged into from Mar 9, 2022
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
8 changes: 8 additions & 0 deletions .errcheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(*github.com/tektoncd/pipeline/vendor/go.uber.org/zap.SugaredLogger).Sync
flag.Set
os.Setenv
logger.Sync
fmt.Fprintf
fmt.Fprintln
(io.Closer).Close
updateConfigMap
41 changes: 41 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
linters-settings:
errcheck:
exclude: .errcheck.txt
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gofmt
- goimports
- gosec
- gocritic
- revive
- misspell
- unconvert
output:
uniq-by-line: false
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
max-issues-per-linter: 0
max-same-issues: 0
include:
# Enable off-by-default rules for revive requiring that all exported elements have a properly formatted comment.
- EXC0012
- EXC0014
run:
issues-exit-code: 1
build-tags:
- e2e
skip-files:
- .*/zz_generated.deepcopy.go
- pkg/apis/pipeline/v1beta1/openapi_generated.go
skip-dirs:
- vendor
- pkg/client
timeout: 10m
modules-download-mode: vendor
36 changes: 36 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ignore: |
/vendor
test/**/*-chart/**

rules:
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
level: warning
comments-indentation:
level: warning
document-end: disable
document-start: disable
empty-lines: enable
empty-values: enable
hyphens: enable
key-duplicates: enable
key-ordering: disable
line-length: disable
new-line-at-end-of-file: disable
new-lines: enable
octal-values: enable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning

# accept both key:
# - item
#
# and key:
# - item
indentation:
indent-sequences: whatever
6 changes: 6 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{

var callbacks = map[schema.GroupVersionKind]validation.Callback{}

// NewDefaultingAdmissionController returns the defaulting webhook's
// controller.
func NewDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return defaulting.NewAdmissionController(ctx,

Expand All @@ -67,6 +69,8 @@ func NewDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher
)
}

// NewValidationAdmissionController returns the validating webhook's
// controller.
func NewValidationAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return validation.NewAdmissionController(ctx,

Expand Down Expand Up @@ -94,6 +98,8 @@ func NewValidationAdmissionController(ctx context.Context, cmw configmap.Watcher
)
}

// NewConfigValidationController returns the configmap validation
// webhook's controller.
func NewConfigValidationController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return configmaps.NewAdmissionController(ctx,

Expand Down
3 changes: 2 additions & 1 deletion config/200-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ aggregationRule:
clusterRoleSelectors:
- matchLabels:
resolution.tekton.dev/controller: "true"
rules: [] # Rules are automatically filled in by the controller manager.
# Rules are automatically filled in by the controller manager.
rules: []

---
kind: ClusterRole
Expand Down
2 changes: 1 addition & 1 deletion config/300-resourcerequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
served: true
storage: true
subresources:
status: { }
status: {}
schema:
openAPIV3Schema:
type: object
Expand Down
2 changes: 2 additions & 0 deletions gitresolver/pkg/git/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ limitations under the License.
package git

const (
// AnnotationKeyCommitHash is the commit hash that was fetched
// from git
AnnotationKeyCommitHash = "commit"
)
7 changes: 7 additions & 0 deletions gitresolver/pkg/git/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ limitations under the License.

package git

// URLParam is the git repo url
const URLParam string = "url"

// PathParam is the path into the git repo where a file is located
const PathParam string = "path"

// CommitParam is the commit hash that a file should be fetched from
const CommitParam string = "commit"

// BranchParam is the git branch that a file should be fetched from
const BranchParam string = "branch"
20 changes: 20 additions & 0 deletions gitresolver/pkg/git/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,43 @@ import (
"github.com/tektoncd/resolution/pkg/resolver/framework"
)

// LabelValueGitResolverType is the value to use for the
// resolution.tekton.dev/type label on resource requests
const LabelValueGitResolverType string = "git"

// GitResolverName is the name that the git resolver should be
// associated with
const GitResolverName string = "Git"

// YAMLContentType is the content type to use when returning yaml
const YAMLContentType string = "application/x-yaml"

var _ framework.Resolver = &Resolver{}

// Resolver implements a framework.Resolver that can fetch files from git.
type Resolver struct{}

// Initialize performs any setup required by the gitresolver.
func (r *Resolver) Initialize(ctx context.Context) error {
return nil
}

// GetName returns the string name that the gitresolver should be
// associated with.
func (r *Resolver) GetName(_ context.Context) string {
return GitResolverName
}

// GetSelector returns the labels that resource requests are required to have for
// the gitresolver to process them.
func (r *Resolver) GetSelector(_ context.Context) map[string]string {
return map[string]string{
resolutioncommon.LabelKeyResolverType: LabelValueGitResolverType,
}
}

// ValidateParams returns an error if the given parameter map is not
// valid for a resource request targeting the gitresolver.
func (r *Resolver) ValidateParams(_ context.Context, params map[string]string) error {
required := []string{
URLParam,
Expand Down Expand Up @@ -83,6 +98,8 @@ func (r *Resolver) ValidateParams(_ context.Context, params map[string]string) e
return nil
}

// Resolve performs the work of fetching a file from git given a map of
// parameters.
func (r *Resolver) Resolve(_ context.Context, params map[string]string) (framework.ResolvedResource, error) {
repo := params[URLParam]
commit := params[CommitParam]
Expand Down Expand Up @@ -146,10 +163,13 @@ type ResolvedGitResource struct {

var _ framework.ResolvedResource = &ResolvedGitResource{}

// Data returns the bytes of the file resolved from git.
func (r *ResolvedGitResource) Data() []byte {
return r.Content
}

// Annotations returns the metadata that accompanies the file fetched
// from git.
func (r *ResolvedGitResource) Annotations() map[string]string {
return map[string]string{
AnnotationKeyCommitHash: r.Commit,
Expand Down
85 changes: 2 additions & 83 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module github.com/tektoncd/resolution

go 1.17
go 1.16

require (
github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2
github.com/tektoncd/plumbing v0.0.0-20220304154415-13228ac1f4a4
go.uber.org/zap v1.19.0
k8s.io/api v0.21.4
k8s.io/apimachinery v0.21.4
Expand All @@ -16,93 +17,11 @@ require (
)

require (
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-kit/log v0.1.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/spec v0.20.2 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/gobuffalo/flect v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/statsd_exporter v0.21.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/automaxprocs v1.4.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/api v0.36.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210416161957-9910b6c460de // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.21.4 // indirect
k8s.io/gengo v0.0.0-20210203185629-de9496dff47b // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.8.0 // indirect
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading