Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state and status to list installation #2171

Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e9e87b0
Use user specified directory for resolving file path (#2142)
VinozzZ Jun 10, 2022
7faa23f
Update to helm3 mixin v0.1.16
carolynvs Jun 9, 2022
4b40a1d
Sanitize archive folder name (#2154)
VinozzZ Jun 15, 2022
c8f3279
Adding pagination for installation, parameter, and credential list re…
joshuabezaleel Jun 15, 2022
0443a86
Add state and status to list installation
joshuabezaleel Jun 18, 2022
a9d285d
fix archive folder test
VinozzZ Jun 16, 2022
6015462
Fix Vet Errors (#2153)
tchaudhry91 Jun 16, 2022
22917e6
Improve error message loading wrong schema (#2157)
kevinbarbour Jun 16, 2022
3e2700d
Add prow github action
carolynvs Jun 16, 2022
94a67e3
Switch prow to use pull_request instead of _target
carolynvs Jun 16, 2022
ca4fc28
Updated installation schema with correct dependency schema
Jun 16, 2022
6338fc7
changed new manifest description for test
Jun 16, 2022
52bf273
Update k8s and containerd dependencies
carolynvs Jun 9, 2022
e96235a
Add comments
joshuabezaleel Jun 18, 2022
4062b1a
StateDefined as default value
joshuabezaleel Jun 23, 2022
ba643f3
Move displayinstallation's state and status to metadata
joshuabezaleel Jun 23, 2022
d58cab0
Add golden file test for print installation
joshuabezaleel Jun 23, 2022
62314c7
Add unit test for displayInstallation's state and status
joshuabezaleel Jun 23, 2022
d4b61f3
Change function name from set to get
joshuabezaleel Jun 23, 2022
9ede1cd
Revert changes on test file
joshuabezaleel Jun 23, 2022
8f3a3d4
resolve conflict
joshuabezaleel Jun 23, 2022
2c92630
add new line
joshuabezaleel Jun 23, 2022
b60a7a7
resolve conflict
joshuabezaleel Jun 23, 2022
8ea1073
fix comment
joshuabezaleel Jun 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated installation schema with correct dependency schema
Signed-off-by: Steven Gettys <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
Steven Gettys authored and joshuabezaleel committed Jun 23, 2022
commit ca4fc28093a2cb205ec8c0819db06ed4a8c68234
63 changes: 35 additions & 28 deletions pkg/porter/schema_test.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package porter

import (
"context"
"fmt"
"io/ioutil"
"testing"

@@ -23,33 +24,39 @@ func TestPorter_PrintManifestSchema(t *testing.T) {
}

func TestPorter_ValidateManifestSchema(t *testing.T) {
ctx := context.Background()
p := NewTestPorter(t)
defer p.Close()

// Load the default Porter manifest
b, err := ioutil.ReadFile("testdata/porter.yaml")
require.NoError(t, err)

// Load the manifest as a go dump
m := make(map[string]interface{})
err = yaml.Unmarshal(b, &m)
require.NoError(t, err)
manifestLoader := gojsonschema.NewGoLoader(m)

// Load the manifest schema
err = p.PrintManifestSchema(ctx)
require.NoError(t, err, "could not generate schema")
schema := p.TestConfig.TestContext.GetOutput()
schemaLoader := gojsonschema.NewStringLoader(schema)

// Validate the manifest against the schema
fails, err := gojsonschema.Validate(schemaLoader, manifestLoader)
require.NoError(t, err)

assert.Empty(t, fails.Errors(), "expected testdata/porter.yaml to validate against the porter schema")
// Print it pretty like
for _, err := range fails.Errors() {
t.Logf("%s", err)
manifests := []string{"testdata/porter.yaml", "testdata/porter-with-dependencies.yaml"}
for _, m := range manifests {
t.Run(fmt.Sprintf("Manifest %s", m), func(t *testing.T) {

ctx := context.Background()
p := NewTestPorter(t)
defer p.Close()

// Load the default Porter manifest
b, err := ioutil.ReadFile(m)
require.NoError(t, err)

// Load the manifest as a go dump
m := make(map[string]interface{})
err = yaml.Unmarshal(b, &m)
require.NoError(t, err)
manifestLoader := gojsonschema.NewGoLoader(m)

// Load the manifest schema
err = p.PrintManifestSchema(ctx)
require.NoError(t, err, "could not generate schema")
schema := p.TestConfig.TestContext.GetOutput()
schemaLoader := gojsonschema.NewStringLoader(schema)

// Validate the manifest against the schema
fails, err := gojsonschema.Validate(schemaLoader, manifestLoader)
require.NoError(t, err)

assert.Empty(t, fails.Errors(), "expected testdata/porter.yaml to validate against the porter schema")
// Print it pretty like
for _, err := range fails.Errors() {
t.Logf("%s", err)
}
})
}
}
90 changes: 90 additions & 0 deletions pkg/porter/testdata/porter-with-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
schemaVersion: 1.0.0-alpha.1
name: porter-hello
version: 0.1.0
description: "A bundle with a custom action"
registry: "localhost:5000"

custom:
customKey1: "customValue1"

credentials:
- name: my-first-cred
env: MY_FIRST_CRED
- name: my-second-cred
description: "My second cred"
path: /path/to/my-second-cred

images:
something:
description: "an image"
imageType: "docker"
repository: "getporter/boo"

dependencies:
requires:
- name: some-dep
bundle:
reference: some-repo
version: ">1.0"
parameters:
param1: first-param

parameters:
- name: my-first-param
type: integer
default: 9
env: MY_FIRST_PARAM
applyTo:
- "install"
- name: my-second-param
description: "My second parameter"
type: string
default: spring-music-demo
path: /path/to/my-second-param
sensitive: true

outputs:
- name: my-first-output
type: string
applyTo:
- "install"
- "upgrade"
sensitive: true
- name: my-second-output
description: "My second output"
type: boolean
sensitive: false
- name: kubeconfig
type: file
path: /home/nonroot/.kube/config

mixins:
- exec

install:
- exec:
description: "Install Hello World with custom arguments"
command: echo
arguments:
- "{{ bundle.custom.customKey1 }}"

upgrade:
- exec:
description: "World 2.0"
command: bash
flags:
c: echo World 2.0

zombies:
- exec:
description: "Trigger zombie apocalypse"
command: bash
flags:
c: echo oh noes my brains

uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
flags:
c: echo Goodbye World
25 changes: 21 additions & 4 deletions pkg/porter/testdata/schema.json
Original file line number Diff line number Diff line change
@@ -19,6 +19,23 @@
},
"type": "array"
},
"bundle": {
"description": "The defintion of a bundle reference",
"properties": {
"reference": {
"description": "The full bundle reference for the dependency in the format REGISTRY/NAME:TAG",
"type": "string"
},
"version": {
"description": "Bundle version contstraint for version matching, see https://github.com/Masterminds/semver/blob/master/README.md#checking-version-constraints",
"type": "string"
}
},
"required": [
"reference"
],
"type": "object"
},
"credential": {
"description": "Credential defines a particular credential, and where it should be placed in the invocation image",
"properties": {
@@ -72,19 +89,19 @@
"dependency": {
"additionalProperties": false,
"properties": {
"bundle": {
"$ref": "#/definitions/bundle"
},
"name": {
"type": "string"
},
"parameters": {
"type": "object"
},
"reference": {
"type": "string"
}
},
"required": [
"name",
"reference"
"bundle"
],
"type": "object"
},
23 changes: 20 additions & 3 deletions pkg/schema/manifest.schema.json
Original file line number Diff line number Diff line change
@@ -170,15 +170,32 @@
"name": {
"type": "string"
},
"reference": {
"type": "string"
"bundle": {
"$ref": "#/definitions/bundle"
},
"parameters": {
"type": "object"
}
},
"required": [
"name",
"bundle"
],
"type": "object"
},
"bundle": {
"description": "The defintion of a bundle reference",
"properties": {
"reference": {
"description": "The full bundle reference for the dependency in the format REGISTRY/NAME:TAG",
"type": "string"
},
"version": {
"description": "Bundle version contstraint for version matching, see https://github.com/Masterminds/semver/blob/master/README.md#checking-version-constraints",
"type": "string"
}
},
"required": [
"reference"
],
"type": "object"
@@ -436,4 +453,4 @@
"upgrade",
"uninstall"
]
}
}