-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This copies over the Build type definitions and generates clients for them. This incorporates BuildSpec into RevisionTemplate and BuildName into Revision. A RevisionTemplate with a BuildSpec will stamp out a Build during reconciliation, and feed the resulting BuildName to the Revision. The Revision will reflect the Build's progress in its Status, and stand up resources upon completion. Fixes: #7
- Loading branch information
Showing
55 changed files
with
2,986 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build --workspace_status_command=./print-workspace-status.sh | ||
run --workspace_status_command=./print-workspace-status.sh | ||
test --test_output=errors |
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
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,8 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["register.go"], | ||
importpath = "github.com/google/elafros/pkg/apis/cloudbuild", | ||
visibility = ["//visibility:public"], | ||
) |
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,21 @@ | ||
/* | ||
Copyright 2018 Google, Inc. All rights reserved. | ||
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. | ||
*/ | ||
|
||
package cloudbuild | ||
|
||
const ( | ||
GroupName = "cloudbuild.googleapis.com" | ||
) |
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,21 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"build_template_types.go", | ||
"build_types.go", | ||
"doc.go", | ||
"register.go", | ||
"zz_generated.deepcopy.go", | ||
], | ||
importpath = "github.com/google/elafros/pkg/apis/cloudbuild/v1alpha1", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/apis/cloudbuild:go_default_library", | ||
"//vendor/k8s.io/api/core/v1:go_default_library", | ||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", | ||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", | ||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", | ||
], | ||
) |
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,93 @@ | ||
/* | ||
Copyright 2018 Google, Inc. All rights reserved. | ||
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. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +genclient:noStatus | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type BuildTemplate struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec BuildTemplateSpec `json:"spec"` | ||
Status BuildTemplateStatus `json:"status"` | ||
} | ||
|
||
type BuildTemplateSpec struct { | ||
// Parameters defines the parameters that can be populated in a template. | ||
Parameters []ParameterSpec `json:"parameters,omitempty"` | ||
Steps []corev1.Container `json:"steps"` | ||
Volumes []corev1.Volume `json:"volumes"` | ||
} | ||
|
||
// BuildTemplateStatus is the status for a Build resource | ||
type BuildTemplateStatus struct { | ||
Conditions []BuildTemplateCondition `json:"conditions,omitempty"` | ||
} | ||
|
||
type BuildTemplateConditionType string | ||
|
||
const ( | ||
// BuildTemplateInvalid specifies that the given specification is invalid. | ||
BuildTemplateInvalid BuildTemplateConditionType = "Invalid" | ||
) | ||
|
||
// BuildTemplateCondition defines a readiness condition for a BuildTemplate. | ||
// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties | ||
type BuildTemplateCondition struct { | ||
Type BuildTemplateConditionType `json:"state"` | ||
|
||
Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` | ||
|
||
// +optional | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` | ||
|
||
// +optional | ||
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` | ||
// +optional | ||
Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` | ||
} | ||
|
||
// ParameterSpec defines the possible parameters that can be populated in a | ||
// template. | ||
type ParameterSpec struct { | ||
// Name is the unique name of this template parameter. | ||
Name string `json:"name"` | ||
|
||
// Description is a human-readable explanation of this template parameter. | ||
Description string `json:"description,omitempty"` | ||
|
||
// Default, if specified, defines the default value that should be applied if | ||
// the build does not specify the value for this parameter. | ||
Default string `json:"default,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// BuildTemplateList is a list of BuildTemplate resources | ||
type BuildTemplateList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
|
||
Items []BuildTemplate `json:"items"` | ||
} |
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,159 @@ | ||
/* | ||
Copyright 2018 Google, Inc. All rights reserved. | ||
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. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +genclient:noStatus | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Build is a specification for a Build resource | ||
type Build struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec BuildSpec `json:"spec"` | ||
Status BuildStatus `json:"status"` | ||
} | ||
|
||
// BuildSpec is the spec for a Build resource | ||
type BuildSpec struct { | ||
Source *SourceSpec `json:"source,omitempty"` | ||
Steps []corev1.Container `json:"steps,omitempty"` | ||
// TODO(mattmoor): Remove Images | ||
Images []string `json:"images,omitempty"` | ||
|
||
Volumes []corev1.Volume `json:"volumes,omitempty"` | ||
|
||
// Template, if specified,references a BuildTemplate resource to use to | ||
// populate fields in the build, and optional Arguments to pass to the | ||
// template. | ||
Template *TemplateInstantiationSpec `json:"template,omitempty"` | ||
} | ||
|
||
type TemplateInstantiationSpec struct { | ||
// Name references the BuildTemplate resource to use. | ||
Name string `json:"name"` | ||
|
||
// Namespace, if specified, is the namespace of the BuildTemplate resource to | ||
// use. If omitted, the build's namespace is used. | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// Arguments, if specified, lists values that should be applied to the | ||
// parameters specified by the template. | ||
Arguments []ArgumentSpec `json:"arguments,omitempty"` | ||
} | ||
|
||
// ArgumentSpec defines the actual values to use to populate a template's | ||
// parameters. | ||
type ArgumentSpec struct { | ||
Name string `json:"name"` | ||
Value string `json:"value"` | ||
// TODO(jasonhall): ValueFrom? | ||
} | ||
|
||
// SourceSpec defines the input to the Build | ||
type SourceSpec struct { | ||
Git *GitSourceSpec `json:"git,omitempty"` | ||
Custom *corev1.Container `json:"custom,omitempty"` | ||
} | ||
|
||
type GitSourceSpec struct { | ||
Url string `json:"url"` | ||
|
||
// One of these may be specified. | ||
Branch string `json:"branch,omitempty"` | ||
Tag string `json:"tag,omitempty"` | ||
Ref string `json:"ref,omitempty"` | ||
Commit string `json:"commit,omitempty"` | ||
|
||
// TODO(mattmoor): authn/z | ||
} | ||
|
||
type BuildProvider string | ||
|
||
const ( | ||
// GoogleBuildProvider indicates that this build was performed with Google Container Builder. | ||
GoogleBuildProvider BuildProvider = "Google" | ||
// ClusterBuildProvider indicates that this build was performed on-cluster. | ||
ClusterBuildProvider BuildProvider = "Cluster" | ||
) | ||
|
||
// BuildStatus is the status for a Build resource | ||
type BuildStatus struct { | ||
Builder BuildProvider `json:"builder,omitempty"` | ||
|
||
// Additional information based on the Builder executing this build. | ||
Cluster *ClusterSpec `json:"cluster,omitempty"` | ||
Google *GoogleSpec `json:"google,omitempty"` | ||
|
||
// Information about the execution of the build. | ||
StartTime metav1.Time `json:"startTime,omitEmpty"` | ||
CompletionTime metav1.Time `json:"completionTime,omitEmpty"` | ||
|
||
Conditions []BuildCondition `json:"conditions,omitempty"` | ||
} | ||
|
||
type ClusterSpec struct { | ||
Namespace string `json:"namespace"` | ||
JobName string `json:"jobName"` | ||
} | ||
|
||
type GoogleSpec struct { | ||
Operation string `json:"operation"` | ||
} | ||
|
||
type BuildConditionType string | ||
|
||
const ( | ||
// BuildComplete specifies that the build has completed successfully. | ||
BuildComplete BuildConditionType = "Complete" | ||
// BuildFailed specifies that the build has failed. | ||
BuildFailed BuildConditionType = "Failed" | ||
// BuildInvalid specifies that the given build specification is invalid. | ||
BuildInvalid BuildConditionType = "Invalid" | ||
) | ||
|
||
// BuildCondition defines a readiness condition for a Build. | ||
// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties | ||
type BuildCondition struct { | ||
Type BuildConditionType `json:"state"` | ||
|
||
Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` | ||
|
||
// +optional | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` | ||
|
||
// +optional | ||
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` | ||
// +optional | ||
Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// BuildList is a list of Build resources | ||
type BuildList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
|
||
Items []Build `json:"items"` | ||
} |
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,21 @@ | ||
/* | ||
Copyright 2018 Google, Inc. All rights reserved. | ||
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. | ||
*/ | ||
|
||
// +k8s:deepcopy-gen=package | ||
|
||
// Package v1alpha1 is the v1alpha1 version of the API. | ||
// +groupName=cloudbuild.googleapis.com | ||
package v1alpha1 |
Oops, something went wrong.