Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit f971d50

Browse files
committed
feat: add repository object
This change adds the ability to create repositories and pull requests for different providers.
1 parent 9df3686 commit f971d50

31 files changed

+849
-38
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN go mod download
1313

1414
# Copy the go source
1515
COPY main.go main.go
16-
COPY api/ api/
16+
COPY apis/ apis/
1717
COPY controllers/ controllers/
1818
COPY pkg/ pkg/
1919

PROJECT

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
15
domain: ocm.software
26
layout:
37
- go.kubebuilder.io/v3
8+
multigroup: true
49
projectName: git-controller
510
repo: github.com/open-component-model/git-controller
611
resources:
@@ -11,6 +16,15 @@ resources:
1116
domain: ocm.software
1217
group: delivery
1318
kind: Sync
14-
path: github.com/open-component-model/git-controller/api/v1alpha1
19+
path: github.com/open-component-model/git-controller/apis/delivery/v1alpha1
20+
version: v1alpha1
21+
- api:
22+
crdVersion: v1
23+
namespaced: true
24+
controller: true
25+
domain: ocm.software
26+
group: mpas
27+
kind: Repository
28+
path: github.com/open-component-model/git-controller/apis/mpas/v1alpha1
1529
version: v1alpha1
1630
version: "3"

api/v1alpha1/condition_types.go renamed to apis/delivery/v1alpha1/condition_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Copyright 2022.
21
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
32
//
43
// SPDX-License-Identifier: Apache-2.0

api/v1alpha1/groupversion_info.go renamed to apis/delivery/v1alpha1/groupversion_info.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Copyright 2022.
21
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
32
//
43
// SPDX-License-Identifier: Apache-2.0

api/v1alpha1/sync_types.go renamed to apis/delivery/v1alpha1/sync_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Copyright 2022.
21
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
32
//
43
// SPDX-License-Identifier: Apache-2.0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
// Package v1alpha1 contains API Schema definitions for the mpas v1alpha1 API group
6+
// +kubebuilder:object:generate=true
7+
// +groupName=mpas.ocm.software
8+
package v1alpha1
9+
10+
import (
11+
"k8s.io/apimachinery/pkg/runtime/schema"
12+
"sigs.k8s.io/controller-runtime/pkg/scheme"
13+
)
14+
15+
var (
16+
// GroupVersion is group version used to register these objects
17+
GroupVersion = schema.GroupVersion{Group: "mpas.ocm.software", Version: "v1alpha1"}
18+
19+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
20+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
21+
22+
// AddToScheme adds the types in this group-version to the given scheme.
23+
AddToScheme = SchemeBuilder.AddToScheme
24+
)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package v1alpha1
6+
7+
import (
8+
"time"
9+
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
)
12+
13+
// SecretRef is a reference to a secret in the same namespace as the referencing object.
14+
type SecretRef struct {
15+
Name string `json:"name"`
16+
}
17+
18+
// Credentials contains ways of authenticating the creation of a repository.
19+
type Credentials struct {
20+
SecretRef SecretRef `json:"secretRef"`
21+
}
22+
23+
// RepositorySpec defines the desired state of Repository
24+
type RepositorySpec struct {
25+
Provider string `json:"provider"`
26+
Owner string `json:"owner"`
27+
Repository string `json:"repository"`
28+
Credentials Credentials `json:"credentials"`
29+
Interval metav1.Duration `json:"interval"`
30+
31+
//+optional
32+
Maintainers []string `json:"maintainers,omitempty"`
33+
//+optional
34+
//+kubebuilder:default=true;
35+
AutomaticPullRequestCreation bool `json:"automaticPullRequestCreation,omitempty"`
36+
}
37+
38+
// RepositoryStatus defines the observed state of Repository
39+
type RepositoryStatus struct {
40+
// ObservedGeneration is the last reconciled generation.
41+
// +optional
42+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
43+
44+
// +optional
45+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
46+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
47+
Conditions []metav1.Condition `json:"conditions,omitempty"`
48+
}
49+
50+
// GetConditions returns the conditions of the ComponentVersion.
51+
func (in *Repository) GetConditions() []metav1.Condition {
52+
return in.Status.Conditions
53+
}
54+
55+
// SetConditions sets the conditions of the ComponentVersion.
56+
func (in *Repository) SetConditions(conditions []metav1.Condition) {
57+
in.Status.Conditions = conditions
58+
}
59+
60+
// GetRequeueAfter returns the duration after which the ComponentVersion must be
61+
// reconciled again.
62+
func (in Repository) GetRequeueAfter() time.Duration {
63+
return in.Spec.Interval.Duration
64+
}
65+
66+
//+kubebuilder:object:root=true
67+
//+kubebuilder:subresource:status
68+
69+
// Repository is the Schema for the repositories API
70+
type Repository struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
74+
Spec RepositorySpec `json:"spec,omitempty"`
75+
Status RepositoryStatus `json:"status,omitempty"`
76+
}
77+
78+
//+kubebuilder:object:root=true
79+
80+
// RepositoryList contains a list of Repository
81+
type RepositoryList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata,omitempty"`
84+
Items []Repository `json:"items"`
85+
}
86+
87+
func init() {
88+
SchemeBuilder.Register(&Repository{}, &RepositoryList{})
89+
}

apis/mpas/v1alpha1/zz_generated.deepcopy.go

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)