mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
MLCronJob embedded fields (#1520)
Co-authored-by: Nikita Vaniasin <nikita.vanyasin@gmail.com>
This commit is contained in:
parent
2b063dc1f9
commit
d74e1db063
7 changed files with 2966 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -797,7 +797,7 @@ check-community:
|
|||
_check: sync-crds
|
||||
@$(MAKE) fmt yamlfmt license-verify linter run-unit-tests bin vulncheck-optional
|
||||
|
||||
generate: generate-internal generate-proto fmt
|
||||
generate: generate-internal generate-proto fmt yamlfmt
|
||||
|
||||
generate-internal:
|
||||
ROOT=$(ROOT) go test --count=1 "$(REPOPATH)/internal/..."
|
||||
|
|
|
@ -2,11 +2,27 @@
|
|||
|
||||
## Spec
|
||||
|
||||
### .spec
|
||||
|
||||
Type: `batch.CronJobSpec` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_spec.go#L32)</sup>
|
||||
|
||||
Links:
|
||||
* [Kubernetes Documentation](https://godoc.org/k8s.io/api/batch/v1beta1#CronJobSpec)
|
||||
|
||||
## Status
|
||||
|
||||
### .status
|
||||
|
||||
Type: `batch.CronJobStatus` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L36)</sup>
|
||||
|
||||
Links:
|
||||
* [Kubernetes Documentation](https://godoc.org/k8s.io/api/batch/v1beta1#CronJobStatus)
|
||||
|
||||
***
|
||||
|
||||
### .status.conditions
|
||||
|
||||
Type: `api.Conditions` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L28)</sup>
|
||||
Type: `api.Conditions` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L32)</sup>
|
||||
|
||||
Conditions specific to the entire cron job
|
||||
|
||||
|
|
|
@ -184,6 +184,20 @@ func iterateOverObjectDirect(t *testing.T, fields map[string]*ast.Field, name st
|
|||
}
|
||||
}
|
||||
|
||||
// inline and anonymous field (embedded)
|
||||
if inline && n == "" {
|
||||
if doc != nil {
|
||||
if t, ok := extractType(doc); ok {
|
||||
info := typeInfo{
|
||||
path: fmt.Sprintf("%s.%s", path, name),
|
||||
typ: t[0],
|
||||
}
|
||||
r[info] = doc
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if inline {
|
||||
for k, v := range iterateOverObjectDirect(t, fields, name, f.Type, path) {
|
||||
if v == nil {
|
||||
|
@ -301,9 +315,32 @@ func parseSourceFiles(t *testing.T, root string, fset *token.FileSet, path strin
|
|||
if nt != nil {
|
||||
require.NotEmpty(t, nt.Name)
|
||||
|
||||
for _, name := range x.Names {
|
||||
r[fmt.Sprintf("%s.%s.%s", k, nt.Name, name)] = x
|
||||
if len(x.Names) > 0 {
|
||||
for _, name := range x.Names {
|
||||
r[fmt.Sprintf("%s.%s.%s", k, nt.Name, name)] = x
|
||||
}
|
||||
} else {
|
||||
// If x.Names is empty, it's an anonymous field
|
||||
if len(x.Names) == 0 {
|
||||
// first check if it's a pointer to a struct
|
||||
typeName, ok := x.Type.(*ast.StarExpr)
|
||||
if ok {
|
||||
ident, ok := typeName.X.(*ast.SelectorExpr)
|
||||
if ok {
|
||||
fieldName := ident.Sel.Name
|
||||
r[fmt.Sprintf("%s.%s.%s", k, nt.Name, fieldName)] = x
|
||||
}
|
||||
} else {
|
||||
// if it's not a pointer
|
||||
ident, ok := x.Type.(*ast.SelectorExpr)
|
||||
if ok {
|
||||
fieldName := ident.Sel.Name
|
||||
r[fmt.Sprintf("%s.%s.%s", k, nt.Name, fieldName)] = x
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,16 @@
|
|||
|
||||
package v1alpha1
|
||||
|
||||
import "github.com/arangodb/kube-arangodb/pkg/apis/shared"
|
||||
import (
|
||||
batchApi "k8s.io/api/batch/v1beta1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
|
||||
)
|
||||
|
||||
type ArangoMLCronJobSpec struct {
|
||||
// +doc/type: batch.CronJobSpec
|
||||
// +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1beta1#CronJobSpec
|
||||
*batchApi.CronJobSpec `json:",inline"`
|
||||
}
|
||||
|
||||
func (a *ArangoMLCronJobSpec) Validate() error {
|
||||
|
|
|
@ -20,10 +20,18 @@
|
|||
|
||||
package v1alpha1
|
||||
|
||||
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
import (
|
||||
batchApi "k8s.io/api/batch/v1beta1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
)
|
||||
|
||||
type ArangoMLCronJobStatus struct {
|
||||
// Conditions specific to the entire cron job
|
||||
// +doc/type: api.Conditions
|
||||
Conditions api.ConditionList `json:"conditions,omitempty"`
|
||||
|
||||
// +doc/type: batch.CronJobStatus
|
||||
// +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1beta1#CronJobStatus
|
||||
batchApi.CronJobStatus `json:",inline"`
|
||||
}
|
||||
|
|
9
pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go
generated
9
pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go
generated
|
@ -28,6 +28,7 @@ package v1alpha1
|
|||
import (
|
||||
v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
sharedv1 "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
|
||||
v1beta1 "k8s.io/api/batch/v1beta1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -136,7 +137,7 @@ func (in *ArangoMLCronJob) DeepCopyInto(out *ArangoMLCronJob) {
|
|||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
@ -195,6 +196,11 @@ func (in *ArangoMLCronJobList) DeepCopyObject() runtime.Object {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ArangoMLCronJobSpec) DeepCopyInto(out *ArangoMLCronJobSpec) {
|
||||
*out = *in
|
||||
if in.CronJobSpec != nil {
|
||||
in, out := &in.CronJobSpec, &out.CronJobSpec
|
||||
*out = new(v1beta1.CronJobSpec)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -218,6 +224,7 @@ func (in *ArangoMLCronJobStatus) DeepCopyInto(out *ArangoMLCronJobStatus) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
in.CronJobStatus.DeepCopyInto(&out.CronJobStatus)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue