Skip to content

Commit

Permalink
Implement git repository controller (#82)
Browse files Browse the repository at this point in the history
* add initial support for local and embdedded fs
* push manifests to gitea

Signed-off-by: Manabu Mccloskey <[email protected]>
  • Loading branch information
nabuskey authored Nov 24, 2023
1 parent 458852c commit ca8f132
Show file tree
Hide file tree
Showing 19 changed files with 1,417 additions and 71 deletions.
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"`
// 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
// +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"`
}

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

0 comments on commit ca8f132

Please sign in to comment.