-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ArangoJob model * Update Makefile
- Loading branch information
Showing
26 changed files
with
1,290 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
package apps | ||
|
||
const ( | ||
ArangoJobCRDName = ArangoJobResourcePlural + "." + ArangoAppsGroupName | ||
ArangoJobResourceKind = "ArangoJob" | ||
ArangoJobResourcePlural = "arangojobs" | ||
|
||
ArangoAppsGroupName = "apps.arangodb.com" | ||
) | ||
|
||
var ( | ||
ArangoJobShortNames = []string{"arangojob"} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
// +k8s:deepcopy-gen=package | ||
// +groupName=apps.arangodb.com | ||
package v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
package v1 | ||
|
||
import ( | ||
"github.com/arangodb/kube-arangodb/pkg/apis/apps" | ||
|
||
batchv1 "k8s.io/api/batch/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ArangoJobList is a list of ArangoDB jobs. | ||
type ArangoJobList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
|
||
Items []ArangoJob `json:"items"` | ||
} | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ArangoJob contains definition and status of the ArangoDB type Job. | ||
type ArangoJob struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec ArangoJobSpec `json:"spec,omitempty"` | ||
Status batchv1.JobStatus `json:"status,omitempty"` | ||
} | ||
|
||
// AsOwner creates an OwnerReference for the given job | ||
func (a *ArangoJob) AsOwner() metav1.OwnerReference { | ||
trueVar := true | ||
return metav1.OwnerReference{ | ||
APIVersion: SchemeGroupVersion.String(), | ||
Kind: apps.ArangoJobResourceKind, | ||
Name: a.Name, | ||
UID: a.UID, | ||
Controller: &trueVar, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
package v1 | ||
|
||
import batchv1 "k8s.io/api/batch/v1" | ||
|
||
type ArangoJobSpec struct { | ||
ArangoDeploymentName string `json:"arangoDeploymentName"` | ||
JobTemplate *batchv1.JobSpec `json:"jobTemplate,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
package v1 | ||
|
||
import "github.com/arangodb/kube-arangodb/pkg/util/errors" | ||
|
||
func (a *ArangoJob) Validate() error { | ||
if err := a.Spec.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (a *ArangoJobSpec) Validate() error { | ||
if a.ArangoDeploymentName == "" { | ||
return errors.Newf("deployment name can not be empty") | ||
} | ||
|
||
if a.JobTemplate == nil { | ||
return errors.Newf("jobTemplate name can not be empty") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Jakub Wierzbowski | ||
// | ||
|
||
package v1 | ||
|
||
import ( | ||
"github.com/arangodb/kube-arangodb/pkg/apis/apps" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const ( | ||
ArangoAppsVersion = "v1" | ||
) | ||
|
||
var ( | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
|
||
SchemeGroupVersion = schema.GroupVersion{Group: apps.ArangoAppsGroupName, Version: ArangoAppsVersion} | ||
) | ||
|
||
// Resource gets an ArangoCluster GroupResource for a specified resource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
// addKnownTypes adds the set of types defined in this package to the supplied scheme. | ||
func addKnownTypes(s *runtime.Scheme) error { | ||
s.AddKnownTypes(SchemeGroupVersion, | ||
&ArangoJob{}, | ||
&ArangoJobList{}, | ||
) | ||
metav1.AddToGroupVersion(s, SchemeGroupVersion) | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.