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

Implement git repository controller #82

Merged
merged 4 commits into from
Nov 24, 2023
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
75 changes: 75 additions & 0 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package v1alpha1

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

type GitRepositorySpec struct {
Source GitRepositorySource `json:"source,omitempty"`
nabuskey marked this conversation as resolved.
Show resolved Hide resolved
// GitURL is the base URL of Git server used for API calls.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^https?:\/\/.+$`
GitURL string `json:"gitURL"`
// SecretRef is the reference to secret that contain Git server credentials
// +kubebuilder:validation:Optional
SecretRef SecretReference `json:"secretRef"`
}

type GitRepositorySource struct {
// +kubebuilder:validation:Enum:=argocd;backstage;crossplane;gitea;nginx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crossplane should be removed from the enum and we should keep what currently we support or point to a link = doc page enumerating them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will probably have to keep it since the reference implementation uses it. For now, I am keeping it because the purpose of this PR is to move the git functionality over from embedded git server to gitea.

// +kubebuilder:validation:Optional
EmbeddedAppName string `json:"embeddedAppName"`
// Path is the absolute path to directory that contains Kustomize structure or raw manifests.
// This is required when Type is set to local.
// +kubebuilder:validation:Optional
Path string `json:"path"`
// Type is the source type.
// +kubebuilder:validation:Enum:=local;embedded
// +kubebuilder:default:=embedded
Type string `json:"type"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe what is the purpose of the type and what will happen if we select one the values: local, embedded, etc ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local indicates the gitea repository contents will come from a local directory. E.g. /home/ubuntu/myrepo

Embedded indicates the repository contents will come from what is embedded in the go binary.

}

type SecretReference struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
}

type Commit struct {
// Hash is the digest of the most recent commit
// +kubebuilder:validation:Optional
Hash string `json:"hash"`
}

type GitRepositoryStatus struct {
// LatestCommit is the most recent commit known to the controller
// +kubebuilder:validation:Optional
LatestCommit Commit `json:"commit"`
// ExternalGitRepositoryUrl is the url for the in-cluster repository accessible from local machine.
// +kubebuilder:validation:Optional
ExternalGitRepositoryUrl string `json:"externalGitRepositoryUrl"`
// InternalGitRepositoryUrl is the url for the in-cluster repository accessible within the cluster.
// +kubebuilder:validation:Optional
InternalGitRepositoryUrl string `json:"internalGitRepositoryUrl"`
// Path is the path within the repository that contains the files.
// +kubebuilder:validation:Optional
Path string `json:"path"`

Synced bool `json:"synced"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type GitRepository struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GitRepositorySpec `json:"spec,omitempty"`
Status GitRepositoryStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type GitRepositoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GitRepository `json:"items"`
}
1 change: 1 addition & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ var (
func init() {
SchemeBuilder.Register(&Localbuild{}, &LocalbuildList{})
SchemeBuilder.Register(&GitServer{}, &GitServerList{})
SchemeBuilder.Register(&GitRepository{}, &GitRepositoryList{})
}
29 changes: 21 additions & 8 deletions api/v1alpha1/localbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,27 @@ type LocalbuildSpec struct {
type LocalbuildStatus struct {
// ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

GitServerAvailable bool `json:"gitServerAvailable,omitempty"`
ArgoAvailable bool `json:"argoAvailable,omitempty"`
NginxAvailable bool `json:"nginxAvailable,omitempty"`
GiteaAvailable bool `json:"giteaAvailable,omitempty"`
ArgoAppsCreated bool `json:"argoAppsCreated,omitempty"`
GiteaSecretName string `json:"giteaSecret,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
ArgoCD ArgoCDStatus `json:"ArgoCD,omitempty"`
Nginx NginxStatus `json:"nginx,omitempty"`
Gitea GiteaStatus `json:"gitea,omitempty"`
}

type GiteaStatus struct {
Available bool `json:"available,omitempty"`
ExternalURL string `json:"externalURL,omitempty"`
InternalURL string `json:"internalURL,omitempty"`
AdminUserSecretName string `json:"adminUserSecretNameecret,omitempty"`
AdminUserSecretNamespace string `json:"adminUserSecretNamespace,omitempty"`
}

type ArgoCDStatus struct {
Available bool `json:"available,omitempty"`
AppsCreated bool `json:"appsCreated,omitempty"`
}

type NginxStatus struct {
Available bool `json:"available,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
185 changes: 185 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading