commit
22bbab7fe4
|
@ -42,14 +42,14 @@ jobs:
|
|||
- name: Run smoke tests
|
||||
run: |
|
||||
kubectl apply -f ./config/samples
|
||||
kubectl -n sourcer-system rollout status deploy/sourcer-controller --timeout=1m
|
||||
kubectl -n source-system rollout status deploy/source-controller --timeout=1m
|
||||
kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m
|
||||
kubectl wait helmrepository/podinfo --for=condition=ready --timeout=1m
|
||||
kubectl -n sourcer-system logs deploy/sourcer-controller
|
||||
kubectl -n source-system logs deploy/source-controller
|
||||
- name: Debug failure
|
||||
if: failure()
|
||||
run: |
|
||||
kubectl get gitrepositories -oyaml
|
||||
kubectl get helmrepositories -oyaml
|
||||
kubectl -n sourcer-system get all
|
||||
kubectl -n sourcer-system logs deploy/sourcer-controller
|
||||
kubectl -n source-system get all
|
||||
kubectl -n source-system logs deploy/source-controller
|
||||
|
|
|
@ -15,12 +15,12 @@ COPY api/ api/
|
|||
COPY controllers/ controllers/
|
||||
|
||||
# build
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o sourcer main.go
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go
|
||||
|
||||
FROM alpine:3.11
|
||||
|
||||
RUN apk add --no-cache openssh-client ca-certificates tini 'git>=2.12.0' socat curl bash
|
||||
|
||||
COPY --from=builder /workspace/sourcer /usr/local/bin/
|
||||
COPY --from=builder /workspace/source-controller /usr/local/bin/
|
||||
|
||||
ENTRYPOINT [ "/sbin/tini", "--", "sourcer" ]
|
||||
ENTRYPOINT [ "/sbin/tini", "--", "source-controller" ]
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,6 +1,6 @@
|
|||
|
||||
# Image URL to use all building/pushing image targets
|
||||
IMG ?= fluxcd/sourcer:latest
|
||||
IMG ?= fluxcd/source-controller:latest
|
||||
# Produce CRDs that work back to Kubernetes 1.13
|
||||
CRD_OPTIONS ?= crd
|
||||
|
||||
|
@ -35,13 +35,13 @@ uninstall: manifests
|
|||
|
||||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
|
||||
deploy: manifests
|
||||
cd config/manager && kustomize edit set image fluxcd/sourcer=${IMG}
|
||||
cd config/manager && kustomize edit set image fluxcd/source-controller=${IMG}
|
||||
kustomize build config/default | kubectl apply -f -
|
||||
|
||||
# Deploy controller dev image in the configured Kubernetes cluster in ~/.kube/config
|
||||
dev-deploy: manifests
|
||||
mkdir -p config/dev && cp config/default/* config/dev
|
||||
cd config/dev && kustomize edit set image fluxcd/sourcer=${IMG}
|
||||
cd config/dev && kustomize edit set image fluxcd/source-controller=${IMG}
|
||||
kustomize build config/dev | kubectl apply -f -
|
||||
rm -rf config/dev
|
||||
|
||||
|
|
6
PROJECT
6
PROJECT
|
@ -1,10 +1,10 @@
|
|||
domain: fluxcd.io
|
||||
repo: github.com/fluxcd/sourcer
|
||||
repo: github.com/fluxcd/source-controller
|
||||
resources:
|
||||
- group: sourcer
|
||||
- group: source
|
||||
kind: GitRepository
|
||||
version: v1alpha1
|
||||
- group: sourcer
|
||||
- group: source
|
||||
kind: HelmRepository
|
||||
version: v1alpha1
|
||||
version: "2"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# sourcer
|
||||
Experimental source manager
|
||||
# Source controller
|
||||
|
||||
Experimental source manager and artifact provider.
|
||||
|
|
|
@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the sourcer v1alpha1 API group
|
||||
// Package v1alpha1 contains API Schema definitions for the source v1alpha1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=sourcer.fluxcd.io
|
||||
// +groupName=source.fluxcd.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
GroupVersion = schema.GroupVersion{Group: "sourcer.fluxcd.io", Version: "v1alpha1"}
|
||||
GroupVersion = schema.GroupVersion{Group: "source.fluxcd.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
|
|
@ -6,7 +6,7 @@ metadata:
|
|||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.2.5
|
||||
creationTimestamp: null
|
||||
name: gitrepositories.sourcer.fluxcd.io
|
||||
name: gitrepositories.source.fluxcd.io
|
||||
spec:
|
||||
additionalPrinterColumns:
|
||||
- JSONPath: .spec.url
|
||||
|
@ -21,7 +21,7 @@ spec:
|
|||
- JSONPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
group: sourcer.fluxcd.io
|
||||
group: source.fluxcd.io
|
||||
names:
|
||||
kind: GitRepository
|
||||
listKind: GitRepositoryList
|
|
@ -6,7 +6,7 @@ metadata:
|
|||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.2.5
|
||||
creationTimestamp: null
|
||||
name: helmrepositories.sourcer.fluxcd.io
|
||||
name: helmrepositories.source.fluxcd.io
|
||||
spec:
|
||||
additionalPrinterColumns:
|
||||
- JSONPath: .spec.url
|
||||
|
@ -21,7 +21,7 @@ spec:
|
|||
- JSONPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
group: sourcer.fluxcd.io
|
||||
group: source.fluxcd.io
|
||||
names:
|
||||
kind: HelmRepository
|
||||
listKind: HelmRepositoryList
|
|
@ -1,7 +1,7 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- bases/sourcer.fluxcd.io_gitrepositories.yaml
|
||||
- bases/sourcer.fluxcd.io_helmrepositories.yaml
|
||||
- bases/source.fluxcd.io_gitrepositories.yaml
|
||||
- bases/source.fluxcd.io_helmrepositories.yaml
|
||||
# +kubebuilder:scaffold:crdkustomizeresource
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: sourcer-system
|
||||
namePrefix: sourcer-
|
||||
namespace: source-system
|
||||
namePrefix: source-
|
||||
bases:
|
||||
- ../crd
|
||||
- ../rbac
|
||||
|
|
|
@ -8,12 +8,12 @@ metadata:
|
|||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sourcer
|
||||
app: source-controller
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sourcer
|
||||
app: source-controller
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "9090"
|
||||
|
@ -21,7 +21,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
- name: manager
|
||||
image: fluxcd/sourcer
|
||||
image: fluxcd/source-controller
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
|
|
@ -5,5 +5,5 @@ resources:
|
|||
- service.yaml
|
||||
- deployment.yaml
|
||||
images:
|
||||
- name: fluxcd/sourcer
|
||||
- name: fluxcd/source-controller
|
||||
newTag: 0.0.1-alpha.1
|
||||
|
|
|
@ -8,7 +8,7 @@ metadata:
|
|||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: sourcer
|
||||
app: source-controller
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
name: gitrepository-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories
|
||||
verbs:
|
||||
|
@ -17,7 +17,7 @@ rules:
|
|||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories/status
|
||||
verbs:
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
name: gitrepository-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories
|
||||
verbs:
|
||||
|
@ -13,7 +13,7 @@ rules:
|
|||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories/status
|
||||
verbs:
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
name: helmrepository-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories
|
||||
verbs:
|
||||
|
@ -17,7 +17,7 @@ rules:
|
|||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories/status
|
||||
verbs:
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
name: helmrepository-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories
|
||||
verbs:
|
||||
|
@ -13,7 +13,7 @@ rules:
|
|||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories/status
|
||||
verbs:
|
||||
|
|
|
@ -7,7 +7,7 @@ metadata:
|
|||
name: manager-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories
|
||||
verbs:
|
||||
|
@ -19,7 +19,7 @@ rules:
|
|||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- gitrepositories/status
|
||||
verbs:
|
||||
|
@ -27,7 +27,7 @@ rules:
|
|||
- patch
|
||||
- update
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories
|
||||
verbs:
|
||||
|
@ -39,7 +39,7 @@ rules:
|
|||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- sourcer.fluxcd.io
|
||||
- source.fluxcd.io
|
||||
resources:
|
||||
- helmrepositories/status
|
||||
verbs:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
apiVersion: sourcer.fluxcd.io/v1alpha1
|
||||
apiVersion: source.fluxcd.io/v1alpha1
|
||||
kind: GitRepository
|
||||
metadata:
|
||||
name: podinfo
|
||||
annotations:
|
||||
sourcer.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
|
||||
source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
|
||||
spec:
|
||||
interval: 1m
|
||||
url: https://github.com/stefanprodan/podinfo
|
|
@ -1,8 +1,7 @@
|
|||
apiVersion: sourcer.fluxcd.io/v1alpha1
|
||||
apiVersion: source.fluxcd.io/v1alpha1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: podinfo
|
||||
spec:
|
||||
interval: 1m
|
||||
url: https://stefanprodan.github.io/podinfo
|
||||
|
|
@ -38,7 +38,7 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
||||
|
||||
sourcerv1 "github.com/fluxcd/sourcer/api/v1alpha1"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||
)
|
||||
|
||||
// GitRepositoryReconciler reconciles a GitRepository object
|
||||
|
@ -49,8 +49,8 @@ type GitRepositoryReconciler struct {
|
|||
StoragePath string
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=gitrepositories,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=gitrepositories/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=source.fluxcd.io,resources=gitrepositories,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=source.fluxcd.io,resources=gitrepositories/status,verbs=get;update;patch
|
||||
|
||||
func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
|
@ -58,7 +58,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
|
|||
|
||||
log := r.Log.WithValues("gitrepository", req.NamespacedName)
|
||||
|
||||
var repo sourcerv1.GitRepository
|
||||
var repo sourcev1.GitRepository
|
||||
if err := r.Get(ctx, req.NamespacedName, &repo); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
|
|||
log.Info("Initialising repository")
|
||||
repo.Status.Artifacts = ""
|
||||
repo.Status.LastUpdateTime = nil
|
||||
repo.Status.Conditions = []sourcerv1.RepositoryCondition{
|
||||
repo.Status.Conditions = []sourcev1.RepositoryCondition{
|
||||
{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionUnknown,
|
||||
},
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
|
|||
// update status
|
||||
timeNew := metav1.Now()
|
||||
readyCondition.LastTransitionTime = &timeNew
|
||||
repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition}
|
||||
repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition}
|
||||
|
||||
if err := r.Status().Update(ctx, &repo); err != nil {
|
||||
log.Error(err, "unable to update GitRepository status")
|
||||
|
@ -112,7 +112,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
|
|||
|
||||
func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&sourcerv1.GitRepository{}).
|
||||
For(&sourcev1.GitRepository{}).
|
||||
WithEventFilter(RepositoryChangePredicate{}).
|
||||
WithEventFilter(predicate.Funcs{
|
||||
DeleteFunc: func(e event.DeleteEvent) bool {
|
||||
|
@ -132,7 +132,7 @@ func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
|||
Complete(r)
|
||||
}
|
||||
|
||||
func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.RepositoryCondition, string, error) {
|
||||
func (r *GitRepositoryReconciler) sync(gr sourcev1.GitRepository) (sourcev1.RepositoryCondition, string, error) {
|
||||
// determine ref
|
||||
refName := plumbing.NewBranchReferenceName("master")
|
||||
if gr.Spec.Branch != "" {
|
||||
|
@ -146,8 +146,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
dir, err := ioutil.TempDir("", gr.Name)
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("tmp dir error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "ExecFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -165,8 +165,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
})
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("git clone error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCloneFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -178,8 +178,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
rng, err := semver.ParseRange(gr.Spec.SemVer)
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("semver parse range error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCloneFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -189,8 +189,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
repoTags, err := repo.Tags()
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("git list tags error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCloneFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -222,8 +222,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
w, err := repo.Worktree()
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("git worktree error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCheckoutFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -235,8 +235,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
})
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("git checkout error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCheckoutFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -244,8 +244,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
}
|
||||
} else {
|
||||
ex := fmt.Errorf("no match found for semver %s", gr.Spec.SemVer)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitCheckoutFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -257,8 +257,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
ref, err := repo.Head()
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("git resolve HEAD error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "GitHeadFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -271,8 +271,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
err = os.MkdirAll(storage, 0777)
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("mkdir dir error %w", err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "ExecFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -287,8 +287,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
err = command.Run()
|
||||
if err != nil {
|
||||
ex := fmt.Errorf("tar %s error %w", artifacts, err)
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: "ExecFailed",
|
||||
Message: ex.Error(),
|
||||
|
@ -305,15 +305,15 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re
|
|||
artifactsURL := fmt.Sprintf("http://%s/repositories/%s-%s/%s.tar.gz",
|
||||
hostname, gr.Name, gr.Namespace, ref.Hash().String())
|
||||
|
||||
return sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
return sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionTrue,
|
||||
Reason: "GitCloneSucceed",
|
||||
Message: fmt.Sprintf("Fetched artifacts are available at %s", artifacts),
|
||||
}, artifactsURL, nil
|
||||
}
|
||||
|
||||
func (r *GitRepositoryReconciler) shouldResetStatus(gr sourcerv1.GitRepository) bool {
|
||||
func (r *GitRepositoryReconciler) shouldResetStatus(gr sourcev1.GitRepository) bool {
|
||||
resetStatus := false
|
||||
if gr.Status.Artifacts != "" {
|
||||
pathParts := strings.Split(gr.Status.Artifacts, "/")
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
sourcerv1 "github.com/fluxcd/sourcer/api/v1alpha1"
|
||||
"github.com/go-logr/logr"
|
||||
"gopkg.in/yaml.v2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
@ -33,6 +32,8 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||
)
|
||||
|
||||
// HelmRepositoryReconciler reconciles a HelmRepository object
|
||||
|
@ -42,8 +43,8 @@ type HelmRepositoryReconciler struct {
|
|||
Scheme *runtime.Scheme
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=helmrepositories/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=source.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=source.fluxcd.io,resources=helmrepositories/status,verbs=get;update;patch
|
||||
|
||||
func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
|
@ -51,27 +52,27 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
|
|||
|
||||
log := r.Log.WithValues("helmrepository", req.NamespacedName)
|
||||
|
||||
var repo sourcerv1.HelmRepository
|
||||
var repo sourcev1.HelmRepository
|
||||
|
||||
if err := r.Get(ctx, req.NamespacedName, &repo); err != nil {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
readyCondition := sourcerv1.RepositoryCondition{
|
||||
Type: sourcerv1.RepositoryConditionReady,
|
||||
readyCondition := sourcev1.RepositoryCondition{
|
||||
Type: sourcev1.RepositoryConditionReady,
|
||||
Status: corev1.ConditionUnknown,
|
||||
}
|
||||
|
||||
if len(repo.Status.Conditions) == 0 {
|
||||
log.Info("Starting index download")
|
||||
repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition}
|
||||
repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition}
|
||||
if err := r.Status().Update(ctx, &repo); err != nil {
|
||||
log.Error(err, "unable to update HelmRepository status")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
} else {
|
||||
for _, condition := range repo.Status.Conditions {
|
||||
if condition.Type == sourcerv1.RepositoryConditionReady {
|
||||
if condition.Type == sourcev1.RepositoryConditionReady {
|
||||
readyCondition = condition
|
||||
break
|
||||
}
|
||||
|
@ -80,19 +81,19 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
|
|||
|
||||
if err := r.downloadIndex(repo.Spec.Url); err != nil {
|
||||
log.Info("Index download error", "error", err.Error())
|
||||
readyCondition.Reason = sourcerv1.IndexDownloadFailedReason
|
||||
readyCondition.Reason = sourcev1.IndexDownloadFailedReason
|
||||
readyCondition.Message = err.Error()
|
||||
readyCondition.Status = corev1.ConditionFalse
|
||||
} else {
|
||||
log.Info("Index download successful")
|
||||
readyCondition.Reason = sourcerv1.IndexDownloadSucceedReason
|
||||
readyCondition.Reason = sourcev1.IndexDownloadSucceedReason
|
||||
readyCondition.Message = "Repository is ready"
|
||||
readyCondition.Status = corev1.ConditionTrue
|
||||
}
|
||||
|
||||
timeNew := metav1.Now()
|
||||
readyCondition.LastTransitionTime = &timeNew
|
||||
repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition}
|
||||
repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition}
|
||||
|
||||
if err := r.Status().Update(ctx, &repo); err != nil {
|
||||
log.Error(err, "unable to update HelmRepository status")
|
||||
|
@ -104,7 +105,7 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
|
|||
|
||||
func (r *HelmRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&sourcerv1.HelmRepository{}).
|
||||
For(&sourcev1.HelmRepository{}).
|
||||
WithEventFilter(RepositoryChangePredicate{}).
|
||||
Complete(r)
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@ func (RepositoryChangePredicate) Update(e event.UpdateEvent) bool {
|
|||
}
|
||||
|
||||
const (
|
||||
ForceSyncAnnotation string = "sourcer.fluxcd.io/syncAt"
|
||||
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
|
||||
sourcerv1alpha1 "github.com/fluxcd/sourcer/api/v1alpha1"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||
// +kubebuilder:scaffold:imports
|
||||
)
|
||||
|
||||
|
@ -62,10 +62,10 @@ var _ = BeforeSuite(func(done Done) {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(cfg).ToNot(BeNil())
|
||||
|
||||
err = sourcerv1alpha1.AddToScheme(scheme.Scheme)
|
||||
err = sourcev1.AddToScheme(scheme.Scheme)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = sourcerv1alpha1.AddToScheme(scheme.Scheme)
|
||||
err = sourcev1.AddToScheme(scheme.Scheme)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// +kubebuilder:scaffold:scheme
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module github.com/fluxcd/sourcer
|
||||
module github.com/fluxcd/source-controller
|
||||
|
||||
go 1.13
|
||||
|
||||
|
|
6
main.go
6
main.go
|
@ -29,8 +29,8 @@ import (
|
|||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
|
||||
sourcerv1alpha1 "github.com/fluxcd/sourcer/api/v1alpha1"
|
||||
"github.com/fluxcd/sourcer/controllers"
|
||||
sourcev1alpha1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||
"github.com/fluxcd/source-controller/controllers"
|
||||
// +kubebuilder:scaffold:imports
|
||||
)
|
||||
|
||||
|
@ -42,7 +42,7 @@ var (
|
|||
func init() {
|
||||
_ = clientgoscheme.AddToScheme(scheme)
|
||||
|
||||
_ = sourcerv1alpha1.AddToScheme(scheme)
|
||||
_ = sourcev1alpha1.AddToScheme(scheme)
|
||||
// +kubebuilder:scaffold:scheme
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue