Skip to content

Commit

Permalink
Start building out shim layer for Tinkerbell
Browse files Browse the repository at this point in the history
  • Loading branch information
detiber committed Dec 10, 2020
1 parent 4f1e8b6 commit f6e867b
Show file tree
Hide file tree
Showing 11 changed files with 657 additions and 157 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ crds: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./controllers/... \
paths=./tink/api/... \
paths=./tink/controllers/... \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=./config/crd/bases \
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha3/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Copyright 2020 The Kubernetes Authors.
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 v1alpha3
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ go 1.15

require (
github.com/go-logr/logr v0.1.0
k8s.io/api v0.17.14
k8s.io/api v0.17.14
k8s.io/apimachinery v0.17.14
k8s.io/client-go v0.17.14
k8s.io/component-base v0.17.14
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/cluster-api v0.3.11
sigs.k8s.io/controller-runtime v0.5.11
)
154 changes: 1 addition & 153 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tink/api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Copyright 2020 The Kubernetes Authors.
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
33 changes: 33 additions & 0 deletions tink/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2020 The Kubernetes Authors.
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 contains API Schema definitions for the Tinkerbell v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=tinkerbell.org
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "tinkerbell.org", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
60 changes: 60 additions & 0 deletions tink/api/v1alpha1/hardware_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright 2020 The Kubernetes Authors.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// HardwareIDAnnotation is used by the controller to store the
// ID assigned to the workflow by Tinkerbell.
const HardwareIDAnnotation = "hardware.tinkerbell.org/id"

// HardwareSpec defines the desired state of Hardware.
type HardwareSpec struct {
}

// HardwareStatus defines the observed state of Hardware.
type HardwareStatus struct {
}

// +kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hardware,scope=Cluster,categories=tinkerbell
// +kubebuilder:storageversion

// Hardware is the Schema for the Hardware API.
type Hardware struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec HardwareSpec `json:"spec,omitempty"`
Status HardwareStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// HardwareList contains a list of Hardware.
type HardwareList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Hardware `json:"items"`
}

func init() {
SchemeBuilder.Register(&Hardware{}, &HardwareList{})
}
65 changes: 65 additions & 0 deletions tink/api/v1alpha1/template_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2020 The Kubernetes Authors.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// TemplateIDAnnotation is used by the controller to store the
// ID assigned to the workflow by Tinkerbell.
TemplateIDAnnotation = "template.tinkerbell.org/id"

TemplateFinalizer = "template.tinkerbell.org"
)

// TemplateSpec defines the desired state of Template.
type TemplateSpec struct {
Data string `json:"data,omitempty"`
}

// TemplateStatus defines the observed state of Template.
type TemplateStatus struct {
}

// +kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=templates,scope=Cluster,categories=tinkerbell
// +kubebuilder:storageversion

// Template is the Schema for the Templates API.
type Template struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TemplateSpec `json:"spec,omitempty"`
Status TemplateStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// TemplateList contains a list of Templates.
type TemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Template `json:"items"`
}

func init() {
SchemeBuilder.Register(&Template{}, &TemplateList{})
}
70 changes: 70 additions & 0 deletions tink/api/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2020 The Kubernetes Authors.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// WorkflowIDAnnotation is used by the controller to store the
// ID assigned to the workflow by Tinkerbell.
const WorkflowIDAnnotation = "workflow.tinkerbell.org/id"

// WorkflowSpec defines the desired state of Workflow.
type WorkflowSpec struct {
// Name of the Template associated with this Workflow.
Template string `json:"template,omitempty"`

// Name of the Hardware associated with this workflow.
Hardware string `json:"hardware,omitempty"`
}

// WorkflowStatus defines the observed state of Workflow.
type WorkflowStatus struct {
// State is the state of the workflow in Tinkerbell.
State string `json:"state,omitempty"`

// Data is the populated Workflow Data in Tinkerbell.
Data string `json:"data,omitempty"`
}

// +kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=workflows,scope=Cluster,categories=tinkerbell
// +kubebuilder:storageversion

// Workflow is the Schema for the Workflows API.
type Workflow struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec WorkflowSpec `json:"spec,omitempty"`
Status WorkflowStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// WorkflowList contains a list of Workflows.
type WorkflowList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Workflow `json:"items"`
}

func init() {
SchemeBuilder.Register(&Workflow{}, &WorkflowList{})
}
Loading

0 comments on commit f6e867b

Please sign in to comment.