Skip to content

Commit

Permalink
OLM integration
Browse files Browse the repository at this point in the history
  • Loading branch information
sabre1041 committed Jan 20, 2021
1 parent 6c4dd70 commit b31f193
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ tags
bin
.codacy-coverage
envfile
#Bundle
bundle
bundle.Dockerfile
15 changes: 12 additions & 3 deletions api/v1alpha1/githubactionrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,58 @@ package v1alpha1

import (
"errors"
"time"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// GithubActionRunnerSpec defines the desired state of GithubActionRunner
type GithubActionRunnerSpec struct {
// Your GitHub organization
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Organization",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Organization string `json:"organization"`

// Optional Github repository name, if repo scoped.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Repository",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Repository string `json:"repository,omitempty"`

// Minimum pool-size. Note that you need one runner in order for jobs to be schedulable, else they fail claiming no runners match the selector labels.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Required
// +kubebuilder:default=1
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Minimum Pool Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
MinRunners int `json:"minRunners"`

// Maximum pool-size. Must be greater or equal to minRunners
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Maximum Pool Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
MaxRunners int `json:"maxRunners"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:XEmbeddedResource
// +kubebuilder:pruning:PreserveUnknownFields
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Pod Template"
PodTemplateSpec v1.PodTemplateSpec `json:"podTemplateSpec"`

// PAT to un/register runners. Required if the operator is not running in github-application mode.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Token Reference"
TokenRef v1.SecretKeySelector `json:"tokenRef"`

// How often to reconcile/check the runner pool. If undefined the controller uses a default of 1m
// +kubebuilder:validation:Optional
// +kubebuilder:default="1m"
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Reconciliation Period"
ReconciliationPeriod string `json:"reconciliationPeriod"`

// What order to delete idle pods in
// +kubebuilder:default="LeastRecent"
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Deletion Order",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:select:leastrecent","urn:alm:descriptor:com.tectonic.ui:select:mostrecent"}
DeletionOrder SortOrder `json:"deletionOrder"`
}

Expand Down Expand Up @@ -88,6 +95,7 @@ type GithubActionRunnerStatus struct {
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Conditions",xDescriptors="urn:alm:descriptor:io.kubernetes.conditions"
// Details of the current state of this API Resource.
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}
Expand All @@ -97,6 +105,7 @@ type GithubActionRunnerStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=githubactionrunners,scope=Namespaced,shortName=gar
// +kubebuilder:printcolumn:name="currentPoolSize",type=integer,JSONPath=`.status.currentSize`
// +operator-sdk:csv:customresourcedefinitions:displayName="GitHub Actions Runner"
type GithubActionRunner struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions config/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- ../default
- ../samples
- ../scorecard
7 changes: 7 additions & 0 deletions config/scorecard/bases/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: scorecard.operatorframework.io/v1alpha3
kind: Configuration
metadata:
name: config
stages:
- parallel: true
tests: []
16 changes: 16 additions & 0 deletions config/scorecard/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resources:
- bases/config.yaml
patchesJson6902:
- path: patches/basic.config.yaml
target:
group: scorecard.operatorframework.io
version: v1alpha3
kind: Configuration
name: config
- path: patches/olm.config.yaml
target:
group: scorecard.operatorframework.io
version: v1alpha3
kind: Configuration
name: config
# +kubebuilder:scaffold:patchesJson6902
10 changes: 10 additions & 0 deletions config/scorecard/patches/basic.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- basic-check-spec
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: basic
test: basic-check-spec-test
50 changes: 50 additions & 0 deletions config/scorecard/patches/olm.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- olm-bundle-validation
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: olm
test: olm-bundle-validation-test
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- olm-crds-have-validation
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: olm
test: olm-crds-have-validation-test
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- olm-crds-have-resources
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: olm
test: olm-crds-have-resources-test
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- olm-spec-descriptors
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: olm
test: olm-spec-descriptors-test
- op: add
path: /stages/0/tests/-
value:
entrypoint:
- scorecard-test
- olm-status-descriptors
image: quay.io/operator-framework/scorecard-test:v1.2.0
labels:
suite: olm
test: olm-status-descriptors-test

0 comments on commit b31f193

Please sign in to comment.