forked from kform-dev/kform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
2,461 additions
and
913 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 |
---|---|---|
|
@@ -6,9 +6,7 @@ | |
*.dylib | ||
bin | ||
vendor | ||
config | ||
build | ||
*.kformpkg | ||
.kform | ||
test | ||
|
||
|
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,92 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"reflect" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type ConfigSpec struct { | ||
// The hostname (in form of URI) of Kubernetes master. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
Host *string `json:"host,omitempty" yaml:"host,omitempty"` | ||
|
||
// The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
Username *string `json:"username,omitempty" yaml:"username,omitempty"` | ||
|
||
// The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint. | ||
// The hostname (in form of URI) of Kubernetes master. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
Password *string `json:"password,omitempty" yaml:"password,omitempty"` | ||
|
||
// Insecure determines whether the server should be accessible without verifying the TLS certificate | ||
// +kubebuilder:default=false | ||
Insecure *bool `json:"insecure,omitempty" yaml:"insecure,omitempty"` | ||
|
||
// Server name passed to the server for SNI and is used in the client to check server certificates against | ||
// example: Some name | ||
TLSServerName *string `json:"tlsServerName,omitempty" yaml:"tlsServerName,omitempty"` | ||
|
||
// PEM-encoded client certificate for TLS authentication. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ClientCertificate *string `json:"clientCertificate,omitempty" yaml:"clientCertificate,omitempty"` | ||
|
||
// PEM-encoded client certificate key for TLS authentication. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ClientKey *string `json:"clientKey,omitempty" yaml:"clientKey,omitempty"` | ||
|
||
// PEM-encoded root certificates bundle for TLS authentication. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ClusterCACertificate *string `json:"clusterCACertificate,omitempty" yaml:"clusterCACertificate,omitempty"` | ||
|
||
// ConfigPaths defines a list of paths to kube config files. | ||
ConfigPaths []string `json:"configPaths,omitempty" yaml:"configPaths,omitempty"` | ||
|
||
// ConfigPath defines the path to the kube config file. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
// +kubebuilder:default="~/.kube/config" | ||
ConfigPath *string `json:"configPath,omitempty" yaml:"configPath,omitempty"` | ||
|
||
// ConfigContext defines the context to be used in the kube config file. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ConfigContext *string `json:"configContext,omitempty" yaml:"configContext,omitempty"` | ||
|
||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ConfigContextAuthInfo *string `json:"configContextAuthInfo,omitempty" yaml:"configContextAuthInfo,omitempty"` | ||
|
||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ConfigContextCluster *string `json:"configContextCluster,omitempty" yaml:"configContextCluster,omitempty"` | ||
|
||
// Token to authenticate a service account. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
Token *string `json:"token,omitempty" yaml:"token,omitempty"` | ||
|
||
// ProxyURL defines the URL of the proxy to be used for all API requests | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=64 | ||
ProxyURL *string `json:"proxyURL,omitempty" yaml:"proxyURL,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
type Config struct { | ||
metav1.TypeMeta `json:",inline" yaml:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` | ||
|
||
Spec ConfigSpec `json:"spec,omitempty" yaml:"spec,omitempty"` | ||
} | ||
|
||
var ( | ||
ConfigKind = reflect.TypeOf(Config{}).Name() | ||
) |
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,9 @@ | ||
// +kubebuilder:object:generate=true | ||
// +groupName=backend.kform.io | ||
package v1alpha1 | ||
|
||
const ( | ||
Group = "backend.kform.io" | ||
Version = "v1alpha1" | ||
APIVersion = Group + "/" + Version | ||
) |
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,13 @@ | ||
package core | ||
|
||
import ( | ||
rbacv1 "k8s.io/api/rbac/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
var RBACGroupKind = map[schema.GroupKind]bool{ | ||
{Group: rbacv1.GroupName, Kind: "Role"}: true, | ||
{Group: rbacv1.GroupName, Kind: "ClusterRole"}: true, | ||
{Group: rbacv1.GroupName, Kind: "RoleBinding"}: true, | ||
{Group: rbacv1.GroupName, Kind: "ClusterRoleBinding"}: true, | ||
} |
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,9 @@ | ||
package core | ||
|
||
import "k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
var ConfigMapGVK = schema.GroupVersionKind{ | ||
Group: "", | ||
Kind: "ConfigMap", | ||
Version: "v1", | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
kformv1alpha1 "github.com/kform-dev/kform/apis/pkg/v1alpha1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/kustomize/kyaml/yaml" | ||
) | ||
|
||
func (r Object) GetRnNode(blockType, resourceType, resourceID string) *yaml.RNode { | ||
rn := yaml.MakeNullNode() | ||
rn.SetApiVersion(schema.GroupVersion{Group: r.ObjectRef.Group, Version: r.ObjectRef.Version}.String()) | ||
rn.SetKind(r.ObjectRef.Kind) | ||
rn.SetName(r.ObjectRef.Name) | ||
rn.SetNamespace(r.ObjectRef.Namespace) | ||
annotations := map[string]string{} | ||
annotations[kformv1alpha1.KformAnnotationKey_BLOCK_TYPE] = kformv1alpha1.BlockTYPE_DATA.String() | ||
annotations[kformv1alpha1.KformAnnotationKey_RESOURCE_TYPE] = resourceType | ||
annotations[kformv1alpha1.KformAnnotationKey_RESOURCE_ID] = resourceID | ||
rn.SetAnnotations(annotations) | ||
return rn | ||
} |
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,115 @@ | ||
package v1alpha1 | ||
|
||
/* | ||
data: | ||
providers: | ||
kubernetes: | ||
config: | ||
apiVersion: kubernetes.provider.kform.io/v1alpha1 | ||
kind: ProviderConfig | ||
metadata: | ||
name: kubernetes | ||
namespace: default | ||
annotations: | ||
kform.dev/block-type: provider | ||
spec: | ||
configPath: "~/.kube/config" | ||
packages: | ||
root: | ||
kubernetes_manifest.bla: | ||
resources: | ||
- ref: | ||
group | ||
kind | ||
namespace | ||
name | ||
status: | ||
strategy: | ||
actuation: | ||
reconcile: | ||
*/ | ||
|
||
// Non Goal: expose execution context | ||
// Goal | ||
// Expose the cluster resources that were applied to the system | ||
// -> per provider track resources | ||
|
||
type Inventory struct { | ||
Providers map[string]string `json:"providers,omitempty" yaml:"providers,omitempty"` | ||
Packages map[string]*PackageInventory `json:"packages,omitempty" yaml:"packages,omitempty"` | ||
} | ||
|
||
type PackageInventory struct { | ||
PackageResources map[string][]Object `json:",inline" yaml:",inline"` | ||
} | ||
|
||
type Object struct { | ||
ObjectRef ObjectReference `json:"objectRef,omitempty" yaml:"objectRef,omitempty"` | ||
// Strategy indicates the method of actuation (apply or delete) used or planned to be used. | ||
Strategy ActuationStrategy `json:"strategy,omitempty" yaml:"strategy,omitempty"` | ||
// Actuation indicates whether actuation has been performed yet and how it went. | ||
Actuation ActuationStatus `json:"actuation,omitempty" yaml:"actuation,omitempty"` | ||
// Reconcile indicates whether reconciliation has been performed yet and how it went. | ||
Reconcile ReconcileStatus `json:"reconcile,omitempty" yaml:"reconcile,omitempty"` | ||
} | ||
|
||
// ObjectReference is a reference to a KRM resource by name and kind. | ||
// | ||
// Kubernetes only stores one API Version for each Kind at any given time, | ||
// so version is not used when referencing objects. | ||
type ObjectReference struct { | ||
// Group identifies an API namespace for REST resources. | ||
// If group is omitted, it is treated as the "core" group. | ||
// More info: https://kubernetes.io/docs/reference/using-api/#api-groups | ||
// +optional | ||
Group string `json:"group,omitempty" yaml:"group,omitempty"` | ||
|
||
// Version identifies an API Version for REST resources. | ||
Version string `json:"version,omitempty" version:"group,omitempty"` | ||
|
||
// Kind identifies a REST resource within a Group. | ||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` | ||
|
||
// Name identifies an object instance of a REST resource. | ||
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names | ||
Name string `json:"name,omitempty" yaml:"name,omitempty"` | ||
|
||
// Namespace identifies a group of objects across REST resources. | ||
// If namespace is specified, the resource must be namespace-scoped. | ||
// If namespace is omitted, the resource must be cluster-scoped. | ||
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ | ||
// +optional | ||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` | ||
} | ||
|
||
//nolint:revive // consistent prefix improves tab-completion for enums | ||
//go:generate stringer -type=ActuationStrategy -linecomment | ||
type ActuationStrategy int | ||
|
||
const ( | ||
ActuationStrategyApply ActuationStrategy = iota // Apply | ||
ActuationStrategyDelete // Delete | ||
) | ||
|
||
//nolint:revive // consistent prefix improves tab-completion for enums | ||
//go:generate stringer -type=ActuationStatus -linecomment | ||
type ActuationStatus int | ||
|
||
const ( | ||
ActuationPending ActuationStatus = iota // Pending | ||
ActuationSucceeded // Succeeded | ||
ActuationSkipped // Skipped | ||
ActuationFailed // Failed | ||
) | ||
|
||
//go:generate stringer -type=ReconcileStatus -linecomment | ||
type ReconcileStatus int | ||
|
||
const ( | ||
ReconcilePending ReconcileStatus = iota // Pending | ||
ReconcileSucceeded // Succeeded | ||
ReconcileSkipped // Skipped | ||
ReconcileFailed // Failed | ||
ReconcileTimeout // Timeout | ||
) |
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,26 @@ | ||
package v1alpha1 | ||
|
||
const ( | ||
// InventoryLabelKey is the label stored on the ConfigMap | ||
// inventory object. The value of the label is a unique | ||
// identifier (by default a UUID), representing the set of | ||
// objects applied at the same time as the inventory object. | ||
// This inventory object is used for pruning and deletion. | ||
InventoryLabelKey = "inv.kform.dev/inventory-id" | ||
|
||
// InventoryOwnerKey is the annotation key indicating the inventory owning an object. | ||
InventoryOwnerKey = "inv.kform.dev/inventory-owner" | ||
|
||
// LifecycleDeletionAnnotation is the lifecycle annotation key for deletion operation. | ||
//LifecycleDeleteAnnotation = "client.lifecycle.config.k8s.io/deletion" | ||
|
||
// PreventDeletion is the value used with LifecycleDeletionAnnotation | ||
// to prevent deleting a resource. | ||
//PreventDeletion = "detach" | ||
|
||
//OnRemoveAnnotation = "cli-utils.sigs.k8s.io/on-remove" | ||
// Resource lifecycle annotation value to prevent deletion. | ||
|
||
// Resource lifecycle annotation value to prevent deletion. | ||
//OnRemoveKeep = "keep" | ||
) |
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.