Skip to content

Commit

Permalink
define
Browse files Browse the repository at this point in the history
define
  • Loading branch information
jiuker committed May 17, 2024
1 parent 7ae65b2 commit 272aae4
Show file tree
Hide file tree
Showing 7 changed files with 1,970 additions and 290 deletions.
893 changes: 893 additions & 0 deletions helm/operator/templates/job.min.io_jobs.yaml

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions pkg/apis/job.min.io/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,37 @@ type CommandSpec struct {
// DependsOn List of named `command` in this MinioJob that have to be scheduled and executed before this command runs
// +optional
DependsOn []string `json:"dependsOn,omitempty"`

// Compute Resources required by this container.
// Cannot be updated.
// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,8,opt,name=resources"`

// List of sources to populate environment variables in the container.
// The keys defined within a source must be a C_IDENTIFIER. All invalid keys
// will be reported as an event when the container is starting. When a key exists in multiple
// sources, the value associated with the last source will take precedence.
// Values defined by an Env with a duplicate key will take precedence.
// Cannot be updated.
// +optional
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
// List of environment variables to set in the container.
// Cannot be updated.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
Env []corev1.EnvVar `json:"env,omitempty"`

// Pod volumes to mount into the container's filesystem.
// Cannot be updated.
// +optional
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`

// List of volumes that can be mounted by containers belonging to the pod.
// More info: https://kubernetes.io/docs/concepts/storage/volumes
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// TenantRef Is the reference to the target tenant of the jobs
Expand Down
12 changes: 2 additions & 10 deletions pkg/controller/job-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,7 @@ func checkMinIOJob(jobCR *v1alpha1.MinIOJob) (intervalJob *miniojob.MinIOInterva
return intervalJob, fmt.Errorf("serviceaccount name is empty")
}
for index, val := range jobCR.Spec.Commands {
mcCommand, found := miniojob.OperationAliasToMC(val.Operation)
if !found {
return intervalJob, fmt.Errorf("operation %s is not supported", val.Operation)
}
argsFuncs, found := miniojob.JobOperation[mcCommand]
if !found {
return intervalJob, fmt.Errorf("operation %s is not supported", mcCommand)
}
jobCommand, err := miniojob.GenerateMinIOIntervalJobCommand(mcCommand, index, val.DependsOn, val.Name, val.Args, argsFuncs)
jobCommand, err := miniojob.GenerateMinIOIntervalJobCommand(val, index)
if err != nil {
return intervalJob, err
}
Expand All @@ -321,7 +313,7 @@ func checkMinIOJob(jobCR *v1alpha1.MinIOJob) (intervalJob *miniojob.MinIOInterva
}
// check all dependon
for _, command := range intervalJob.Command {
for _, dep := range command.DepnedsOn {
for _, dep := range command.CommandSpec.DependsOn {
_, found := intervalJob.CommandMap[dep]
if !found {
return intervalJob, fmt.Errorf("dependent job %s not found", dep)
Expand Down
58 changes: 1 addition & 57 deletions pkg/utils/miniojob/minioJob.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,9 @@ import (
"strings"
)

// ArgType - arg type
type ArgType int

const (
// ArgTypeKey - key=value print value
ArgTypeKey ArgType = iota
// ArgTypeFile - key=value print /temp/value.ext
ArgTypeFile
// ArgTypeKeyFile - key=value print key="/temp/value.ext"
ArgTypeKeyFile
)

// Arg - parse the arg result
type Arg struct {
Command string
FileName string
FileExt string
FileContext string
ArgType ArgType
Command string
}

// FieldsFunc - alias function
Expand Down Expand Up @@ -68,27 +52,6 @@ func Static(val string) FieldsFunc {
}
}

// File - fName is the the key, value is content, ext is the file ext
func File(fName string, ext string) FieldsFunc {
return func(args map[string]string) (out Arg, err error) {
if args == nil {
return out, fmt.Errorf("args is nil")
}
if val, ok := args[fName]; ok {
if val == "" {
return out, fmt.Errorf("value is empty")
}
out.FileName = fName
out.FileExt = ext
out.FileContext = strings.TrimSpace(val)
out.ArgType = ArgTypeFile
delete(args, fName)
return out, nil
}
return out, fmt.Errorf("file %s not found", fName)
}
}

// KeyValue - match key and putout the key, like endpoint="https://webhook-1.example.net"
func KeyValue(key string) FieldsFunc {
return func(args map[string]string) (out Arg, err error) {
Expand All @@ -105,25 +68,6 @@ func KeyValue(key string) FieldsFunc {
}
}

// KeyFile - match key and putout the key, like client_cert="[here is content]"
func KeyFile(key string, ext string) FieldsFunc {
return func(args map[string]string) (out Arg, err error) {
if args == nil {
return out, fmt.Errorf("args is nil")
}
val, ok := args[key]
if !ok {
return out, fmt.Errorf("key %s not found", key)
}
out.FileName = key
out.FileExt = ext
out.FileContext = strings.TrimSpace(val)
out.ArgType = ArgTypeKeyFile
delete(args, key)
return out, nil
}
}

// Option - ignore the error
func Option(opt FieldsFunc) FieldsFunc {
return func(args map[string]string) (out Arg, err error) {
Expand Down

0 comments on commit 272aae4

Please sign in to comment.