Skip to content

Move to v1beta2 API and rewrite reconcilers #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
Feb 23, 2022
Merged
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
cc1e482
Introduce v1beta2 API package
darkowlzz Jan 28, 2022
7c3c149
Switch to v1beta2 API package
hiddeco Jan 27, 2022
e42eedd
Introduce more explicit Condition types
hiddeco Jul 30, 2021
349739b
Implement new runtime interfaces, prepare testenv
hiddeco Jul 30, 2021
e190059
Introduce `artifactSet` to replace `hasArtifactUpdated`
hiddeco Jul 30, 2021
9eb6833
source: Add `GetRequeueAfter`
darkowlzz Nov 24, 2021
a1efbad
Use new events and metrics helpers in main.go
darkowlzz Nov 24, 2021
b1233dc
Move Artifact conditions to conditions
darkowlzz Nov 24, 2021
dc9d8b7
Add gomega matcher for artifact
darkowlzz Nov 25, 2021
6789aaf
api: Embed runtime.Object in Source interface
darkowlzz Jan 19, 2022
5df4acb
Add internal packages error and reconcile
darkowlzz Dec 19, 2021
5ab2f62
internal/util: introduce temp dir/path helpers
hiddeco Jan 21, 2022
31d2e6d
Rewrite `GitRepositoryReconciler` to new standards
hiddeco Jul 30, 2021
b814070
Fixes to gitrepo reconciler tests
darkowlzz Nov 24, 2021
1818077
controllers: Add more tests for reconcileArtifact
darkowlzz Aug 2, 2021
67bd2cb
Replace %q in messages with '%s'
hiddeco Aug 3, 2021
1e326e8
source: `GetRequeueAfter` in place of `GetInterval`
hiddeco Aug 3, 2021
c2e6875
Tweak logged messages
hiddeco Aug 3, 2021
7e71185
gitrepo: reconcileInclude test assertion fixes
darkowlzz Aug 6, 2021
59b3e5d
gitrepo: Add tests for old conditions update
darkowlzz Aug 7, 2021
3d56988
gitrepo: test reconcileArtifact condtns & symlink
darkowlzz Aug 8, 2021
a437ed6
Consolidate condition types into `FetchFailed`
hiddeco Aug 9, 2021
dbaf21b
Wrap err with context instead of logging twice
hiddeco Aug 10, 2021
88dc2e6
chore: ensure Git server dir is removed after test
hiddeco Aug 11, 2021
25ae83a
gitrepo: Fix SourceVerifiedCondition condition type
darkowlzz Dec 6, 2021
d9a947c
gitrepo: Ignore patch error not found on delete
darkowlzz Dec 6, 2021
5767291
gitrepo: Add more reconciler design improvements
darkowlzz Dec 20, 2021
2acb721
gitrepo: Use internal/util for creating temp dir
darkowlzz Jan 24, 2022
c4fa79c
gitrepo: Fix reconcileInclude() includes
darkowlzz Jan 26, 2022
52f4a2a
bucket: Replace GetInterval() with GetRequeueAfter()
darkowlzz Nov 24, 2021
89ba837
Rewrite `BucketReconciler` to new standards
hiddeco Jul 31, 2021
84301e6
Consolidate condition types into `FetchFailed`
hiddeco Aug 9, 2021
c79a55b
BucketReconciler: Add reconcileArtifact tests
darkowlzz Aug 9, 2021
2577924
Add more reconcileMinioSource test cases
darkowlzz Nov 27, 2021
f472cad
Add bucket controller tests for reconcileGCPSource
darkowlzz Nov 29, 2021
848534a
bucket: Ignore patch error not found on delete
darkowlzz Dec 8, 2021
ba7cbd3
bucket: Add more reconciler design improvements
darkowlzz Dec 20, 2021
5f125eb
helmrepo: Replace GetInterval() with GetRequeueAfter()
darkowlzz Nov 24, 2021
dd68cd5
Rewrite `HelmRepositoryReconciler` to new standards
hiddeco Jul 31, 2021
f14a053
helmrepo: Add more reconciler design improvements
darkowlzz Dec 16, 2021
e0e048a
helmchart: Replace GetInterval() with GetRequeueAfter()
darkowlzz Nov 24, 2021
8e107ea
HelmChartReconciler refactor
hiddeco Dec 8, 2021
527fce0
Rewrite HelmChartReconciler tests
hiddeco Jan 21, 2022
032ffb4
controllers: tweak events and logging
hiddeco Jan 26, 2022
ceb61a3
controllers: remove legacy test suite
hiddeco Jan 26, 2022
474658a
api: remove obsolete constants
hiddeco Jan 26, 2022
78882b3
Consolidate result conversion and computation
darkowlzz Jan 27, 2022
eb0a554
internal/helm: ErrChartReference on local load err
hiddeco Jan 27, 2022
fb45032
controllers: only handle BuildError
hiddeco Jan 27, 2022
21a7dfe
controllers: HelmChart Reconcile test
hiddeco Jan 27, 2022
028a85d
controllers: cleanup TestStorageCopyFromPath files
hiddeco Jan 28, 2022
ad0993e
controllers: truncate temporary cached Helm index
hiddeco Jan 28, 2022
849f7ee
controllers: replace `logr.NewContext` shims
hiddeco Jan 28, 2022
9b56137
storage: Return details about the deleted items
darkowlzz Jan 31, 2022
d997876
Make generic SummarizeAndPatch()
darkowlzz Feb 4, 2022
45df2d7
Update API descriptions and messages to be consistent
darkowlzz Feb 9, 2022
acda998
gitrepo: Use commit msg in NewArtifact message
darkowlzz Feb 15, 2022
47d0958
bucket: Make NewArtifact event more informative
darkowlzz Feb 15, 2022
07a539e
build: update meta API and pkg/runtime to non RC
hiddeco Feb 18, 2022
f72a28a
Use field owner in the patch helper
darkowlzz Feb 21, 2022
e9ae0c2
Add kstatus client conformance tests
darkowlzz Feb 21, 2022
84bf8c8
fuzz: Update to use v1beta2 APIs
darkowlzz Feb 21, 2022
9c7661d
helmrepo: Make NewArtifact event human friendly
darkowlzz Feb 21, 2022
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ manifests: controller-gen ## Generate manifests, e.g. CRD, RBAC, etc.
cd api; $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config="../config/crd/bases"

api-docs: gen-crd-api-reference-docs ## Generate API reference documentation
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md

tidy: ## Run go mod tidy
go mod tidy
12 changes: 12 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
domain: toolkit.fluxcd.io
repo: github.com/fluxcd/source-controller
resources:
- group: source
kind: GitRepository
version: v1beta2
- group: source
kind: HelmRepository
version: v1beta2
- group: source
kind: HelmChart
version: v1beta2
- group: source
kind: Bucket
version: v1beta2
- group: source
kind: GitRepository
version: v1beta1
6 changes: 3 additions & 3 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ go 1.17

require (
github.com/fluxcd/pkg/apis/acl v0.0.3
github.com/fluxcd/pkg/apis/meta v0.10.2
k8s.io/apimachinery v0.23.1
github.com/fluxcd/pkg/apis/meta v0.12.0
k8s.io/apimachinery v0.23.2
sigs.k8s.io/controller-runtime v0.11.0
)

@@ -24,5 +24,5 @@ require (
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
)
11 changes: 6 additions & 5 deletions api/go.sum
Original file line number Diff line number Diff line change
@@ -123,8 +123,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6k1lc=
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
github.com/fluxcd/pkg/apis/meta v0.10.2 h1:pnDBBEvfs4HaKiVAYgz+e/AQ8dLvcgmVfSeBroZ/KKI=
github.com/fluxcd/pkg/apis/meta v0.10.2/go.mod h1:KQ2er9xa6koy7uoPMZjIjNudB5p4tXs+w0GO6fRcy7I=
github.com/fluxcd/pkg/apis/meta v0.12.0 h1:Ssyltj6E9A7y32sZrzjog0m+bIsFM/3lHHfmpxesUAU=
github.com/fluxcd/pkg/apis/meta v0.12.0/go.mod h1:SPrSWMwDK7Ls2/4GadzhjDjPFbKrzzgzuZ0oDO3jzso=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -897,8 +897,8 @@ k8s.io/api v0.23.0 h1:WrL1gb73VSC8obi8cuYETJGXEoFNEh3LU0Pt+Sokgro=
k8s.io/api v0.23.0/go.mod h1:8wmDdLBHBNxtOIytwLstXt5E9PddnZb0GaMcqsvDBpg=
k8s.io/apiextensions-apiserver v0.23.0/go.mod h1:xIFAEEDlAZgpVBl/1VSjGDmLoXAWRG40+GsWhKhAxY4=
k8s.io/apimachinery v0.23.0/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc=
k8s.io/apimachinery v0.23.1 h1:sfBjlDFwj2onG0Ijx5C+SrAoeUscPrmghm7wHP+uXlo=
k8s.io/apimachinery v0.23.1/go.mod h1:SADt2Kl8/sttJ62RRsi9MIV4o8f5S3coArm0Iu3fBno=
k8s.io/apimachinery v0.23.2 h1:dBmjCOeYBdg2ibcQxMuUq+OopZ9fjfLIR5taP/XKeTs=
k8s.io/apimachinery v0.23.2/go.mod h1:zDqeV0AK62LbCI0CI7KbWCAYdLg+E+8UXJ0rIz5gmS8=
k8s.io/apiserver v0.23.0/go.mod h1:Cec35u/9zAepDPPFyT+UMrgqOCjgJ5qtfVJDxjZYmt4=
k8s.io/client-go v0.23.0/go.mod h1:hrDnpnK1mSr65lHHcUuIZIXDgEbzc7/683c6hyG4jTA=
k8s.io/code-generator v0.23.0/go.mod h1:vQvOhDXhuzqiVfM/YHp+dmg10WDZCchJVObc9MvowsE=
@@ -924,8 +924,9 @@ sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87J
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY=
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 h1:kDvPBbnPk+qYmkHmSo8vKGp438IASWofnbbUKDE/bv0=
sigs.k8s.io/structured-merge-diff/v4 v4.2.0/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
24 changes: 21 additions & 3 deletions api/v1beta1/bucket_types.go
Original file line number Diff line number Diff line change
@@ -126,7 +126,13 @@ func BucketProgressing(bucket Bucket) Bucket {
bucket.Status.ObservedGeneration = bucket.Generation
bucket.Status.URL = ""
bucket.Status.Conditions = []metav1.Condition{}
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: meta.ProgressingReason,
Message: "reconciliation in progress",
}
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
return bucket
}

@@ -136,14 +142,26 @@ func BucketProgressing(bucket Bucket) Bucket {
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
bucket.Status.Artifact = &artifact
bucket.Status.URL = url
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
return bucket
}

// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
// the given reason and message. It returns the modified Bucket.
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
return bucket
}

24 changes: 21 additions & 3 deletions api/v1beta1/gitrepository_types.go
Original file line number Diff line number Diff line change
@@ -196,7 +196,13 @@ func GitRepositoryProgressing(repository GitRepository) GitRepository {
repository.Status.ObservedGeneration = repository.Generation
repository.Status.URL = ""
repository.Status.Conditions = []metav1.Condition{}
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: meta.ProgressingReason,
Message: "reconciliation in progress",
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

@@ -207,15 +213,27 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, includedArt
repository.Status.Artifact = &artifact
repository.Status.IncludedArtifacts = includedArtifacts
repository.Status.URL = url
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

// GitRepositoryNotReady sets the meta.ReadyCondition on the given GitRepository
// to 'False', with the given reason and message. It returns the modified
// GitRepository.
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

24 changes: 21 additions & 3 deletions api/v1beta1/helmchart_types.go
Original file line number Diff line number Diff line change
@@ -152,7 +152,13 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
chart.Status.ObservedGeneration = chart.Generation
chart.Status.URL = ""
chart.Status.Conditions = []metav1.Condition{}
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: meta.ProgressingReason,
Message: "reconciliation in progress",
}
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
return chart
}

@@ -162,15 +168,27 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
chart.Status.Artifact = &artifact
chart.Status.URL = url
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
return chart
}

// HelmChartNotReady sets the meta.ReadyCondition on the given HelmChart to
// 'False', with the given reason and message. It returns the modified
// HelmChart.
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
return chart
}

24 changes: 21 additions & 3 deletions api/v1beta1/helmrepository_types.go
Original file line number Diff line number Diff line change
@@ -113,7 +113,13 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
repository.Status.ObservedGeneration = repository.Generation
repository.Status.URL = ""
repository.Status.Conditions = []metav1.Condition{}
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: meta.ProgressingReason,
Message: "reconciliation in progress",
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

@@ -123,15 +129,27 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
repository.Status.Artifact = &artifact
repository.Status.URL = url
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

// HelmRepositoryNotReady sets the meta.ReadyCondition on the given
// HelmRepository to 'False', with the given reason and message. It returns the
// modified HelmRepository.
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
return repository
}

2 changes: 1 addition & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

76 changes: 76 additions & 0 deletions api/v1beta2/artifact_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2022 The Flux 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

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,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta2

import (
"path"
"strings"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Artifact represents the output of a Source synchronisation.
type Artifact struct {
// Path is the relative file path of this Artifact.
// It can be used to locate the Artifact file in the root of the Artifact
// storage on the local file system of the controller managing the Source.
// +required
Path string `json:"path"`

// URL is the HTTP address of this artifact.
// It is used by the consumers of the artifacts to fetch and use the
// artifacts. It is expected to be resolvable from within the cluster.
// +required
URL string `json:"url"`

// Revision is a human readable identifier traceable in the origin source
// system. It can be a Git commit SHA, Git tag, a Helm index timestamp, a Helm
// chart version, etc.
// +optional
Revision string `json:"revision"`

// Checksum is the SHA256 checksum of the artifact.
// +optional
Checksum string `json:"checksum"`

// LastUpdateTime is the timestamp corresponding to the last update of this
// artifact.
// +required
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
}

// HasRevision returns true if the given revision matches the current Revision
// of the Artifact.
func (in *Artifact) HasRevision(revision string) bool {
if in == nil {
return false
}
return in.Revision == revision
}

// ArtifactDir returns the artifact dir path in the form of
// <source-kind>/<source-namespace>/<source-name>.
func ArtifactDir(kind, namespace, name string) string {
kind = strings.ToLower(kind)
return path.Join(kind, namespace, name)
}

// ArtifactPath returns the artifact path in the form of
// <source-kind>/<source-namespace>/<source-name>/<artifact-filename>.
func ArtifactPath(kind, namespace, name, filename string) string {
return path.Join(ArtifactDir(kind, namespace, name), filename)
}
Loading