Skip to content
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

feat: add repository object #13

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY apis/ apis/
COPY controllers/ controllers/
COPY pkg/ pkg/

Expand Down
16 changes: 15 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: ocm.software
layout:
- go.kubebuilder.io/v3
multigroup: true
projectName: git-controller
repo: github.com/open-component-model/git-controller
resources:
Expand All @@ -11,6 +16,15 @@ resources:
domain: ocm.software
group: delivery
kind: Sync
path: github.com/open-component-model/git-controller/api/v1alpha1
path: github.com/open-component-model/git-controller/apis/delivery/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: ocm.software
group: mpas
kind: Repository
path: github.com/open-component-model/git-controller/apis/mpas/v1alpha1
version: v1alpha1
version: "3"
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local_resource(
"main.go",
"go.mod",
"go.sum",
"api",
"apis",
"controllers",
"pkg",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2022.
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2022.
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2022.
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
Expand Down
10 changes: 10 additions & 0 deletions apis/mpas/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

const (
// RepositoryCreateFailedReason is used when we fail to create a Repository.
RepositoryCreateFailedReason = "RepositoryCreateFailed"
)
24 changes: 24 additions & 0 deletions apis/mpas/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

// Package v1alpha1 contains API Schema definitions for the mpas v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=mpas.ocm.software
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "mpas.ocm.software", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
97 changes: 97 additions & 0 deletions apis/mpas/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
"time"

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

// SecretRef is a reference to a secret in the same namespace as the referencing object.
type SecretRef struct {
Name string `json:"name"`
}

// Credentials contains ways of authenticating the creation of a repository.
type Credentials struct {
SecretRef SecretRef `json:"secretRef"`
}

// RepositorySpec defines the desired state of Repository
type RepositorySpec struct {
Provider string `json:"provider"`
Owner string `json:"owner"`
RepositoryName string `json:"repositoryName"`
Credentials Credentials `json:"credentials"`
Skarlso marked this conversation as resolved.
Show resolved Hide resolved

//+optional
Interval metav1.Duration `json:"interval,omitempty"`
//+optional
//+kubebuilder:default:=internal
Skarlso marked this conversation as resolved.
Show resolved Hide resolved
Visibility string `json:"visibility,omitempty"`
//+kubebuilder:default:=true
IsOrganization bool `json:"isOrganization,omitempty"`
//+optional
Domain string `json:"domain,omitempty"`
//+optional
Maintainers []string `json:"maintainers,omitempty"`
//+optional
//+kubebuilder:default:=true
AutomaticPullRequestCreation bool `json:"automaticPullRequestCreation,omitempty"`
}

// RepositoryStatus defines the observed state of Repository
type RepositoryStatus struct {
// ObservedGeneration is the last reconciled generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// +optional
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// GetConditions returns the conditions of the ComponentVersion.
func (in *Repository) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the conditions of the ComponentVersion.
func (in *Repository) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetRequeueAfter returns the duration after which the ComponentVersion must be
// reconciled again.
func (in Repository) GetRequeueAfter() time.Duration {
return in.Spec.Interval.Duration
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Repository is the Schema for the repositories API
type Repository struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RepositorySpec `json:"spec,omitempty"`
Status RepositoryStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// RepositoryList contains a list of Repository
type RepositoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Repository `json:"items"`
}

func init() {
SchemeBuilder.Register(&Repository{}, &RepositoryList{})
}
149 changes: 149 additions & 0 deletions apis/mpas/v1alpha1/zz_generated.deepcopy.go

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

Loading