-
Notifications
You must be signed in to change notification settings - Fork 63
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
Allow for custom packages #100
Changes from 5 commits
e81f85c
9f83544
9054d09
23dd352
1aa1601
73b7fe8
43d4b79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 { | ||
// 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"` | ||
// InternalGitServeURL specifies the base URL for the git server accessible within the cluster. | ||
// for example, http://my-gitea-http.gitea.svc.cluster.local:3000 | ||
InternalGitServeURL string `json:"internalGitServeURL"` | ||
GitServerAuthSecretRef SecretReference `json:"gitServerAuthSecretRef"` | ||
|
||
ArgoCD ArgoCDPackageSpec `json:"argoCD,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
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"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should it contain the git repo for where the spec is pushed and tracked? particularly if it is in gitea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ var ( | |
kubeVersion string | ||
extraPortsMapping string | ||
kindConfigPath string | ||
extraPackagesDirs []string | ||
) | ||
|
||
var CreateCmd = &cobra.Command{ | ||
|
@@ -38,6 +39,7 @@ func init() { | |
CreateCmd.PersistentFlags().StringVar(&kubeVersion, "kubeVersion", "v1.26.3", "Version of the kind kubernetes cluster to create.") | ||
CreateCmd.PersistentFlags().StringVar(&extraPortsMapping, "extraPorts", "", "List of extra ports to expose on the docker container and kubernetes cluster as nodePort (e.g. \"22:32222,9090:39090,etc\").") | ||
CreateCmd.PersistentFlags().StringVar(&kindConfigPath, "kindConfig", "", "Path of the kind config file to be used instead of the default.") | ||
CreateCmd.Flags().StringSliceVarP(&extraPackagesDirs, "package-dir", "p", []string{}, "paths to custom packages") | ||
|
||
zapfs := flag.NewFlagSet("zap", flag.ExitOnError) | ||
opts := zap.Options{ | ||
|
@@ -60,10 +62,40 @@ func create(cmd *cobra.Command, args []string) error { | |
os.Exit(1) | ||
} | ||
|
||
b := build.NewBuild(buildName, kubeVersion, kubeConfigPath, kindConfigPath, extraPortsMapping, k8s.GetScheme(), ctxCancel) | ||
var absPaths []string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a more descriptive name? |
||
if len(extraPackagesDirs) > 0 { | ||
p, err := getPackageAbsDirs(extraPackagesDirs) | ||
if err != nil { | ||
return err | ||
} | ||
absPaths = p | ||
} | ||
|
||
b := build.NewBuild(buildName, kubeVersion, kubeConfigPath, kindConfigPath, extraPortsMapping, absPaths, k8s.GetScheme(), ctxCancel) | ||
|
||
if err := b.Run(ctx, recreateCluster); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func getPackageAbsDirs(paths []string) ([]string, error) { | ||
out := make([]string, len(paths), len(paths)) | ||
for i := range paths { | ||
path := paths[i] | ||
absPath, err := filepath.Abs(path) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to validate path %s : %w", path, err) | ||
} | ||
f, err := os.Stat(absPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to validate path %s : %w", absPath, err) | ||
} | ||
if !f.IsDir() { | ||
return nil, fmt.Errorf("given path is not a directory. %s", absPath) | ||
} | ||
out[i] = absPath | ||
} | ||
|
||
return out, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be defaulted to something, no? I assume it is probably a
no
by default?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it defaults to false via zero value. I'll add an annotation to be explicit.