codify

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

Codify

This is the naml feature that will convert YAML to Go.

Adding an implementation

Each implementation will require special attention to detail.

The boilerplate is straightforward however there are some special considerations.

This is the alias method that will handle the weird Kubernetes import alias mechanism.

alias(generated, default string)

The main problem is that all objects will render as v1 instead of their corresponding alias such as corev1 or metav1. This method will do it's best to figure these out (without using reflection). There are members in the top of codify.go that call out the well-known subobjects that cannot be defaulted.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KubernetesImportPackageMap = map[string]string{
		"k8s.io/api/apps/v1":                                       "appsv1",
		"k8s.io/api/batch/v1":                                      "batchv1",
		"k8s.io/api/core/v1":                                       "corev1",
		"k8s.io/apimachinery/pkg/apis/meta/v1":                     "metav1",
		"k8s.io/api/rbac/v1":                                       "rbacv1",
		"k8s.io/api/networking/v1":                                 "networkingv1",
		"k8s.io/api/admissionregistration/v1":                      "admissionregistrationv1",
		"k8s.io/api/policy/v1beta1":                                "policyv1beta1",
		"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1": "apiextensionsv1",
	}

	PolicyV1Types = []string{
		"PolicyV1Interface",
	}

	AppsV1Types = []string{""}

	MetaV1Types = []string{
		"APIGroup",
		"ObjectMeta",
		"Time",
		"TypeMeta",
		"ManagedFieldsEntry",
		"OwnerReference",
		"CreateOptions",
		"DeleteOptions",
		"LabelSelector",
	}

	CoreV1Types = []string{
		"WeightedPodAffinityTerm",
		"TCPSocketAction",
		"Volume",
		"SecretEnvSource",
		"SecretKeySelector",
		"SecretProjection",
		"ConfigMapKeySelector",
		"ConfigMapProjection",
		"ConfigMapEnvSource",
		"HTTPHeader",
		"PodAntiAffinity",
		"PodAffinityTerm",
		"KeyToPath",
		"SecretVolumeSource",
		"EmptyDirVolumeSource",
		"Handler",
		"TaintEffect",
		"HTTPGetAction",
		"URIScheme",
		"PodTemplateSpec",
		"PodSpec",
		"Protocol",
		"ResourceRequirements",
		"ResourceList",
		"VolumeDevice",
		"Probe",
		"Container",
		"EnvFromSource",
		"EnvVar",
		"VolumeMount",
		"Lifecycle",
		"SecurityContext",
		"EphemeralContainer",
		"LocalObjectReference",
		"Affinity",
		"Toleration",
		"HostAlias",
		"PodDNSConfig",
		"PodReadinessGate",
		"PreemptionPolicy",
		"TopologySpreadConstraint",
		"TerminationMessagePolicy",
		"PullPolicy",
		"RestartPolicy",
		"DNSPolicy",
		"ObjectFieldSelector",
		"PodSecurityContext",
		"ResourceName",
		"Capabilities",
		"Capability",
		"ExecAction",
		"HostPathVolumeSource",
		"HostPathType",
		"ProjectedVolumeSource",
		"MountPropagationMode",
		"ConfigMapVolumeSource",
		"ClaimName",
		"PersistentVolumeClaimVolumeSource",
	}
)

Functions

This section is empty.

Types

type ClusterRole

type ClusterRole struct {
	KubeObject *rbacv1.ClusterRole
	GoName     string
}

func NewClusterRole

func NewClusterRole(obj *rbacv1.ClusterRole) *ClusterRole

func (ClusterRole) Install

func (k ClusterRole) Install() (string, []string)

func (ClusterRole) Uninstall

func (k ClusterRole) Uninstall() string

type ClusterRoleBinding

type ClusterRoleBinding struct {
	KubeObject *rbacv1.ClusterRoleBinding
	GoName     string
}

func NewClusterRoleBinding

func NewClusterRoleBinding(obj *rbacv1.ClusterRoleBinding) *ClusterRoleBinding

func (ClusterRoleBinding) Install

func (k ClusterRoleBinding) Install() (string, []string)

func (ClusterRoleBinding) Uninstall

func (k ClusterRoleBinding) Uninstall() string

type Codified added in v1.0.0

type Codified struct {

	// The unknown original object
	Object interface{}

	// The packages required to code each object
	Packages []string

	// The Go code to define each object
	Source string

	// The full result from valast
	R valast.Result
}

Codified is the source code associated with a given Kubernetes object.

func Literal

func Literal(kubeobject interface{}) (*Codified, error)

Literal will convert an abstract kubeobject interface{} to Go code.

The various components relevant to each conversion are returned in a *Codified object.

type ConfigMap

type ConfigMap struct {
	KubeObject *corev1.ConfigMap
	GoName     string
}

func NewConfigMap

func NewConfigMap(obj *corev1.ConfigMap) *ConfigMap

func (ConfigMap) Install

func (k ConfigMap) Install() (string, []string)

func (ConfigMap) Uninstall

func (k ConfigMap) Uninstall() string

type CronJob

type CronJob struct {
	KubeObject *batchv1.CronJob
	GoName     string
}

func NewCronJob

func NewCronJob(obj *batchv1.CronJob) *CronJob

func (CronJob) Install

func (k CronJob) Install() (string, []string)

func (CronJob) Uninstall

func (k CronJob) Uninstall() string

type CustomResourceDefinition added in v0.2.9

type CustomResourceDefinition struct {
	KubeObject *apiextensionsv1.CustomResourceDefinition
	GoName     string
}

func NewCustomResourceDefinition added in v0.2.9

func NewCustomResourceDefinition(obj *apiextensionsv1.CustomResourceDefinition) *CustomResourceDefinition

func (CustomResourceDefinition) Install added in v0.2.9

func (k CustomResourceDefinition) Install() (string, []string)

func (CustomResourceDefinition) Uninstall added in v0.2.9

func (k CustomResourceDefinition) Uninstall() string

type DaemonSet

type DaemonSet struct {
	KubeObject *appsv1.DaemonSet
	GoName     string
}

func NewDaemonSet

func NewDaemonSet(obj *appsv1.DaemonSet) *DaemonSet

func (DaemonSet) Install

func (k DaemonSet) Install() (string, []string)

func (DaemonSet) Uninstall

func (k DaemonSet) Uninstall() string

type Deployment

type Deployment struct {
	KubeObject *appsv1.Deployment
	GoName     string
}

func NewDeployment

func NewDeployment(obj *appsv1.Deployment) *Deployment

func (Deployment) Install

func (k Deployment) Install() (string, []string)

func (Deployment) Uninstall

func (k Deployment) Uninstall() string

type Ingress

type Ingress struct {
	KubeObject *networkingv1.Ingress
	GoName     string
}

func NewIngress

func NewIngress(obj *networkingv1.Ingress) *Ingress

func (Ingress) Install

func (k Ingress) Install() (string, []string)

func (Ingress) Uninstall

func (k Ingress) Uninstall() string

type IngressClass added in v0.3.2

type IngressClass struct {
	KubeObject *networkingv1.IngressClass
	GoName     string
}

func NewIngressClass added in v0.3.2

func NewIngressClass(obj *networkingv1.IngressClass) *IngressClass

func (IngressClass) Install added in v0.3.2

func (k IngressClass) Install() (string, []string)

func (IngressClass) Uninstall added in v0.3.2

func (k IngressClass) Uninstall() string

type Job

type Job struct {
	KubeObject *batchv1.Job
	GoName     string
}

func NewJob

func NewJob(obj *batchv1.Job) *Job

func (Job) Install

func (k Job) Install() (string, []string)

func (Job) Uninstall

func (k Job) Uninstall() string

type Namespace added in v0.2.9

type Namespace struct {
	KubeObject *corev1.Namespace
	GoName     string
}

func NewNamespace added in v0.2.9

func NewNamespace(obj *corev1.Namespace) *Namespace

func (Namespace) Install added in v0.2.9

func (k Namespace) Install() (string, []string)

func (Namespace) Uninstall added in v0.2.9

func (k Namespace) Uninstall() string

type PersistentVolume

type PersistentVolume struct {
	KubeObject *corev1.PersistentVolume
	GoName     string
}

func NewPersistentVolume

func NewPersistentVolume(obj *corev1.PersistentVolume) *PersistentVolume

func (PersistentVolume) Install

func (k PersistentVolume) Install() (string, []string)

func (PersistentVolume) Uninstall

func (k PersistentVolume) Uninstall() string

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	KubeObject *corev1.PersistentVolumeClaim
	GoName     string
}

func (PersistentVolumeClaim) Install

func (k PersistentVolumeClaim) Install() (string, []string)

func (PersistentVolumeClaim) Uninstall

func (k PersistentVolumeClaim) Uninstall() string

type Pod

type Pod struct {
	KubeObject *corev1.Pod
	GoName     string
}

func NewPod

func NewPod(obj *corev1.Pod) *Pod

func (Pod) Install

func (k Pod) Install() (string, []string)

func (Pod) Uninstall

func (k Pod) Uninstall() string

type PodDisruptionBudget added in v1.0.2

type PodDisruptionBudget struct {
	KubeObject *policyv1.PodDisruptionBudget
	GoName     string
}

func NewPodDisruptionBudget added in v1.0.2

func NewPodDisruptionBudget(obj *policyv1.PodDisruptionBudget) *PodDisruptionBudget

func (PodDisruptionBudget) Install added in v1.0.2

func (k PodDisruptionBudget) Install() (string, []string)

func (PodDisruptionBudget) Uninstall added in v1.0.2

func (k PodDisruptionBudget) Uninstall() string

type PodSecurityPolicy added in v0.4.0

type PodSecurityPolicy struct {
	KubeObject *policyv1.PodSecurityPolicy
	GoName     string
}

func NewPodSecurityPolicy added in v0.4.0

func NewPodSecurityPolicy(obj *policyv1.PodSecurityPolicy) *PodSecurityPolicy

func (PodSecurityPolicy) Install added in v0.4.0

func (k PodSecurityPolicy) Install() (string, []string)

func (PodSecurityPolicy) Uninstall added in v0.4.0

func (k PodSecurityPolicy) Uninstall() string

type Role

type Role struct {
	KubeObject *rbacv1.Role
	GoName     string
}

func NewRole

func NewRole(obj *rbacv1.Role) *Role

func (Role) Install

func (k Role) Install() (string, []string)

func (Role) Uninstall

func (k Role) Uninstall() string

type RoleBinding

type RoleBinding struct {
	KubeObject *rbacv1.RoleBinding
	GoName     string
}

func NewRoleBinding

func NewRoleBinding(obj *rbacv1.RoleBinding) *RoleBinding

func (RoleBinding) Install

func (k RoleBinding) Install() (string, []string)

func (RoleBinding) Uninstall

func (k RoleBinding) Uninstall() string

type Secret

type Secret struct {
	KubeObject *corev1.Secret
	GoName     string
}

func NewSecret

func NewSecret(obj *corev1.Secret) *Secret

func (Secret) Install

func (k Secret) Install() (string, []string)

func (Secret) Uninstall

func (k Secret) Uninstall() string

type Service

type Service struct {
	KubeObject *corev1.Service
	GoName     string
}

func NewService

func NewService(obj *corev1.Service) *Service

func (Service) Install

func (k Service) Install() (string, []string)

func (Service) Uninstall

func (k Service) Uninstall() string

type ServiceAccount

type ServiceAccount struct {
	KubeObject *corev1.ServiceAccount
	GoName     string
}

func NewServiceAccount

func NewServiceAccount(obj *corev1.ServiceAccount) *ServiceAccount

func (ServiceAccount) Install

func (k ServiceAccount) Install() (string, []string)

func (ServiceAccount) Uninstall

func (k ServiceAccount) Uninstall() string

type StatefulSet

type StatefulSet struct {
	KubeObject *appsv1.StatefulSet
	GoName     string
}

func NewStatefulSet

func NewStatefulSet(obj *appsv1.StatefulSet) *StatefulSet

func (StatefulSet) Install

func (k StatefulSet) Install() (string, []string)

func (StatefulSet) Uninstall

func (k StatefulSet) Uninstall() string

type ValidatingwebhookConfiguration added in v0.3.2

type ValidatingwebhookConfiguration struct {
	KubeObject *admissionregistrationv1.ValidatingWebhookConfiguration
	GoName     string
}

func (ValidatingwebhookConfiguration) Install added in v0.3.2

func (k ValidatingwebhookConfiguration) Install() (string, []string)

func (ValidatingwebhookConfiguration) Uninstall added in v0.3.2

func (k ValidatingwebhookConfiguration) Uninstall() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL