kubernetes-fluent-client 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +4 -0
- package/README.md +24 -0
- package/e2e/cli.e2e.test.ts +127 -0
- package/e2e/crds/policyreports.default.expected/policyreport-v1alpha1.ts +332 -0
- package/e2e/crds/policyreports.default.expected/policyreport-v1alpha2.ts +360 -0
- package/e2e/crds/policyreports.default.expected/policyreport-v1beta1.ts +360 -0
- package/e2e/crds/policyreports.no.post.expected/policyreport-v1alpha1.ts +331 -0
- package/e2e/crds/policyreports.no.post.expected/policyreport-v1alpha2.ts +360 -0
- package/e2e/crds/policyreports.no.post.expected/policyreport-v1beta1.ts +360 -0
- package/e2e/crds/test.yaml/policyreports.test.yaml +1008 -0
- package/e2e/crds/test.yaml/uds-podmonitors.test.yaml +1245 -0
- package/e2e/crds/uds-podmonitors.default.expected/podmonitor-v1.ts +1333 -0
- package/e2e/crds/uds-podmonitors.no.post.expected/podmonitor-v1.ts +1360 -0
- package/package.json +8 -7
- package/src/cli.ts +25 -1
- package/src/fileSystem.test.ts +67 -0
- package/src/fileSystem.ts +25 -0
- package/src/generate.test.ts +368 -358
- package/src/generate.ts +173 -154
- package/src/postProcessing.test.ts +742 -0
- package/src/postProcessing.ts +568 -0
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -48
- package/dist/fetch.d.ts +0 -22
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -82
- package/dist/fetch.test.d.ts +0 -2
- package/dist/fetch.test.d.ts.map +0 -1
- package/dist/fetch.test.js +0 -97
- package/dist/fluent/index.d.ts +0 -12
- package/dist/fluent/index.d.ts.map +0 -1
- package/dist/fluent/index.js +0 -228
- package/dist/fluent/index.test.d.ts +0 -2
- package/dist/fluent/index.test.d.ts.map +0 -1
- package/dist/fluent/index.test.js +0 -193
- package/dist/fluent/types.d.ts +0 -187
- package/dist/fluent/types.d.ts.map +0 -1
- package/dist/fluent/types.js +0 -16
- package/dist/fluent/utils.d.ts +0 -41
- package/dist/fluent/utils.d.ts.map +0 -1
- package/dist/fluent/utils.js +0 -153
- package/dist/fluent/utils.test.d.ts +0 -2
- package/dist/fluent/utils.test.d.ts.map +0 -1
- package/dist/fluent/utils.test.js +0 -215
- package/dist/fluent/watch.d.ts +0 -86
- package/dist/fluent/watch.d.ts.map +0 -1
- package/dist/fluent/watch.js +0 -425
- package/dist/fluent/watch.spec.d.ts +0 -2
- package/dist/fluent/watch.spec.d.ts.map +0 -1
- package/dist/fluent/watch.spec.js +0 -261
- package/dist/generate.d.ts +0 -24
- package/dist/generate.d.ts.map +0 -1
- package/dist/generate.js +0 -195
- package/dist/generate.test.d.ts +0 -2
- package/dist/generate.test.d.ts.map +0 -1
- package/dist/generate.test.js +0 -373
- package/dist/helpers.d.ts +0 -33
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -103
- package/dist/helpers.test.d.ts +0 -2
- package/dist/helpers.test.d.ts.map +0 -1
- package/dist/helpers.test.js +0 -37
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/kinds.d.ts +0 -16
- package/dist/kinds.d.ts.map +0 -1
- package/dist/kinds.js +0 -570
- package/dist/kinds.test.d.ts +0 -2
- package/dist/kinds.test.d.ts.map +0 -1
- package/dist/kinds.test.js +0 -155
- package/dist/patch.d.ts +0 -7
- package/dist/patch.d.ts.map +0 -1
- package/dist/patch.js +0 -2
- package/dist/types.d.ts +0 -32
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/upstream.d.ts +0 -4
- package/dist/upstream.d.ts.map +0 -1
- package/dist/upstream.js +0 -56
package/.prettierignore
ADDED
package/README.md
CHANGED
|
@@ -105,6 +105,30 @@ Promise.all([
|
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
### Generating TypeScript Definitions from CRDs
|
|
109
|
+
|
|
110
|
+
The Kubernetes Fluent Client can generate TypeScript definitions from Custom Resource Definitions (CRDs) using the `generate` command. This command will generate TypeScript interfaces for the CRDs in the cluster and save them to a file.
|
|
111
|
+
|
|
112
|
+
To generate TypeScript definitions from CRDs, run the following command:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
kubernetes-fluent-client crd /path/to/input.yaml /path/to/output/folder
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
If you have a CRD in a file named `crd.yaml` and you want to generate TypeScript definitions in a folder named `types`, you can run the following command:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
kubernetes-fluent-client crd crd.yaml types
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This will generate TypeScript interfaces for the CRD in the `crd.yaml` file and save them to the `types` folder.
|
|
125
|
+
|
|
126
|
+
By default, the generated TypeScript interfaces will be post-processed to make them more user-friendly. If you want to disable this post-processing, you can use the `--noPost` flag:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
kubernetes-fluent-client crd crd.yaml types --noPost
|
|
130
|
+
```
|
|
131
|
+
|
|
108
132
|
### Community
|
|
109
133
|
|
|
110
134
|
To chat with other users & see some examples of the fluent client in active use, go to [Kubernetes Slack](https://communityinviter.com/apps/kubernetes/community) and join `#pepr` channel.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { describe, beforeEach, test, expect, afterEach } from "@jest/globals";
|
|
5
|
+
|
|
6
|
+
// Utility function to execute the CLI command
|
|
7
|
+
const runCliCommand = (
|
|
8
|
+
args: string[],
|
|
9
|
+
callback: (error: Error | null, stdout: string, stderr: string) => void,
|
|
10
|
+
) => {
|
|
11
|
+
execFile("node", ["./dist/cli.js", ...args], callback); // Path to built CLI JS file
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Utility function to compare generated files to expected files
|
|
15
|
+
const compareGeneratedToExpected = (generatedFile: string, expectedFile: string) => {
|
|
16
|
+
// Check if the expected file exists
|
|
17
|
+
expect(fs.existsSync(expectedFile)).toBe(true);
|
|
18
|
+
|
|
19
|
+
// Read and compare the content of the generated file to the expected file
|
|
20
|
+
const generatedContent = fs.readFileSync(generatedFile, "utf8").trim();
|
|
21
|
+
const expectedContent = fs.readFileSync(expectedFile, "utf8").trim();
|
|
22
|
+
|
|
23
|
+
expect(generatedContent).toBe(expectedContent);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe("End-to-End CLI tests with multiple test files", () => {
|
|
27
|
+
const testFolder = path.join(__dirname, "crds/test.yaml"); // Directory containing .test.yaml files
|
|
28
|
+
|
|
29
|
+
// Get all .test.yaml files in the test folder
|
|
30
|
+
const testFiles = fs.readdirSync(testFolder).filter(file => file.endsWith(".test.yaml"));
|
|
31
|
+
|
|
32
|
+
testFiles.forEach(testFile => {
|
|
33
|
+
const name = path.basename(testFile, ".test.yaml"); // Extract name from the filename
|
|
34
|
+
const mockYamlPath = path.join(testFolder, testFile); // Full path to the test YAML file
|
|
35
|
+
const mockDir = path.join(__dirname, "crds/", name); // Output directory based on name
|
|
36
|
+
const expectedDir = path.join(__dirname, `crds/${name}.default.expected`); // Expected default directory
|
|
37
|
+
const expectedPostDir = path.join(__dirname, `crds/${name}.no.post.expected`); // Expected post-processing directory
|
|
38
|
+
|
|
39
|
+
const testInfoMessage = `
|
|
40
|
+
Running tests for ${name}
|
|
41
|
+
Test file: ${mockYamlPath}
|
|
42
|
+
Output directory: ${mockDir}
|
|
43
|
+
Expected directory: ${expectedDir}
|
|
44
|
+
Expected post-processing directory: ${expectedPostDir}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
console.log(testInfoMessage);
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
// Ensure the output directory is clean
|
|
51
|
+
if (fs.existsSync(mockDir)) {
|
|
52
|
+
fs.rmSync(mockDir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Recreate the output directory
|
|
56
|
+
fs.mkdirSync(mockDir);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
// Cleanup the output directory after each test
|
|
61
|
+
if (fs.existsSync(mockDir)) {
|
|
62
|
+
fs.rmSync(mockDir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test(`should generate TypeScript types and run post-processing for ${name}`, done => {
|
|
67
|
+
// Run the CLI command with the appropriate arguments
|
|
68
|
+
runCliCommand(["crd", mockYamlPath, mockDir], (error, stdout) => {
|
|
69
|
+
expect(error).toBeNull(); // Ensure no errors occurred
|
|
70
|
+
|
|
71
|
+
// Get the list of generated files
|
|
72
|
+
const generatedFiles = fs.readdirSync(mockDir);
|
|
73
|
+
|
|
74
|
+
// Compare each generated file to the corresponding expected file in expectedDir
|
|
75
|
+
generatedFiles.forEach(file => {
|
|
76
|
+
const generatedFilePath = path.join(mockDir, file);
|
|
77
|
+
const expectedFilePath = path.join(expectedDir, file);
|
|
78
|
+
|
|
79
|
+
compareGeneratedToExpected(generatedFilePath, expectedFilePath);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Verify stdout output
|
|
83
|
+
expect(stdout).toContain("✅ Generated");
|
|
84
|
+
|
|
85
|
+
// Complete the test
|
|
86
|
+
done();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test(`should skip post-processing for ${name} when using --noPost`, done => {
|
|
91
|
+
// Run the CLI command without the --noPost flag
|
|
92
|
+
runCliCommand(["crd", mockYamlPath, mockDir, "--noPost"], (error, stdout) => {
|
|
93
|
+
expect(error).toBeNull(); // Ensure no errors occurred
|
|
94
|
+
|
|
95
|
+
// Ensure post-processing was not run (stdout should reflect this)
|
|
96
|
+
expect(stdout).not.toContain("🔧 Post-processing started");
|
|
97
|
+
|
|
98
|
+
// Complete the test
|
|
99
|
+
done();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test(`should skip post-processing for ${name} when using --noPost`, done => {
|
|
104
|
+
// Run the CLI command without post-processing
|
|
105
|
+
runCliCommand(["crd", mockYamlPath, mockDir, "--noPost"], (error, stdout) => {
|
|
106
|
+
expect(error).toBeNull(); // Ensure no errors occurred
|
|
107
|
+
|
|
108
|
+
// Get the list of generated files
|
|
109
|
+
const generatedFiles = fs.readdirSync(mockDir);
|
|
110
|
+
|
|
111
|
+
// Compare each generated file to the corresponding expected file in expectedPostDir
|
|
112
|
+
generatedFiles.forEach(file => {
|
|
113
|
+
const generatedFilePath = path.join(mockDir, file);
|
|
114
|
+
const expectedFilePath = path.join(expectedPostDir, file);
|
|
115
|
+
|
|
116
|
+
compareGeneratedToExpected(generatedFilePath, expectedFilePath);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Ensure post-processing was not run (stdout should reflect this)
|
|
120
|
+
expect(stdout).not.toContain("🔧 Post-processing started");
|
|
121
|
+
|
|
122
|
+
// Complete the test
|
|
123
|
+
done();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// This file is auto-generated by kubernetes-fluent-client, do not edit manually
|
|
2
|
+
import { GenericKind, RegisterKind } from "kubernetes-fluent-client";
|
|
3
|
+
/**
|
|
4
|
+
* PolicyReport is the Schema for the policyreports API
|
|
5
|
+
*/
|
|
6
|
+
export class PolicyReport extends GenericKind {
|
|
7
|
+
/**
|
|
8
|
+
* APIVersion defines the versioned schema of this representation of an object. Servers
|
|
9
|
+
* should convert recognized schemas to the latest internal value, and may reject
|
|
10
|
+
* unrecognized values. More info:
|
|
11
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
|
12
|
+
*/
|
|
13
|
+
declare apiVersion?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Kind is a string value representing the REST resource this object represents. Servers may
|
|
16
|
+
* infer this from the endpoint the client submits requests to. Cannot be updated. In
|
|
17
|
+
* CamelCase. More info:
|
|
18
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
|
19
|
+
*/
|
|
20
|
+
declare kind?: string;
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
declare metadata?: { [key: string]: any };
|
|
23
|
+
/**
|
|
24
|
+
* PolicyReportResult provides result details
|
|
25
|
+
*/
|
|
26
|
+
results?: Result[];
|
|
27
|
+
/**
|
|
28
|
+
* Scope is an optional reference to the report scope (e.g. a Deployment, Namespace, or Node)
|
|
29
|
+
*/
|
|
30
|
+
scope?: Scope;
|
|
31
|
+
/**
|
|
32
|
+
* ScopeSelector is an optional selector for multiple scopes (e.g. Pods). Either one of, or
|
|
33
|
+
* none of, but not both of, Scope or ScopeSelector should be specified.
|
|
34
|
+
*/
|
|
35
|
+
scopeSelector?: ScopeSelector;
|
|
36
|
+
/**
|
|
37
|
+
* PolicyReportSummary provides a summary of results
|
|
38
|
+
*/
|
|
39
|
+
summary?: Summary;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* PolicyReportResult provides the result for an individual policy
|
|
44
|
+
*/
|
|
45
|
+
export interface Result {
|
|
46
|
+
/**
|
|
47
|
+
* Category indicates policy category
|
|
48
|
+
*/
|
|
49
|
+
category?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Data provides additional information for the policy rule
|
|
52
|
+
*/
|
|
53
|
+
data?: { [key: string]: string };
|
|
54
|
+
/**
|
|
55
|
+
* Message is a short user friendly description of the policy rule
|
|
56
|
+
*/
|
|
57
|
+
message?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Policy is the name of the policy
|
|
60
|
+
*/
|
|
61
|
+
policy: string;
|
|
62
|
+
/**
|
|
63
|
+
* Resources is an optional reference to the resource checked by the policy and rule
|
|
64
|
+
*/
|
|
65
|
+
resources?: Resource[];
|
|
66
|
+
/**
|
|
67
|
+
* ResourceSelector is an optional selector for policy results that apply to multiple
|
|
68
|
+
* resources. For example, a policy result may apply to all pods that match a label. Either
|
|
69
|
+
* a Resource or a ResourceSelector can be specified. If neither are provided, the result is
|
|
70
|
+
* assumed to be for the policy report scope.
|
|
71
|
+
*/
|
|
72
|
+
resourceSelector?: ResourceSelector;
|
|
73
|
+
/**
|
|
74
|
+
* Rule is the name of the policy rule
|
|
75
|
+
*/
|
|
76
|
+
rule?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Scored indicates if this policy rule is scored
|
|
79
|
+
*/
|
|
80
|
+
scored?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Severity indicates policy severity
|
|
83
|
+
*/
|
|
84
|
+
severity?: Severity;
|
|
85
|
+
/**
|
|
86
|
+
* Status indicates the result of the policy rule check
|
|
87
|
+
*/
|
|
88
|
+
status?: Status;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* ResourceSelector is an optional selector for policy results that apply to multiple
|
|
93
|
+
* resources. For example, a policy result may apply to all pods that match a label. Either
|
|
94
|
+
* a Resource or a ResourceSelector can be specified. If neither are provided, the result is
|
|
95
|
+
* assumed to be for the policy report scope.
|
|
96
|
+
*/
|
|
97
|
+
export interface ResourceSelector {
|
|
98
|
+
/**
|
|
99
|
+
* matchExpressions is a list of label selector requirements. The requirements are ANDed.
|
|
100
|
+
*/
|
|
101
|
+
matchExpressions?: ResourceSelectorMatchExpression[];
|
|
102
|
+
/**
|
|
103
|
+
* matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is
|
|
104
|
+
* equivalent to an element of matchExpressions, whose key field is "key", the operator is
|
|
105
|
+
* "In", and the values array contains only "value". The requirements are ANDed.
|
|
106
|
+
*/
|
|
107
|
+
matchLabels?: { [key: string]: string };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A label selector requirement is a selector that contains values, a key, and an operator
|
|
112
|
+
* that relates the key and values.
|
|
113
|
+
*/
|
|
114
|
+
export interface ResourceSelectorMatchExpression {
|
|
115
|
+
/**
|
|
116
|
+
* key is the label key that the selector applies to.
|
|
117
|
+
*/
|
|
118
|
+
key: string;
|
|
119
|
+
/**
|
|
120
|
+
* operator represents a key's relationship to a set of values. Valid operators are In,
|
|
121
|
+
* NotIn, Exists and DoesNotExist.
|
|
122
|
+
*/
|
|
123
|
+
operator: string;
|
|
124
|
+
/**
|
|
125
|
+
* values is an array of string values. If the operator is In or NotIn, the values array
|
|
126
|
+
* must be non-empty. If the operator is Exists or DoesNotExist, the values array must be
|
|
127
|
+
* empty. This array is replaced during a strategic merge patch.
|
|
128
|
+
*/
|
|
129
|
+
values?: string[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* ObjectReference contains enough information to let you inspect or modify the referred
|
|
134
|
+
* object. --- New uses of this type are discouraged because of difficulty describing its
|
|
135
|
+
* usage when embedded in APIs. 1. Ignored fields. It includes many fields which are not
|
|
136
|
+
* generally honored. For instance, ResourceVersion and FieldPath are both very rarely
|
|
137
|
+
* valid in actual usage. 2. Invalid usage help. It is impossible to add specific help for
|
|
138
|
+
* individual usage. In most embedded usages, there are particular restrictions like, "must
|
|
139
|
+
* refer only to types A and B" or "UID not honored" or "name must be restricted". Those
|
|
140
|
+
* cannot be well described when embedded. 3. Inconsistent validation. Because the usages
|
|
141
|
+
* are different, the validation rules are different by usage, which makes it hard for users
|
|
142
|
+
* to predict what will happen. 4. The fields are both imprecise and overly precise. Kind
|
|
143
|
+
* is not a precise mapping to a URL. This can produce ambiguity during interpretation and
|
|
144
|
+
* require a REST mapping. In most cases, the dependency is on the group,resource tuple and
|
|
145
|
+
* the version of the actual struct is irrelevant. 5. We cannot easily change it. Because
|
|
146
|
+
* this type is embedded in many locations, updates to this type will affect numerous
|
|
147
|
+
* schemas. Don't make new APIs embed an underspecified API type they do not control.
|
|
148
|
+
* Instead of using this type, create a locally provided and used type that is well-focused
|
|
149
|
+
* on your reference. For example, ServiceReferences for admission registration:
|
|
150
|
+
* https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533
|
|
151
|
+
* .
|
|
152
|
+
*/
|
|
153
|
+
export interface Resource {
|
|
154
|
+
/**
|
|
155
|
+
* API version of the referent.
|
|
156
|
+
*/
|
|
157
|
+
apiVersion?: string;
|
|
158
|
+
/**
|
|
159
|
+
* If referring to a piece of an object instead of an entire object, this string should
|
|
160
|
+
* contain a valid JSON/Go field access statement, such as
|
|
161
|
+
* desiredState.manifest.containers[2]. For example, if the object reference is to a
|
|
162
|
+
* container within a pod, this would take on a value like: "spec.containers{name}" (where
|
|
163
|
+
* "name" refers to the name of the container that triggered the event) or if no container
|
|
164
|
+
* name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax
|
|
165
|
+
* is chosen only to have some well-defined way of referencing a part of an object. TODO:
|
|
166
|
+
* this design is not final and this field is subject to change in the future.
|
|
167
|
+
*/
|
|
168
|
+
fieldPath?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Kind of the referent. More info:
|
|
171
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
|
172
|
+
*/
|
|
173
|
+
kind?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Name of the referent. More info:
|
|
176
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
|
177
|
+
*/
|
|
178
|
+
name?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Namespace of the referent. More info:
|
|
181
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
|
|
182
|
+
*/
|
|
183
|
+
namespace?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Specific resourceVersion to which this reference is made, if any. More info:
|
|
186
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
|
|
187
|
+
*/
|
|
188
|
+
resourceVersion?: string;
|
|
189
|
+
/**
|
|
190
|
+
* UID of the referent. More info:
|
|
191
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
|
|
192
|
+
*/
|
|
193
|
+
uid?: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Severity indicates policy severity
|
|
198
|
+
*/
|
|
199
|
+
export enum Severity {
|
|
200
|
+
High = "high",
|
|
201
|
+
Low = "low",
|
|
202
|
+
Medium = "medium",
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Status indicates the result of the policy rule check
|
|
207
|
+
*/
|
|
208
|
+
export enum Status {
|
|
209
|
+
Error = "error",
|
|
210
|
+
Fail = "fail",
|
|
211
|
+
Pass = "pass",
|
|
212
|
+
Skip = "skip",
|
|
213
|
+
Warn = "warn",
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Scope is an optional reference to the report scope (e.g. a Deployment, Namespace, or Node)
|
|
218
|
+
*/
|
|
219
|
+
export interface Scope {
|
|
220
|
+
/**
|
|
221
|
+
* API version of the referent.
|
|
222
|
+
*/
|
|
223
|
+
apiVersion?: string;
|
|
224
|
+
/**
|
|
225
|
+
* If referring to a piece of an object instead of an entire object, this string should
|
|
226
|
+
* contain a valid JSON/Go field access statement, such as
|
|
227
|
+
* desiredState.manifest.containers[2]. For example, if the object reference is to a
|
|
228
|
+
* container within a pod, this would take on a value like: "spec.containers{name}" (where
|
|
229
|
+
* "name" refers to the name of the container that triggered the event) or if no container
|
|
230
|
+
* name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax
|
|
231
|
+
* is chosen only to have some well-defined way of referencing a part of an object. TODO:
|
|
232
|
+
* this design is not final and this field is subject to change in the future.
|
|
233
|
+
*/
|
|
234
|
+
fieldPath?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Kind of the referent. More info:
|
|
237
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
|
238
|
+
*/
|
|
239
|
+
kind?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Name of the referent. More info:
|
|
242
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
|
243
|
+
*/
|
|
244
|
+
name?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Namespace of the referent. More info:
|
|
247
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
|
|
248
|
+
*/
|
|
249
|
+
namespace?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Specific resourceVersion to which this reference is made, if any. More info:
|
|
252
|
+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
|
|
253
|
+
*/
|
|
254
|
+
resourceVersion?: string;
|
|
255
|
+
/**
|
|
256
|
+
* UID of the referent. More info:
|
|
257
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
|
|
258
|
+
*/
|
|
259
|
+
uid?: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* ScopeSelector is an optional selector for multiple scopes (e.g. Pods). Either one of, or
|
|
264
|
+
* none of, but not both of, Scope or ScopeSelector should be specified.
|
|
265
|
+
*/
|
|
266
|
+
export interface ScopeSelector {
|
|
267
|
+
/**
|
|
268
|
+
* matchExpressions is a list of label selector requirements. The requirements are ANDed.
|
|
269
|
+
*/
|
|
270
|
+
matchExpressions?: ScopeSelectorMatchExpression[];
|
|
271
|
+
/**
|
|
272
|
+
* matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is
|
|
273
|
+
* equivalent to an element of matchExpressions, whose key field is "key", the operator is
|
|
274
|
+
* "In", and the values array contains only "value". The requirements are ANDed.
|
|
275
|
+
*/
|
|
276
|
+
matchLabels?: { [key: string]: string };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A label selector requirement is a selector that contains values, a key, and an operator
|
|
281
|
+
* that relates the key and values.
|
|
282
|
+
*/
|
|
283
|
+
export interface ScopeSelectorMatchExpression {
|
|
284
|
+
/**
|
|
285
|
+
* key is the label key that the selector applies to.
|
|
286
|
+
*/
|
|
287
|
+
key: string;
|
|
288
|
+
/**
|
|
289
|
+
* operator represents a key's relationship to a set of values. Valid operators are In,
|
|
290
|
+
* NotIn, Exists and DoesNotExist.
|
|
291
|
+
*/
|
|
292
|
+
operator: string;
|
|
293
|
+
/**
|
|
294
|
+
* values is an array of string values. If the operator is In or NotIn, the values array
|
|
295
|
+
* must be non-empty. If the operator is Exists or DoesNotExist, the values array must be
|
|
296
|
+
* empty. This array is replaced during a strategic merge patch.
|
|
297
|
+
*/
|
|
298
|
+
values?: string[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* PolicyReportSummary provides a summary of results
|
|
303
|
+
*/
|
|
304
|
+
export interface Summary {
|
|
305
|
+
/**
|
|
306
|
+
* Error provides the count of policies that could not be evaluated
|
|
307
|
+
*/
|
|
308
|
+
error?: number;
|
|
309
|
+
/**
|
|
310
|
+
* Fail provides the count of policies whose requirements were not met
|
|
311
|
+
*/
|
|
312
|
+
fail?: number;
|
|
313
|
+
/**
|
|
314
|
+
* Pass provides the count of policies whose requirements were met
|
|
315
|
+
*/
|
|
316
|
+
pass?: number;
|
|
317
|
+
/**
|
|
318
|
+
* Skip indicates the count of policies that were not selected for evaluation
|
|
319
|
+
*/
|
|
320
|
+
skip?: number;
|
|
321
|
+
/**
|
|
322
|
+
* Warn provides the count of unscored policies whose requirements were not met
|
|
323
|
+
*/
|
|
324
|
+
warn?: number;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
RegisterKind(PolicyReport, {
|
|
328
|
+
group: "wgpolicyk8s.io",
|
|
329
|
+
version: "v1alpha1",
|
|
330
|
+
kind: "PolicyReport",
|
|
331
|
+
plural: "policyreports",
|
|
332
|
+
});
|