Generate OpenAPISchema

This commit is contained in:
Marc Campbell
2020-02-10 21:17:11 +00:00
parent b466188679
commit 899d5d7672
12 changed files with 4686 additions and 0 deletions

View File

@@ -69,6 +69,15 @@ generate: controller-gen client-gen
controller-gen object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/...
client-gen --output-package=github.com/replicatedhq/troubleshoot/pkg/client --clientset-name troubleshootclientset --input-base github.com/replicatedhq/troubleshoot/pkg/apis --input troubleshoot/v1beta1 -h ./hack/boilerplate.go.txt
.PHONY: openapischema
openapischema: controller-gen
controller-gen crd +output:dir=./config/crds paths=./pkg/apis/troubleshoot/v1beta1
.PHONY: schemas
schemas: fmt vet openapischema
go build ${LDFLAGS} -o bin/schemagen github.com/replicatedhq/troubleshoot/cmd/schemagen
./bin/schemagen --output-dir ./schemas
# find or download controller-gen
# download controller-gen if necessary
controller-gen:

128
cmd/schemagen/cli/root.go Normal file
View File

@@ -0,0 +1,128 @@
package cli
import (
"encoding/json"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
extensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
extensionsscheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme"
"k8s.io/client-go/kubernetes/scheme"
)
func RootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "schemagen",
Short: "Generate openapischemas for the kinds in this project",
SilenceUsage: true,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
v := viper.GetViper()
return generateSchemas(v)
},
}
cobra.OnInitialize(initConfig)
cmd.Flags().String("output-dir", "./schemas", "directory to save the schemas in")
viper.BindPFlags(cmd.Flags())
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
return cmd
}
func InitAndExecute() {
if err := RootCmd().Execute(); err != nil {
os.Exit(1)
}
}
func initConfig() {
viper.SetEnvPrefix("TROUBLESHOOT")
viper.AutomaticEnv()
}
func generateSchemas(v *viper.Viper) error {
// we generate schemas from the config/crds in the root of this project
// those crds can be created from controller-gen or by running `make openapischema`
workdir, err := os.Getwd()
if err != nil {
return errors.Wrap(err, "failed to get workdir")
}
preflightContents, err := ioutil.ReadFile(filepath.Join(workdir, "config", "crds", "troubleshoot.replicated.com_preflights.yaml"))
if err != nil {
return errors.Wrap(err, "failed to read preflight crd")
}
if err := generateSchemaFromCRD(preflightContents, filepath.Join(workdir, v.GetString("output-dir"), "preflight.json")); err != nil {
return errors.Wrap(err, "failed to write preflight schema")
}
analyzersContents, err := ioutil.ReadFile(filepath.Join(workdir, "config", "crds", "troubleshoot.replicated.com_analyzers.yaml"))
if err != nil {
return errors.Wrap(err, "failed to read analyzers crd")
}
if err := generateSchemaFromCRD(analyzersContents, filepath.Join(workdir, v.GetString("output-dir"), "analyzers.json")); err != nil {
return errors.Wrap(err, "failed to write analyzers schema")
}
collectorsContents, err := ioutil.ReadFile(filepath.Join(workdir, "config", "crds", "troubleshoot.replicated.com_collectors.yaml"))
if err != nil {
return errors.Wrap(err, "failed to read collectors crd")
}
if err := generateSchemaFromCRD(collectorsContents, filepath.Join(workdir, v.GetString("output-dir"), "collectors.json")); err != nil {
return errors.Wrap(err, "failed to write collectors schema")
}
return nil
}
func generateSchemaFromCRD(crd []byte, outfile string) error {
extensionsscheme.AddToScheme(scheme.Scheme)
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode(crd, nil, nil)
if err != nil {
return errors.Wrap(err, "failed to decode crd")
}
customResourceDefinition := obj.(*extensionsv1beta1.CustomResourceDefinition)
b, err := json.MarshalIndent(customResourceDefinition.Spec.Validation.OpenAPIV3Schema, "", " ")
if err != nil {
return errors.Wrap(err, "failed to marshal json")
}
_, err = os.Stat(outfile)
if err == nil {
if err := os.Remove(outfile); err != nil {
return errors.Wrap(err, "failed to remove file")
}
}
d, _ := path.Split(outfile)
_, err = os.Stat(d)
if os.IsNotExist(err) {
if err = os.MkdirAll(d, 0755); err != nil {
return errors.Wrap(err, "failed to mkdir")
}
}
err = ioutil.WriteFile(outfile, b, 0644)
if err != nil {
return errors.Wrap(err, "failed to write file")
}
return nil
}

9
cmd/schemagen/main.go Normal file
View File

@@ -0,0 +1,9 @@
package main
import (
"github.com/replicatedhq/troubleshoot/cmd/schemagen/cli"
)
func main() {
cli.InitAndExecute()
}

View File

@@ -0,0 +1,51 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: analyzerjobs.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: AnalyzerJob
listKind: AnalyzerJobList
plural: analyzerjobs
singular: analyzerjob
scope: Namespaced
validation:
openAPIV3Schema:
description: AnalyzerJob is the Schema for the analyzerjobs 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
spec:
description: AnalyzerJobSpec defines the desired state of AnalyzerJob
type: object
status:
description: AnalyzerJobStatus defines the observed state of AnalyzerJob
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,611 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: analyzers.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: Analyzer
listKind: AnalyzerList
plural: analyzers
singular: analyzer
scope: Namespaced
validation:
openAPIV3Schema:
description: Analyzer is the Schema for the analyzers 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
spec:
description: AnalyzerSpec defines the desired state of Analyzer
properties:
analyzers:
items:
properties:
clusterVersion:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
containerRuntime:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
customResourceDefinition:
properties:
checkName:
type: string
customResourceDefinitionName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- customResourceDefinitionName
- outcomes
type: object
deploymentStatus:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- name
- namespace
- outcomes
type: object
distribution:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
imagePullSecret:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
registryName:
type: string
required:
- outcomes
- registryName
type: object
ingress:
properties:
checkName:
type: string
exclude:
type: boolean
ingressName:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- ingressName
- namespace
- outcomes
type: object
nodeResources:
properties:
checkName:
type: string
exclude:
type: boolean
filters:
properties:
cpuAllocatable:
type: string
cpuCapacity:
type: string
ephemeralStorageAllocatable:
type: string
ephemeralStorageCapacity:
type: string
memoryAllocatable:
type: string
memoryCapacity:
type: string
podAllocatable:
type: string
podCapacity:
type: string
type: object
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
secret:
properties:
checkName:
type: string
exclude:
type: boolean
key:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
secretName:
type: string
required:
- namespace
- outcomes
- secretName
type: object
statefulsetStatus:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- name
- namespace
- outcomes
type: object
storageClass:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
storageClassName:
type: string
required:
- outcomes
- storageClassName
type: object
textAnalyze:
properties:
checkName:
type: string
collectorName:
type: string
exclude:
type: boolean
fileName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
regex:
type: string
regexGroups:
type: string
required:
- outcomes
type: object
type: object
type: array
type: object
status:
description: AnalyzerStatus defines the observed state of Analyzer
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,100 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: collectorjobs.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: CollectorJob
listKind: CollectorJobList
plural: collectorjobs
singular: collectorjob
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: CollectorJob is the Schema for the collectorjobs 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
spec:
description: CollectorJobSpec defines the desired state of CollectorJob
properties:
collector:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
image:
type: string
imagePullPolicy:
type: string
redact:
type: boolean
required:
- collector
type: object
status:
description: CollectorJobStatus defines the observed state of CollectorJob
properties:
failed:
items:
type: string
type: array
isServerReady:
type: boolean
running:
items:
type: string
type: array
serverPodName:
type: string
serverPodNamespace:
type: string
serverPodPort:
type: integer
successful:
items:
type: string
type: array
required:
- failed
- isServerReady
- running
- serverPodName
- serverPodNamespace
- serverPodPort
- successful
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,300 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: collectors.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: Collector
listKind: CollectorList
plural: collectors
singular: collector
scope: Namespaced
validation:
openAPIV3Schema:
description: Collector is the Schema for the collectors 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
spec:
description: CollectorSpec defines the desired state of Collector
properties:
afterCollection:
items:
properties:
callback:
properties:
method:
type: string
uri:
type: string
required:
- method
- uri
type: object
uploadResultsTo:
properties:
method:
type: string
uri:
type: string
required:
- method
- uri
type: object
type: object
type: array
collectors:
items:
properties:
clusterInfo:
properties:
collectorName:
type: string
when:
type: boolean
required:
- when
type: object
clusterResources:
properties:
collectorName:
type: string
when:
type: boolean
required:
- when
type: object
copy:
properties:
collectorName:
type: string
containerName:
type: string
containerPath:
type: string
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
when:
type: boolean
required:
- containerPath
- namespace
- selector
- when
type: object
data:
properties:
collectorName:
type: string
data:
type: string
name:
type: string
when:
type: boolean
required:
- data
- when
type: object
exec:
properties:
args:
items:
type: string
type: array
collectorName:
type: string
command:
items:
type: string
type: array
containerName:
type: string
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
timeout:
type: string
when:
type: boolean
required:
- namespace
- selector
- when
type: object
http:
properties:
collectorName:
type: string
get:
properties:
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
name:
type: string
post:
properties:
body:
type: string
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
put:
properties:
body:
type: string
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
when:
type: boolean
required:
- when
type: object
logs:
properties:
collectorName:
type: string
containerNames:
items:
type: string
type: array
limits:
properties:
maxAge:
type: string
maxLines:
format: int64
type: integer
type: object
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
when:
type: boolean
required:
- selector
- when
type: object
run:
properties:
args:
items:
type: string
type: array
collectorName:
type: string
command:
items:
type: string
type: array
image:
type: string
imagePullPolicy:
type: string
name:
type: string
namespace:
type: string
timeout:
type: string
when:
type: boolean
required:
- image
- namespace
- when
type: object
secret:
properties:
collectorName:
type: string
includeValue:
type: boolean
key:
type: string
name:
type: string
namespace:
type: string
when:
type: boolean
required:
- name
- when
type: object
type: object
type: array
type: object
status:
description: CollectorStatus defines the observed state of Collector
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,120 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: preflightjobs.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: PreflightJob
listKind: PreflightJobList
plural: preflightjobs
singular: preflightjob
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: PreflightJob is the Schema for the preflightjobs 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
spec:
description: PreflightJobSpec defines the desired state of PreflightJob
properties:
collectorImage:
type: string
collectorImagePullPolicy:
type: string
imagePullPolicy:
type: string
preflight:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
preflightImage:
type: string
required:
- preflight
type: object
status:
description: PreflightJobStatus defines the observed state of PreflightJob
properties:
analyzersFailed:
items:
type: string
type: array
analyzersRunning:
items:
type: string
type: array
analyzersSuccessful:
items:
type: string
type: array
collectorsFailed:
items:
type: string
type: array
collectorsRunning:
items:
type: string
type: array
collectorsSuccessful:
items:
type: string
type: array
isAnalyzersComplete:
type: boolean
isServerReady:
type: boolean
serverPodName:
type: string
serverPodNamespace:
type: string
serverPodPort:
type: integer
required:
- analyzersFailed
- analyzersRunning
- analyzersSuccessful
- collectorsFailed
- collectorsRunning
- collectorsSuccessful
- isAnalyzersComplete
- isServerReady
- serverPodName
- serverPodNamespace
- serverPodPort
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,836 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: preflights.troubleshoot.replicated.com
spec:
group: troubleshoot.replicated.com
names:
kind: Preflight
listKind: PreflightList
plural: preflights
singular: preflight
scope: Namespaced
validation:
openAPIV3Schema:
description: Preflight is the Schema for the preflights 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
spec:
description: PreflightSpec defines the desired state of Preflight
properties:
analyzers:
items:
properties:
clusterVersion:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
containerRuntime:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
customResourceDefinition:
properties:
checkName:
type: string
customResourceDefinitionName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- customResourceDefinitionName
- outcomes
type: object
deploymentStatus:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- name
- namespace
- outcomes
type: object
distribution:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
imagePullSecret:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
registryName:
type: string
required:
- outcomes
- registryName
type: object
ingress:
properties:
checkName:
type: string
exclude:
type: boolean
ingressName:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- ingressName
- namespace
- outcomes
type: object
nodeResources:
properties:
checkName:
type: string
exclude:
type: boolean
filters:
properties:
cpuAllocatable:
type: string
cpuCapacity:
type: string
ephemeralStorageAllocatable:
type: string
ephemeralStorageCapacity:
type: string
memoryAllocatable:
type: string
memoryCapacity:
type: string
podAllocatable:
type: string
podCapacity:
type: string
type: object
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
secret:
properties:
checkName:
type: string
exclude:
type: boolean
key:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
secretName:
type: string
required:
- namespace
- outcomes
- secretName
type: object
statefulsetStatus:
properties:
checkName:
type: string
exclude:
type: boolean
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- name
- namespace
- outcomes
type: object
storageClass:
properties:
checkName:
type: string
exclude:
type: boolean
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
storageClassName:
type: string
required:
- outcomes
- storageClassName
type: object
textAnalyze:
properties:
checkName:
type: string
collectorName:
type: string
exclude:
type: boolean
fileName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
regex:
type: string
regexGroups:
type: string
required:
- outcomes
type: object
type: object
type: array
collectors:
items:
properties:
clusterInfo:
properties:
collectorName:
type: string
when:
type: boolean
required:
- when
type: object
clusterResources:
properties:
collectorName:
type: string
when:
type: boolean
required:
- when
type: object
copy:
properties:
collectorName:
type: string
containerName:
type: string
containerPath:
type: string
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
when:
type: boolean
required:
- containerPath
- namespace
- selector
- when
type: object
data:
properties:
collectorName:
type: string
data:
type: string
name:
type: string
when:
type: boolean
required:
- data
- when
type: object
exec:
properties:
args:
items:
type: string
type: array
collectorName:
type: string
command:
items:
type: string
type: array
containerName:
type: string
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
timeout:
type: string
when:
type: boolean
required:
- namespace
- selector
- when
type: object
http:
properties:
collectorName:
type: string
get:
properties:
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
name:
type: string
post:
properties:
body:
type: string
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
put:
properties:
body:
type: string
headers:
additionalProperties:
type: string
type: object
insecureSkipVerify:
type: boolean
url:
type: string
required:
- url
type: object
when:
type: boolean
required:
- when
type: object
logs:
properties:
collectorName:
type: string
containerNames:
items:
type: string
type: array
limits:
properties:
maxAge:
type: string
maxLines:
format: int64
type: integer
type: object
name:
type: string
namespace:
type: string
selector:
items:
type: string
type: array
when:
type: boolean
required:
- selector
- when
type: object
run:
properties:
args:
items:
type: string
type: array
collectorName:
type: string
command:
items:
type: string
type: array
image:
type: string
imagePullPolicy:
type: string
name:
type: string
namespace:
type: string
timeout:
type: string
when:
type: boolean
required:
- image
- namespace
- when
type: object
secret:
properties:
collectorName:
type: string
includeValue:
type: boolean
key:
type: string
name:
type: string
namespace:
type: string
when:
type: boolean
required:
- name
- when
type: object
type: object
type: array
uploadResultsTo:
type: string
type: object
status:
description: PreflightStatus defines the observed state of Preflight
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

891
schemas/analyzers.json Normal file
View File

@@ -0,0 +1,891 @@
{
"description": "Analyzer is the Schema for the analyzers API",
"type": "object",
"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"
},
"spec": {
"description": "AnalyzerSpec defines the desired state of Analyzer",
"type": "object",
"properties": {
"analyzers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"clusterVersion": {
"type": "object",
"required": [
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"containerRuntime": {
"type": "object",
"required": [
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"customResourceDefinition": {
"type": "object",
"required": [
"customResourceDefinitionName",
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"customResourceDefinitionName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"deploymentStatus": {
"type": "object",
"required": [
"name",
"namespace",
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"distribution": {
"type": "object",
"required": [
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"imagePullSecret": {
"type": "object",
"required": [
"outcomes",
"registryName"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"registryName": {
"type": "string"
}
}
},
"ingress": {
"type": "object",
"required": [
"ingressName",
"namespace",
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"ingressName": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"nodeResources": {
"type": "object",
"required": [
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"filters": {
"type": "object",
"properties": {
"cpuAllocatable": {
"type": "string"
},
"cpuCapacity": {
"type": "string"
},
"ephemeralStorageAllocatable": {
"type": "string"
},
"ephemeralStorageCapacity": {
"type": "string"
},
"memoryAllocatable": {
"type": "string"
},
"memoryCapacity": {
"type": "string"
},
"podAllocatable": {
"type": "string"
},
"podCapacity": {
"type": "string"
}
}
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"secret": {
"type": "object",
"required": [
"namespace",
"outcomes",
"secretName"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"key": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"secretName": {
"type": "string"
}
}
},
"statefulsetStatus": {
"type": "object",
"required": [
"name",
"namespace",
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
}
}
},
"storageClass": {
"type": "object",
"required": [
"outcomes",
"storageClassName"
],
"properties": {
"checkName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"storageClassName": {
"type": "string"
}
}
},
"textAnalyze": {
"type": "object",
"required": [
"outcomes"
],
"properties": {
"checkName": {
"type": "string"
},
"collectorName": {
"type": "string"
},
"exclude": {
"type": "boolean"
},
"fileName": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"regex": {
"type": "string"
},
"regexGroups": {
"type": "string"
}
}
}
}
}
}
}
},
"status": {
"description": "AnalyzerStatus defines the observed state of Analyzer",
"type": "object"
}
}
}

401
schemas/collectors.json Normal file
View File

@@ -0,0 +1,401 @@
{
"description": "Collector is the Schema for the collectors API",
"type": "object",
"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"
},
"spec": {
"description": "CollectorSpec defines the desired state of Collector",
"type": "object",
"properties": {
"afterCollection": {
"type": "array",
"items": {
"type": "object",
"properties": {
"callback": {
"type": "object",
"required": [
"method",
"uri"
],
"properties": {
"method": {
"type": "string"
},
"uri": {
"type": "string"
}
}
},
"uploadResultsTo": {
"type": "object",
"required": [
"method",
"uri"
],
"properties": {
"method": {
"type": "string"
},
"uri": {
"type": "string"
}
}
}
}
}
},
"collectors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"clusterInfo": {
"type": "object",
"required": [
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
},
"clusterResources": {
"type": "object",
"required": [
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
},
"copy": {
"type": "object",
"required": [
"containerPath",
"namespace",
"selector",
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"containerName": {
"type": "string"
},
"containerPath": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"selector": {
"type": "array",
"items": {
"type": "string"
}
},
"when": {
"type": "boolean"
}
}
},
"data": {
"type": "object",
"required": [
"data",
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"data": {
"type": "string"
},
"name": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
},
"exec": {
"type": "object",
"required": [
"namespace",
"selector",
"when"
],
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"collectorName": {
"type": "string"
},
"command": {
"type": "array",
"items": {
"type": "string"
}
},
"containerName": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"selector": {
"type": "array",
"items": {
"type": "string"
}
},
"timeout": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
},
"http": {
"type": "object",
"required": [
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"get": {
"type": "object",
"required": [
"url"
],
"properties": {
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"insecureSkipVerify": {
"type": "boolean"
},
"url": {
"type": "string"
}
}
},
"name": {
"type": "string"
},
"post": {
"type": "object",
"required": [
"url"
],
"properties": {
"body": {
"type": "string"
},
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"insecureSkipVerify": {
"type": "boolean"
},
"url": {
"type": "string"
}
}
},
"put": {
"type": "object",
"required": [
"url"
],
"properties": {
"body": {
"type": "string"
},
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"insecureSkipVerify": {
"type": "boolean"
},
"url": {
"type": "string"
}
}
},
"when": {
"type": "boolean"
}
}
},
"logs": {
"type": "object",
"required": [
"selector",
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"containerNames": {
"type": "array",
"items": {
"type": "string"
}
},
"limits": {
"type": "object",
"properties": {
"maxAge": {
"type": "string"
},
"maxLines": {
"type": "integer",
"format": "int64"
}
}
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"selector": {
"type": "array",
"items": {
"type": "string"
}
},
"when": {
"type": "boolean"
}
}
},
"run": {
"type": "object",
"required": [
"image",
"namespace",
"when"
],
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"collectorName": {
"type": "string"
},
"command": {
"type": "array",
"items": {
"type": "string"
}
},
"image": {
"type": "string"
},
"imagePullPolicy": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"timeout": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
},
"secret": {
"type": "object",
"required": [
"name",
"when"
],
"properties": {
"collectorName": {
"type": "string"
},
"includeValue": {
"type": "boolean"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"when": {
"type": "boolean"
}
}
}
}
}
}
}
},
"status": {
"description": "CollectorStatus defines the observed state of Collector",
"type": "object"
}
}
}

1230
schemas/preflight.json Normal file

File diff suppressed because it is too large Load Diff