Skip to content

Commit

Permalink
custom package root type
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu Mccloskey <[email protected]>
  • Loading branch information
nabuskey committed Dec 7, 2023
1 parent e81f85c commit 9f83544
Show file tree
Hide file tree
Showing 15 changed files with 692 additions and 332 deletions.
44 changes: 44 additions & 0 deletions api/v1alpha1/custom_package_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package v1alpha1

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

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

Spec CustomPackageSpec `json:"spec,omitempty"`
Status CustomPackageStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type CustomPackageList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CustomPackage `json:"items"`
}

// CustomPackageSpec controls the installation of the custom applications.
type CustomPackageSpec struct {
//// Type specifies what kind of package this is. local means local files specified in the Directory field must be synced to a Git Repository
//Type string `json:"type"`
// Replicate specifies whether to replicate remote or local contents to the local gitea server.
Replicate bool `json:"replicate"`
// GitServerURL specifies the base URL for the git server for API calls. for example, http://gitea.cnoe.localtest.me:8880
GitServerURL string `json:"gitServerURL"`
GitServerAuthSecretRef SecretReference `json:"gitServerAuthSecretRef"`

ArgoCD ArgoCDPackageSpec `json:"argoCD,omitempty"`
}

type ArgoCDPackageSpec struct {
// ApplicationFile specifies the absolute path to the ArgoCD application file
ApplicationFile string `json:"applicationFile"`
Name string `json:"name"`
Namespace string `json:"namespace"`
}

type CustomPackageStatus struct {
Synced bool `json:"synced,omitempty"`
}
2 changes: 2 additions & 0 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type GitRepositorySpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^https?:\/\/.+$`
GitURL string `json:"gitURL"`
// InternalGitURL is the base URL of Git server accessible within the cluster only.
InternalGitURL string `json:"internalGitURL"`
// SecretRef is the reference to secret that contain Git server credentials
// +kubebuilder:validation:Optional
SecretRef SecretReference `json:"secretRef"`
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ func init() {
SchemeBuilder.Register(&Localbuild{}, &LocalbuildList{})
SchemeBuilder.Register(&GitServer{}, &GitServerList{})
SchemeBuilder.Register(&GitRepository{}, &GitRepositoryList{})
SchemeBuilder.Register(&CustomPackage{}, &CustomPackageList{})
}
8 changes: 1 addition & 7 deletions api/v1alpha1/localbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ type PackageConfigsSpec struct {
GitConfig GitConfigSpec `json:"gitConfig,omitempty"`
Argo ArgoPackageConfigSpec `json:"argoPackageConfigs,omitempty"`
EmbeddedArgoApplications EmbeddedArgoApplicationsPackageConfigSpec `json:"embeddedArgoApplicationsPackageConfigs,omitempty"`
CustomPackages []CustomPackageSpec `json:"customPackages,omitempty"`
}

// CustomPackageSpec controls the installation of the custom argocd applications.
type CustomPackageSpec struct {
// Directory specifies the absolute path to the directory which contains ArgoCD Application manifests
Directory string `json:"directory,omitempty"`
CustomPackageDirs []string `json:"customPackageDirs"`
}

type LocalbuildSpec struct {
Expand Down
97 changes: 94 additions & 3 deletions api/v1alpha1/zz_generated.deepcopy.go

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

13 changes: 1 addition & 12 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error {
},
}

pkgs, err := getPackages(b.customPackageDirs)

setupLog.Info("Creating localbuild resource")
_, err = controllerutil.CreateOrUpdate(ctx, kubeClient, &localBuild, func() error {
localBuild.Spec = v1alpha1.LocalbuildSpec{
Expand All @@ -162,7 +160,7 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error {
// hint: for the old behavior, replace Type value below with globals.GitServerResourcename()
Type: globals.GiteaResourceName(),
},
CustomPackages: pkgs,
CustomPackageDirs: b.customPackageDirs,
},
}
return nil
Expand All @@ -180,12 +178,3 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error {
close(managerExit)
return err
}

func getPackages(srcDirs []string) ([]v1alpha1.CustomPackageSpec, error) {
out := make([]v1alpha1.CustomPackageSpec, len(srcDirs), len(srcDirs))
for i := range srcDirs {
out[i] = v1alpha1.CustomPackageSpec{Directory: srcDirs[i]}
}

return out, nil
}
Loading

0 comments on commit 9f83544

Please sign in to comment.