This repository has been archived by the owner on Mar 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support manifest on riff system install
Fixes #648
- Loading branch information
Showing
12 changed files
with
290 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.1 | ||
istio: | ||
- https://storage.googleapis.com/riff-releases/istio/istio-1.0.0-riff-crds.yaml | ||
- https://storage.googleapis.com/riff-releases/istio/istio-1.0.0-riff-main.yaml | ||
knative: | ||
- https://storage.googleapis.com/knative-releases/serving/previous/v20180809-6b01d8e/release-no-mon.yaml | ||
- https://storage.googleapis.com/knative-releases/eventing/previous/v20180809-34ab480/release.yaml | ||
- https://storage.googleapis.com/knative-releases/eventing/previous/v20180809-34ab480/release-clusterbus-stub.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
version: 0.1 | ||
knative: | ||
- serving-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: 0.1 | ||
istio: | ||
- istio-crds | ||
- istio-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.1 | ||
istio: | ||
- istio-crds | ||
- istio-release | ||
knative: | ||
- serving-release | ||
- eventing-release | ||
- stub-bus-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version: 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2018 The original author or authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package core | ||
|
||
import ( | ||
"fmt" | ||
"gopkg.in/yaml.v2" | ||
"io/ioutil" | ||
) | ||
|
||
const MANIFEST_VERSION = "0.1" | ||
|
||
// Manifest defines the location of YAML files for system components. | ||
type Manifest struct { | ||
Version string | ||
Istio []string | ||
Knative []string | ||
} | ||
|
||
func NewManifest(path string) (*Manifest, error) { | ||
var m Manifest | ||
yamlFile, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error reading manifest file: %v", err) | ||
} | ||
|
||
err = yaml.Unmarshal(yamlFile, &m) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error parsing manifest file: %v", err) | ||
} | ||
|
||
if m.Version != MANIFEST_VERSION { | ||
return nil, fmt.Errorf("Manifest has unsupported version: %s", m.Version) | ||
} | ||
|
||
if m.Istio == nil || | ||
m.Knative == nil { | ||
return nil, fmt.Errorf("Manifest is incomplete: %#v", m) | ||
} | ||
|
||
return &m, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2018 The original author or authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package core_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/projectriff/riff/pkg/core" | ||
) | ||
|
||
var _ = Describe("Manifest", func() { | ||
Describe("NewManifest", func() { | ||
|
||
var ( | ||
manifestPath string | ||
manifest *core.Manifest | ||
err error | ||
) | ||
|
||
JustBeforeEach(func() { | ||
manifest, err = core.NewManifest(manifestPath) | ||
}) | ||
|
||
Context("when an invalid path is provided", func() { | ||
BeforeEach(func() { | ||
manifestPath = "" | ||
}) | ||
|
||
It("should return a suitable error", func() { | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(HavePrefix("Error reading manifest file:")) | ||
}) | ||
}) | ||
|
||
Context("when the file contains invalid YAML", func() { | ||
BeforeEach(func() { | ||
manifestPath = "./fixtures/invalid.yaml" | ||
}) | ||
|
||
It("should return a suitable error", func() { | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(HavePrefix("Error parsing manifest file:")) | ||
}) | ||
}) | ||
|
||
Context("when the manifest has the wrong version", func() { | ||
BeforeEach(func() { | ||
manifestPath = "./fixtures/wrongversion.yaml" | ||
}) | ||
|
||
It("should return a suitable error", func() { | ||
Expect(err).To(MatchError("Manifest has unsupported version: 0.0")) | ||
}) | ||
}) | ||
|
||
Context("when the manifest does not specify the istio array", func() { | ||
BeforeEach(func() { | ||
manifestPath = "./fixtures/noistio.yaml" | ||
}) | ||
|
||
It("should return a suitable error", func() { | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(HavePrefix("Manifest is incomplete:")) | ||
}) | ||
}) | ||
|
||
Context("when the manifest does not specify the knative array", func() { | ||
BeforeEach(func() { | ||
manifestPath = "./fixtures/noknative.yaml" | ||
}) | ||
|
||
It("should return a suitable error", func() { | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(HavePrefix("Manifest is incomplete:")) | ||
}) | ||
}) | ||
|
||
Context("when the manifest is valid", func() { | ||
BeforeEach(func() { | ||
manifestPath = "./fixtures/valid.yaml" | ||
}) | ||
|
||
It("should return with no error", func() { | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("should parse the istio array", func() { | ||
Expect(manifest.Istio).To(ConsistOf("istio-crds", "istio-release")) | ||
}) | ||
|
||
It("should parse the Knative array", func() { | ||
Expect(manifest.Knative).To(ConsistOf("serving-release", "eventing-release", "stub-bus-release")) | ||
}) | ||
}) | ||
}) | ||
|
||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.