Skip to content

Commit

Permalink
Add Inline YAML Program Functionality (#336)
Browse files Browse the repository at this point in the history
* Add Program API types

* Update Makefile and add docs

* Add program tests & functionality to controller

This commit implements the handling of Stacks that refer to Programs, by
adding a case for .spec.programRef, a func to setup the workspace, and a
special case for rescheduling.

* Add changelog entry for inline YAML programs

* Add extra testcases

* Add changes as per reviews

* Use enum for configuration item type field

NB: the codegen (via `crdoc`) fails to escape angle braces in the enum
values, so docs/programs.md is not quite correct. Ideally we can fix the
upstream bug at some point.

Signed-off-by: Michael Bridgen <[email protected]>
Co-authored-by: Roo Thorp <[email protected]>

* Update Program API to include descriptions

* Clean up Program tests with helper functions

* Add SourceUnknown reason when Program is nonexistent

* Cleanup as per review

Signed-off-by: Michael Bridgen <[email protected]>
Co-authored-by: Michael Bridgen <[email protected]>
  • Loading branch information
Roo Thorp and squaremo authored Oct 14, 2022
1 parent 021265b commit 72e4168
Show file tree
Hide file tree
Showing 14 changed files with 1,402 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ CHANGELOG
- Add support for referring to a [Flux source object](https://fluxcd.io/flux/components/source/api/)
as the source of the Pulumi program to run for a Stack.
[#324](https://github.com/pulumi/pulumi-kubernetes-operator/pull/324)
- Add functionality for using [Pulumi YAML](https://www.pulumi.com/docs/intro/languages/yaml/) in-line to create Pulumi programs.
[#336](https://github.com/pulumi/pulumi-kubernetes-operator/pull/336)

## 1.9.0 (2022-10-05)

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ download-test-deps:
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

install-crds:
kubectl apply -f deploy/crds/pulumi.com_stacks.yaml
kubectl apply -f deploy/crds/

codegen: install-controller-gen install-crdoc generate-k8s generate-crds generate-crdocs

Expand All @@ -31,6 +31,7 @@ generate-k8s:

generate-crdocs:
crdoc --resources deploy/crds/pulumi.com_stacks.yaml --output docs/stacks.md
crdoc --resources deploy/crds/pulumi.com_programs.yaml --output docs/programs.md

build-image: build-static
docker build --rm -t $(IMAGE_NAME):$(VERSION) -f Dockerfile .
Expand Down
190 changes: 190 additions & 0 deletions deploy/crds/pulumi.com_programs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: programs.pulumi.com
spec:
group: pulumi.com
names:
kind: Program
listKind: ProgramList
plural: programs
singular: program
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1
schema:
openAPIV3Schema:
description: Program is the schema for the inline YAML program API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
program:
properties:
configuration:
additionalProperties:
properties:
default:
description: default is a value of the appropriate type for
the template to use if no value is specified.
x-kubernetes-preserve-unknown-fields: true
type:
description: type is the (required) data type for the parameter.
enum:
- String
- Number
- List<Number>
- List<String>
type: string
type: object
description: configuration specifies the Pulumi config inputs to the
deployment. Either type or default is required.
type: object
outputs:
additionalProperties:
x-kubernetes-preserve-unknown-fields: true
description: outputs specifies the Pulumi stack outputs of the program
and how they are computed from the resources.
type: object
resources:
additionalProperties:
properties:
get:
description: A getter function for the resource. Supplying get
is mutually exclusive to properties.
properties:
id:
description: The ID of the resource to import.
minLength: 1
type: string
state:
additionalProperties:
x-kubernetes-preserve-unknown-fields: true
description: state contains the known properties (input
& output) of the resource. This assists the provider in
figuring out the correct resource.
type: object
required:
- id
type: object
options:
description: options contains all resource options supported
by Pulumi.
properties:
additionalSecretOutputs:
description: additionalSecretOutputs specifies properties
that must be encrypted as secrets.
items:
type: string
type: array
aliases:
description: aliases specifies names that this resource
used to have, so that renaming or refactoring doesn’t
replace it.
items:
type: string
type: array
customTimeouts:
description: customTimeouts overrides the default retry/timeout
behavior for resource provisioning.
properties:
create:
description: create is the custom timeout for create
operations.
type: string
delete:
description: delete is the custom timeout for delete
operations.
type: string
update:
description: update is the custom timeout for update
operations.
type: string
type: object
deleteBeforeReplace:
description: deleteBeforeReplace overrides the default create-before-delete
behavior when replacing.
type: boolean
dependsOn:
description: dependsOn adds explicit dependencies in addition
to the ones in the dependency graph.
items:
x-kubernetes-preserve-unknown-fields: true
type: array
ignoreChanges:
description: ignoreChanges declares that changes to certain
properties should be ignored when diffing.
items:
type: string
type: array
import:
description: import adopts an existing resource from your
cloud account under the control of Pulumi.
type: string
parent:
description: parent resource option specifies a parent for
a resource. It is used to associate children with the
parents that encapsulate or are responsible for them.
x-kubernetes-preserve-unknown-fields: true
protect:
description: protect prevents accidental deletion of a resource.
type: boolean
provider:
description: provider resource option sets a provider for
the resource.
x-kubernetes-preserve-unknown-fields: true
providers:
additionalProperties:
x-kubernetes-preserve-unknown-fields: true
description: providers resource option sets a map of providers
for the resource and its children.
type: object
version:
description: version specifies a provider plugin version
that should be used when operating on a resource.
type: string
type: object
properties:
additionalProperties:
x-kubernetes-preserve-unknown-fields: true
description: properties contains the primary resource-specific
keys and values to initialize the resource state.
type: object
type:
description: type is the Pulumi type token for this resource.
minLength: 1
type: string
required:
- type
type: object
description: resources declares the Pulumi resources that will be
deployed and managed by the program.
type: object
variables:
additionalProperties:
x-kubernetes-preserve-unknown-fields: true
description: variables specifies intermediate values of the program;
the values of variables are expressions that can be re-used.
type: object
type: object
type: object
served: true
storage: true
subresources: {}
18 changes: 18 additions & 0 deletions deploy/crds/pulumi.com_stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,15 @@ spec:
preferred first, then personal access token, and finally basic auth
credentials. Deprecated. Use GitAuth instead.'
type: string
programRef:
description: ProgramRef refers to a Program object, to be used as
the source for the stack.
properties:
name:
type: string
required:
- name
type: object
projectRepo:
description: ProjectRepo is the git source control repository from
which we fetch the project code and configuration.
Expand Down Expand Up @@ -1314,6 +1323,15 @@ spec:
preferred first, then personal access token, and finally basic auth
credentials. Deprecated. Use GitAuth instead.'
type: string
programRef:
description: ProgramRef refers to a Program object, to be used as
the source for the stack.
properties:
name:
type: string
required:
- name
type: object
projectRepo:
description: ProjectRepo is the git source control repository from
which we fetch the project code and configuration.
Expand Down
Loading

0 comments on commit 72e4168

Please sign in to comment.