diff --git a/.codecov.yaml b/.codecov.yaml new file mode 100644 index 00000000..8739c455 --- /dev/null +++ b/.codecov.yaml @@ -0,0 +1,40 @@ +# See http://docs.codecov.io/docs/coverage-configuration +coverage: + precision: 2 # 2 = xx.xx%, 0 = xx% + round: down + # For example: 20...60 would result in any coverage less than 20% + # would have a red background. The color would gradually change to + # green approaching 60%. Any coverage over 60% would result in a + # solid green color. + range: "20...60" + + status: + # project will give us the diff in the total code coverage between a commit + # and its parent + project: yes + # Patch gives just the coverage of the patch + patch: yes + # changes tells us if there are unexpected code coverage changes in other files + # which were not changed by the diff + changes: yes + + # See http://docs.codecov.io/docs/ignoring-paths + ignore: + - "assets/*" + - "build/*" + - "deploy/*" + - "hack/*" + - "manifests/*" + - "openshift-ci/*" + - "vendor/*" + - "Makefile" + - ".travis.yml" + +# See http://docs.codecov.io/docs/pull-request-comments-1 +comment: + layout: "diff, files" + behavior: "" + # default = posts once then update, posts new if delete + # once = post once then updates + # new = delete old, post new + # spammy = post new diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..0e508192 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,21 @@ +name: Code Coverage Report +on: + push: + branches: + - main +jobs: + build-and-deploy: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2.3.1 + with: + persist-credentials: false + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Run tests + run: make test + - name: Codecov + uses: codecov/codecov-action@v2.1.0 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d771ae41..7dbb94cf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,7 +16,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v2.1.3 with: - go-version: 1.15 + go-version: 1.16 id: go - name: Check out code into the Go module directory @@ -43,11 +43,20 @@ jobs: exit 1 fi + - name: Check license + run: | + go get github.com/google/addlicense@latest + git reset HEAD --hard + make check_license + if [[ $? != 0 ]] + then + echo "not well formatted sources are found:" + git --no-pager diff + exit 1 + fi + - name: Run Go Tests run: make test - - - name: Upload Test Coverage results - uses: actions/upload-artifact@v2 - with: - name: lib-test-coverage-html - path: tests/v2/lib-test-coverage.html \ No newline at end of file + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2.1.0 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5629c1a6..3701ac6f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,13 @@ This document is a new contributor guide, which outlines the requirements for co To get an overview of the project, read the [README](README.md). For more information on devfiles, check the official [devfile docs](https://devfile.io/docs/devfile/2.1.0/user-guide/). +## Certificate of Origin + +By contributing to this project you agree to the Developer Certificate of +Origin (DCO). This document was created by the Linux Kernel community and is a +simple statement that you, as a contributor, have the legal right to make the +contribution. See the [DCO](./DCO) file for details. + ## Prerequisites The following are required to work on devfile library: diff --git a/DCO b/DCO new file mode 100644 index 00000000..8201f992 --- /dev/null +++ b/DCO @@ -0,0 +1,37 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff --git a/Makefile b/Makefile index f0f2dc0f..4e8ba2b6 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,29 @@ bin: .PHONY: test test: - go test -coverprofile tests/v2/lib-test-coverage.out -v ./... - go tool cover -html=tests/v2/lib-test-coverage.out -o tests/v2/lib-test-coverage.html + go test -coverprofile cover.out -v ./... .PHONY: clean clean: @rm -rf $(FILES) +### fmt_license: ensure license header is set on all files +fmt_license: +ifneq ($(shell command -v addlicense 2> /dev/null),) + @echo 'addlicense -v -f license_header.txt **/*.go' + @addlicense -v -f license_header.txt $$(find . -name '*.go') +else + $(error addlicense must be installed for this rule: go get -u github.com/google/addlicense) +endif + +### check_fmt: Checks for missing licenses on files in repo +check_license: + ifeq ($(shell command -v addlicense 2> /dev/null),) + $(error "error addlicense must be installed for this rule: go get -u github.com/google/addlicense") + endif + + if ! addlicense -check -f license_header.txt $$(find . -not -path '*/\.*' -name '*.go'); then \ + echo "Licenses are not formatted; run 'make fmt_license'"; exit 1 ;\ + fi \ + + diff --git a/README.md b/README.md index 8d3c43b2..184cd0ae 100644 --- a/README.md +++ b/README.md @@ -20,20 +20,33 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g ```go // ParserArgs is the struct to pass into parser functions which contains required info for parsing devfile. parserArgs := parser.ParserArgs{ - Path: path, - FlattenedDevfile: &flattenedDevfile, - RegistryURLs: registryURLs, - DefaultNamespace: defaultNamespace, - Context: context, - K8sClient: client, + Path: path, + FlattenedDevfile: &flattenedDevfile, + ConvertKubernetesContentInUri: &convertKubernetesContentInUri + RegistryURLs: registryURLs, + DefaultNamespace: defaultNamespace, + Context: context, + K8sClient: client, + ExternalVariables: externalVariables, } // Parses the devfile and validates the devfile data // if top-level variables are not substituted successfully, the warnings can be logged by parsing variableWarning devfile, variableWarning, err := devfilePkg.ParseDevfileAndValidate(parserArgs) ``` + + +2. To override the HTTP request and response timeouts for a devfile with a parent reference from a registry URL, specify the HTTPTimeout value in the parser arguments + ```go + // specify the timeout in seconds + httpTimeout := 20 + parserArgs := parser.ParserArgs{ + HTTPTimeout: &httpTimeout + } + ``` + -2. To get specific content from devfile +3. To get specific content from devfile ```go // To get all the components from the devfile components, err := devfile.Data.GetComponents(DevfileOptions{}) @@ -65,7 +78,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g }) ``` -3. To get the Kubernetes objects from the devfile, visit [generators.go source file](pkg/devfile/generator/generators.go) +4. To get the Kubernetes objects from the devfile, visit [generators.go source file](pkg/devfile/generator/generators.go) ```go // To get a slice of Kubernetes containers of type corev1.Container from the devfile component containers containers, err := generator.GetContainers(devfile) @@ -82,7 +95,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g deployment := generator.GetDeployment(deployParams) ``` -4. To update devfile content +5. To update devfile content ```go // To update an existing component in devfile object err := devfile.Data.UpdateComponent(v1.Component{ @@ -114,7 +127,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g err := devfile.Data.DeleteComponent(componentName) ``` -5. To write to a devfile, visit [writer.go source file](pkg/devfile/parser/writer.go) +6. To write to a devfile, visit [writer.go source file](pkg/devfile/parser/writer.go) ```go // If the devfile object has been created with devfile path already set, can simply call WriteYamlDevfile to writes the devfile err := devfile.WriteYamlDevfile() @@ -145,7 +158,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g // write to the devfile on disk err = devfile.WriteYamlDevfile() ``` -6. To parse the outerloop Kubernetes/OpenShift component's uri or inline content, call the read and parse functions +7. To parse the outerloop Kubernetes/OpenShift component's uri or inline content, call the read and parse functions ```go // Read the YAML content values, err := ReadKubernetesYaml(src, fs) @@ -154,6 +167,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g resources, err := ParseKubernetesYaml(values) ``` + ## Projects using devfile/library The following projects are consuming this library as a Golang dependency @@ -176,3 +190,6 @@ Issues are tracked in the [devfile/api](https://github.com/devfile/api) repo wit For devfile/library releases, please check the release [page](https://github.com/devfile/library/releases). +## Contributing + +Please see our [contributing.md](./CONTRIBUTING.md). diff --git a/devfile.yaml b/devfile.yaml index b08f18de..b683cd0e 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -1,121 +1,106 @@ +schemaVersion: 2.2.0-latest +metadata: + name: nodejs + version: 1.0.0 + attributes: + alpha.build-dockerfile: /relative/path/to/Dockerfile +variables: + test: testValue +parent: + # uri: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml + id: nodejs + registryUrl: "https://registry.devfile.io" + version: latest + commands: + - id: install + exec: + component: runtime + commandLine: npm install + workingDir: /project-starter + group: + kind: build + isDefault: true +starterProjects: + - name: nodejs-starter2 + git: + remotes: + origin: https://github.com/odo-devfiles/nodejs-ex.git components: - - kubernetes: + - name: runtime2 + attributes: + tool: console-import + import: + strategy: Dockerfile + container: endpoints: - - name: jsct05850 - secure: false - targetPort: 4061 - - exposure: internal - name: fttrf05851 - secure: false - targetPort: 2794 - - name: pediv05852 - path: /Path_GpjjJ - secure: false - targetPort: 4061 - - name: w05853 - protocol: tcp - secure: false - targetPort: 4061 - - name: ve05854 - path: /Path_rUnibQXIL - secure: true - targetPort: 4061 - name: sxi05849 - - kubernetes: + - name: http-8888 + targetPort: 8888 + image: registry.access.redhat.com/ubi8/nodejs-12:1-45 + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + command: + - npm install + - name: runtime3 + attributes: + tool: odo + cli: + usage: deploy + container: endpoints: - - name: bj05856 - path: /Path_QEqKHLrqVSS - secure: false - targetPort: 1985 - - exposure: internal - name: udbeo05857 - secure: true - targetPort: 1985 - - exposure: internal - name: yol05858 - protocol: wss - secure: false - targetPort: 1985 - name: lsk05855 - - kubernetes: {} - name: shf05859 - - kubernetes: + - name: http-8080 + targetPort: 8080 + image: registry.access.redhat.com/ubi8/nodejs-12:1-45 + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + - name: runtime4 + attributes: + tool: workspace-operator + container: endpoints: - - name: grmex05861 - protocol: tcp - secure: true - targetPort: 429 - - name: ork05862 - path: /Path_MofEhbd - protocol: wss - secure: false - targetPort: 3214 - name: zrk05860 - - kubernetes: {} - name: igh05863 - - kubernetes: - endpoints: - - name: emf05865 - path: /Path_ZkPBw - protocol: wss - secure: true - targetPort: 970 - - name: wqnaf05866 - path: /Path_UpxBmbMJDr - secure: true - targetPort: 1863 - - exposure: internal - name: rbk05867 - path: /Path_TTlXWYESKJwelJ - protocol: udp - secure: true - targetPort: 2706 - - exposure: none - name: zjiv05868 - path: /Path_JUQlS - protocol: udp - secure: true - targetPort: 970 - name: ecw05864 - - kubernetes: - endpoints: - - exposure: none - name: i05870 - protocol: tcp - secure: true - targetPort: 565 - - name: yln05871 - protocol: https - secure: true - targetPort: 4386 - - name: qyrrk05872 - path: /Path_gtsayNeeuFJ - secure: false - targetPort: 3546 - - exposure: none - name: vv05873 - secure: false - targetPort: 2295 - - name: dat05874 - path: /Path_kWxdWGLbCmZYf - protocol: wss - secure: false - targetPort: 2474 - name: lgv05869 - - kubernetes: - endpoints: - - name: koac05876 - secure: false - targetPort: 4318 - - name: lelw05877 - path: /Path_EhnGCYPmFHrZPA - protocol: ws - secure: true - targetPort: 592 - - name: j05878 - protocol: tcp - secure: false - targetPort: 4318 - name: qcu05875 -metadata: {} -schemaVersion: 2.2.0 + - name: http-9090 + targetPort: 9090 + image: "{{invalid-var}}" + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project +commands: + - exec: + commandLine: npm install + component: runtime2 + group: + isDefault: false + kind: build + workingDir: "{{test}}" + id: install2 + attributes: + tool: odo + mandatory: false + - exec: + commandLine: npm start + component: runtime2 + group: + isDefault: false + kind: run + workingDir: /project + id: run2 + attributes: + tool: odo + mandatory: true + - exec: + commandLine: npm run debug + component: runtime2 + group: + isDefault: false + kind: debug + workingDir: /project + id: debug2 + - exec: + commandLine: npm test + component: runtime2 + group: + isDefault: false + kind: test + workingDir: /project + id: test2 diff --git a/license_header.txt b/license_header.txt new file mode 100644 index 00000000..8380e327 --- /dev/null +++ b/license_header.txt @@ -0,0 +1,14 @@ + +Copyright 2022 Red Hat, Inc. + +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. \ No newline at end of file diff --git a/main.go b/main.go index 5e4eb54e..3e64e97e 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 main import ( diff --git a/pkg/devfile/generator/generators.go b/pkg/devfile/generator/generators.go index f5767d2d..69b42002 100644 --- a/pkg/devfile/generator/generators.go +++ b/pkg/devfile/generator/generators.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 generator import ( diff --git a/pkg/devfile/generator/generators_test.go b/pkg/devfile/generator/generators_test.go index 49b1b31a..c6e3ee6c 100644 --- a/pkg/devfile/generator/generators_test.go +++ b/pkg/devfile/generator/generators_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 generator import ( diff --git a/pkg/devfile/generator/utils.go b/pkg/devfile/generator/utils.go index 35af3243..c903b708 100644 --- a/pkg/devfile/generator/utils.go +++ b/pkg/devfile/generator/utils.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 generator import ( diff --git a/pkg/devfile/generator/utils_test.go b/pkg/devfile/generator/utils_test.go index 575ecc4a..7870ba9c 100644 --- a/pkg/devfile/generator/utils_test.go +++ b/pkg/devfile/generator/utils_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 generator import ( diff --git a/pkg/devfile/parse.go b/pkg/devfile/parse.go index 64c2890a..ad67c8fd 100644 --- a/pkg/devfile/parse.go +++ b/pkg/devfile/parse.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 devfile import ( diff --git a/pkg/devfile/parse_test.go b/pkg/devfile/parse_test.go index 7c3efed5..43b679a6 100644 --- a/pkg/devfile/parse_test.go +++ b/pkg/devfile/parse_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 devfile import ( diff --git a/pkg/devfile/parser/configurables.go b/pkg/devfile/parser/configurables.go index e05b4646..ffe426c3 100644 --- a/pkg/devfile/parser/configurables.go +++ b/pkg/devfile/parser/configurables.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/apiVersion.go b/pkg/devfile/parser/context/apiVersion.go index e07d706d..e5bb6235 100644 --- a/pkg/devfile/parser/context/apiVersion.go +++ b/pkg/devfile/parser/context/apiVersion.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/apiVersion_test.go b/pkg/devfile/parser/context/apiVersion_test.go index f294ee2f..282f1fcc 100644 --- a/pkg/devfile/parser/context/apiVersion_test.go +++ b/pkg/devfile/parser/context/apiVersion_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/content.go b/pkg/devfile/parser/context/content.go index a4a4ddf1..712136d7 100644 --- a/pkg/devfile/parser/context/content.go +++ b/pkg/devfile/parser/context/content.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/content_test.go b/pkg/devfile/parser/context/content_test.go index 004ce49b..a2b209dd 100644 --- a/pkg/devfile/parser/context/content_test.go +++ b/pkg/devfile/parser/context/content_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/context.go b/pkg/devfile/parser/context/context.go index 92c27f00..7cc8c794 100644 --- a/pkg/devfile/parser/context/context.go +++ b/pkg/devfile/parser/context/context.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/context_test.go b/pkg/devfile/parser/context/context_test.go index 02eb88f5..9fe14cd9 100644 --- a/pkg/devfile/parser/context/context_test.go +++ b/pkg/devfile/parser/context/context_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/fakecontext.go b/pkg/devfile/parser/context/fakecontext.go index 2db3c1bd..2580433b 100644 --- a/pkg/devfile/parser/context/fakecontext.go +++ b/pkg/devfile/parser/context/fakecontext.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import "github.com/devfile/library/pkg/testingutil/filesystem" diff --git a/pkg/devfile/parser/context/fs.go b/pkg/devfile/parser/context/fs.go index d3992483..b8e45aa3 100644 --- a/pkg/devfile/parser/context/fs.go +++ b/pkg/devfile/parser/context/fs.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import "github.com/devfile/library/pkg/testingutil/filesystem" diff --git a/pkg/devfile/parser/context/schema.go b/pkg/devfile/parser/context/schema.go index 13326e96..f35c3ba2 100644 --- a/pkg/devfile/parser/context/schema.go +++ b/pkg/devfile/parser/context/schema.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/context/schema_test.go b/pkg/devfile/parser/context/schema_test.go index 3d0710fb..f6289435 100644 --- a/pkg/devfile/parser/context/schema_test.go +++ b/pkg/devfile/parser/context/schema_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/data/helper.go b/pkg/devfile/parser/data/helper.go index 190acbc2..7ce98456 100644 --- a/pkg/devfile/parser/data/helper.go +++ b/pkg/devfile/parser/data/helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 data import ( diff --git a/pkg/devfile/parser/data/helper_test.go b/pkg/devfile/parser/data/helper_test.go index e35de0be..e45807c8 100644 --- a/pkg/devfile/parser/data/helper_test.go +++ b/pkg/devfile/parser/data/helper_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 data import ( diff --git a/pkg/devfile/parser/data/interface.go b/pkg/devfile/parser/data/interface.go index 743077e8..e4987ba8 100644 --- a/pkg/devfile/parser/data/interface.go +++ b/pkg/devfile/parser/data/interface.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 data import ( diff --git a/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go b/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go index b4c2cd50..431d5fc0 100644 --- a/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go +++ b/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 version200 // https://raw.githubusercontent.com/devfile/api/2.0.x/schemas/latest/devfile.json diff --git a/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go b/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go index 7145fd0b..c92b7a75 100644 --- a/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go +++ b/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 version210 // https://raw.githubusercontent.com/devfile/api/2.1.x/schemas/latest/devfile.json diff --git a/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go b/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go index 1fa44489..f485c744 100644 --- a/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go +++ b/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 version220 // https://raw.githubusercontent.com/devfile/api/main/schemas/latest/devfile.json diff --git a/pkg/devfile/parser/data/v2/attributes.go b/pkg/devfile/parser/data/v2/attributes.go index d241a1b5..6d7ba88a 100644 --- a/pkg/devfile/parser/data/v2/attributes.go +++ b/pkg/devfile/parser/data/v2/attributes.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/attributes_test.go b/pkg/devfile/parser/data/v2/attributes_test.go index e918fff8..c869d849 100644 --- a/pkg/devfile/parser/data/v2/attributes_test.go +++ b/pkg/devfile/parser/data/v2/attributes_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/commands.go b/pkg/devfile/parser/data/v2/commands.go index 8b45991f..3642384a 100644 --- a/pkg/devfile/parser/data/v2/commands.go +++ b/pkg/devfile/parser/data/v2/commands.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/commands_test.go b/pkg/devfile/parser/data/v2/commands_test.go index ebf70df2..754ce34e 100644 --- a/pkg/devfile/parser/data/v2/commands_test.go +++ b/pkg/devfile/parser/data/v2/commands_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/common/command_helper.go b/pkg/devfile/parser/data/v2/common/command_helper.go index b3bf8a0a..f4a5cabf 100644 --- a/pkg/devfile/parser/data/v2/common/command_helper.go +++ b/pkg/devfile/parser/data/v2/common/command_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/command_helper_test.go b/pkg/devfile/parser/data/v2/common/command_helper_test.go index 4f54cf3d..8be31489 100644 --- a/pkg/devfile/parser/data/v2/common/command_helper_test.go +++ b/pkg/devfile/parser/data/v2/common/command_helper_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/component_helper.go b/pkg/devfile/parser/data/v2/common/component_helper.go index 1a5ba332..fdb34371 100644 --- a/pkg/devfile/parser/data/v2/common/component_helper.go +++ b/pkg/devfile/parser/data/v2/common/component_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/component_helper_test.go b/pkg/devfile/parser/data/v2/common/component_helper_test.go index a2e7a0b3..f60bf2e8 100644 --- a/pkg/devfile/parser/data/v2/common/component_helper_test.go +++ b/pkg/devfile/parser/data/v2/common/component_helper_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/errors.go b/pkg/devfile/parser/data/v2/common/errors.go index ed5050ee..fd192d3d 100644 --- a/pkg/devfile/parser/data/v2/common/errors.go +++ b/pkg/devfile/parser/data/v2/common/errors.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import "fmt" diff --git a/pkg/devfile/parser/data/v2/common/options.go b/pkg/devfile/parser/data/v2/common/options.go index 64c93219..4817788e 100644 --- a/pkg/devfile/parser/data/v2/common/options.go +++ b/pkg/devfile/parser/data/v2/common/options.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/options_test.go b/pkg/devfile/parser/data/v2/common/options_test.go index 0b8451e4..1a35c057 100644 --- a/pkg/devfile/parser/data/v2/common/options_test.go +++ b/pkg/devfile/parser/data/v2/common/options_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/project_helper.go b/pkg/devfile/parser/data/v2/common/project_helper.go index b8df56e7..13291a87 100644 --- a/pkg/devfile/parser/data/v2/common/project_helper.go +++ b/pkg/devfile/parser/data/v2/common/project_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/common/project_helper_test.go b/pkg/devfile/parser/data/v2/common/project_helper_test.go index fe92cd23..cf1828af 100644 --- a/pkg/devfile/parser/data/v2/common/project_helper_test.go +++ b/pkg/devfile/parser/data/v2/common/project_helper_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 common import ( diff --git a/pkg/devfile/parser/data/v2/components.go b/pkg/devfile/parser/data/v2/components.go index 6b88034f..5fcc93ef 100644 --- a/pkg/devfile/parser/data/v2/components.go +++ b/pkg/devfile/parser/data/v2/components.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/components_test.go b/pkg/devfile/parser/data/v2/components_test.go index c0480b15..6e706663 100644 --- a/pkg/devfile/parser/data/v2/components_test.go +++ b/pkg/devfile/parser/data/v2/components_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/containers.go b/pkg/devfile/parser/data/v2/containers.go index 7671f180..e0ba9765 100644 --- a/pkg/devfile/parser/data/v2/containers.go +++ b/pkg/devfile/parser/data/v2/containers.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/containers_test.go b/pkg/devfile/parser/data/v2/containers_test.go index 5f79e23b..067d347c 100644 --- a/pkg/devfile/parser/data/v2/containers_test.go +++ b/pkg/devfile/parser/data/v2/containers_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/events.go b/pkg/devfile/parser/data/v2/events.go index 15c88b00..9565a0b7 100644 --- a/pkg/devfile/parser/data/v2/events.go +++ b/pkg/devfile/parser/data/v2/events.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/events_test.go b/pkg/devfile/parser/data/v2/events_test.go index d60b940a..5227f2a9 100644 --- a/pkg/devfile/parser/data/v2/events_test.go +++ b/pkg/devfile/parser/data/v2/events_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/header.go b/pkg/devfile/parser/data/v2/header.go index b005fd44..5bc4854b 100644 --- a/pkg/devfile/parser/data/v2/header.go +++ b/pkg/devfile/parser/data/v2/header.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/header_test.go b/pkg/devfile/parser/data/v2/header_test.go index 19fc6ecb..c04ba630 100644 --- a/pkg/devfile/parser/data/v2/header_test.go +++ b/pkg/devfile/parser/data/v2/header_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/parent.go b/pkg/devfile/parser/data/v2/parent.go index 75df021a..932f9323 100644 --- a/pkg/devfile/parser/data/v2/parent.go +++ b/pkg/devfile/parser/data/v2/parent.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/parent_test.go b/pkg/devfile/parser/data/v2/parent_test.go index 171cb9e3..3dc0efad 100644 --- a/pkg/devfile/parser/data/v2/parent_test.go +++ b/pkg/devfile/parser/data/v2/parent_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/projects.go b/pkg/devfile/parser/data/v2/projects.go index 714ed5be..c30d2903 100644 --- a/pkg/devfile/parser/data/v2/projects.go +++ b/pkg/devfile/parser/data/v2/projects.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/projects_test.go b/pkg/devfile/parser/data/v2/projects_test.go index 683181a9..276ee128 100644 --- a/pkg/devfile/parser/data/v2/projects_test.go +++ b/pkg/devfile/parser/data/v2/projects_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/types.go b/pkg/devfile/parser/data/v2/types.go index 7a8505ba..c35b0d7e 100644 --- a/pkg/devfile/parser/data/v2/types.go +++ b/pkg/devfile/parser/data/v2/types.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/volumes.go b/pkg/devfile/parser/data/v2/volumes.go index 37a29fc7..45724982 100644 --- a/pkg/devfile/parser/data/v2/volumes.go +++ b/pkg/devfile/parser/data/v2/volumes.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/volumes_test.go b/pkg/devfile/parser/data/v2/volumes_test.go index 9f0e84c5..c1e6b9e2 100644 --- a/pkg/devfile/parser/data/v2/volumes_test.go +++ b/pkg/devfile/parser/data/v2/volumes_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/workspace.go b/pkg/devfile/parser/data/v2/workspace.go index 6cf94d56..a1793e1a 100644 --- a/pkg/devfile/parser/data/v2/workspace.go +++ b/pkg/devfile/parser/data/v2/workspace.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/v2/workspace_test.go b/pkg/devfile/parser/data/v2/workspace_test.go index 52f88d00..07525882 100644 --- a/pkg/devfile/parser/data/v2/workspace_test.go +++ b/pkg/devfile/parser/data/v2/workspace_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 v2 import ( diff --git a/pkg/devfile/parser/data/versions.go b/pkg/devfile/parser/data/versions.go index e85a026e..0229416a 100644 --- a/pkg/devfile/parser/data/versions.go +++ b/pkg/devfile/parser/data/versions.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 data import ( diff --git a/pkg/devfile/parser/devfileobj.go b/pkg/devfile/parser/devfileobj.go index cb076493..14bc84f2 100644 --- a/pkg/devfile/parser/devfileobj.go +++ b/pkg/devfile/parser/devfileobj.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/parse.go b/pkg/devfile/parser/parse.go index 9b8e204f..0800c92d 100644 --- a/pkg/devfile/parser/parse.go +++ b/pkg/devfile/parser/parse.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( @@ -12,17 +27,15 @@ import ( "path" "strings" - "github.com/devfile/library/pkg/util" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/tools/clientcmd" - "sigs.k8s.io/controller-runtime/pkg/client" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" "github.com/devfile/library/pkg/devfile/parser/data" "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/pkg/util" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/clientcmd" "k8s.io/klog" - "reflect" + "sigs.k8s.io/controller-runtime/pkg/client" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" apiOverride "github.com/devfile/api/v2/pkg/utils/overriding" @@ -91,6 +104,8 @@ type ParserArgs struct { K8sClient client.Client // ExternalVariables override variables defined in the Devfile ExternalVariables map[string]string + // HTTPTimeout overrides the request and response timeout values for reading a parent devfile reference from the registry. If a negative value is specified, the default timeout will be used. + HTTPTimeout *int } // ParseDevfile func populates the devfile data, parses and validates the devfile integrity. @@ -114,6 +129,7 @@ func ParseDevfile(args ParserArgs) (d DevfileObj, err error) { registryURLs: args.RegistryURLs, context: args.Context, k8sClient: args.K8sClient, + httpTimeout: args.HTTPTimeout, } flattenedDevfile := true @@ -161,6 +177,8 @@ type resolverTools struct { context context.Context // K8sClient is the Kubernetes client instance used for interacting with a cluster k8sClient client.Client + // httpTimeout is the timeout value in seconds passed in from the client. + httpTimeout *int } func populateAndParseDevfile(d DevfileObj, resolveCtx *resolutionContextTree, tool resolverTools, flattenedDevfile bool) (DevfileObj, error) { @@ -446,7 +464,7 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio destDir := path.Dir(d.Ctx.GetAbsPath()) if registryURL != "" { - devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version) + devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version, tool.httpTimeout) if err != nil { return DevfileObj{}, err } @@ -465,7 +483,7 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio } else if tool.registryURLs != nil { for _, registryURL := range tool.registryURLs { - devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version) + devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version, tool.httpTimeout) if devfileContent != nil && err == nil { d.Ctx, err = devfileCtx.NewByteContentDevfileCtx(devfileContent) if err != nil { @@ -489,13 +507,16 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio return DevfileObj{}, fmt.Errorf("failed to get id: %s from registry URLs provided", id) } -func getDevfileFromRegistry(id, registryURL, version string) ([]byte, error) { +func getDevfileFromRegistry(id, registryURL, version string, httpTimeout *int) ([]byte, error) { if !strings.HasPrefix(registryURL, "http://") && !strings.HasPrefix(registryURL, "https://") { return nil, fmt.Errorf("the provided registryURL: %s is not a valid URL", registryURL) } param := util.HTTPRequestParams{ URL: fmt.Sprintf("%s/devfiles/%s/%s", registryURL, id, version), } + + param.Timeout = httpTimeout + return util.HTTPGetRequest(param, 0) } diff --git a/pkg/devfile/parser/parse_test.go b/pkg/devfile/parser/parse_test.go index 862ae20c..a337751f 100644 --- a/pkg/devfile/parser/parse_test.go +++ b/pkg/devfile/parser/parse_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/reader.go b/pkg/devfile/parser/reader.go index 5c3ba815..a97e775c 100644 --- a/pkg/devfile/parser/reader.go +++ b/pkg/devfile/parser/reader.go @@ -1,12 +1,27 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( "bytes" "io" - "github.com/devfile/library/pkg/testingutil/filesystem" "github.com/devfile/library/pkg/util" "github.com/pkg/errors" + "github.com/spf13/afero" "gopkg.in/yaml.v3" k8yaml "sigs.k8s.io/yaml" @@ -39,7 +54,7 @@ type KubernetesResources struct { // It returns all the parsed Kubernetes objects as an array of interface. // Consumers interested in the Kubernetes resources are expected to Unmarshal // it to the struct of the respective Kubernetes resource. -func ReadKubernetesYaml(src YamlSrc, fs filesystem.Filesystem) ([]interface{}, error) { +func ReadKubernetesYaml(src YamlSrc, fs afero.Afero) ([]interface{}, error) { var data []byte var err error diff --git a/pkg/devfile/parser/reader_test.go b/pkg/devfile/parser/reader_test.go index 5291a984..897d3a13 100644 --- a/pkg/devfile/parser/reader_test.go +++ b/pkg/devfile/parser/reader_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( @@ -7,8 +22,8 @@ import ( "reflect" "testing" - "github.com/devfile/library/pkg/testingutil/filesystem" "github.com/devfile/library/pkg/util" + "github.com/spf13/afero" "github.com/stretchr/testify/assert" ) @@ -16,7 +31,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { const serverIP = "127.0.0.1:9080" var data []byte - fs := filesystem.DefaultFs{} + fs := afero.Afero{Fs: afero.NewOsFs()} absPath, err := util.GetAbsPath("../../../tests/yamls/resources.yaml") if err != nil { t.Error(err) @@ -56,7 +71,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { tests := []struct { name string src YamlSrc - fs filesystem.Filesystem + fs afero.Afero wantErr bool wantDeploymentNames []string wantServiceNames []string @@ -69,7 +84,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ URL: "http://" + serverIP, }, - fs: filesystem.DefaultFs{}, + fs: fs, wantDeploymentNames: []string{"deploy-sample", "deploy-sample-2"}, wantServiceNames: []string{"service-sample", "service-sample-2"}, wantRouteNames: []string{"route-sample", "route-sample-2"}, @@ -81,7 +96,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ Path: "../../../tests/yamls/resources.yaml", }, - fs: filesystem.DefaultFs{}, + fs: fs, wantDeploymentNames: []string{"deploy-sample", "deploy-sample-2"}, wantServiceNames: []string{"service-sample", "service-sample-2"}, wantRouteNames: []string{"route-sample", "route-sample-2"}, @@ -93,7 +108,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ Data: data, }, - fs: filesystem.DefaultFs{}, + fs: fs, wantDeploymentNames: []string{"deploy-sample", "deploy-sample-2"}, wantServiceNames: []string{"service-sample", "service-sample-2"}, wantRouteNames: []string{"route-sample", "route-sample-2"}, @@ -105,7 +120,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ URL: "http://badurl", }, - fs: filesystem.DefaultFs{}, + fs: fs, wantErr: true, }, { @@ -113,7 +128,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ Path: "$%^&", }, - fs: filesystem.DefaultFs{}, + fs: fs, wantErr: true, }, { @@ -121,7 +136,7 @@ func TestReadAndParseKubernetesYaml(t *testing.T) { src: YamlSrc{ Data: badData, }, - fs: filesystem.DefaultFs{}, + fs: fs, wantErr: true, }, } diff --git a/pkg/devfile/parser/resolutionContext.go b/pkg/devfile/parser/resolutionContext.go index 5bb0d4bf..799ecd64 100644 --- a/pkg/devfile/parser/resolutionContext.go +++ b/pkg/devfile/parser/resolutionContext.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/sourceAttribute.go b/pkg/devfile/parser/sourceAttribute.go index dd7608fc..b8949092 100644 --- a/pkg/devfile/parser/sourceAttribute.go +++ b/pkg/devfile/parser/sourceAttribute.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/sourceAttribute_test.go b/pkg/devfile/parser/sourceAttribute_test.go index 6701efb8..d997ab9a 100644 --- a/pkg/devfile/parser/sourceAttribute_test.go +++ b/pkg/devfile/parser/sourceAttribute_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/writer.go b/pkg/devfile/parser/writer.go index 45d371dd..8b3f9d25 100644 --- a/pkg/devfile/parser/writer.go +++ b/pkg/devfile/parser/writer.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/parser/writer_test.go b/pkg/devfile/parser/writer_test.go index e7828279..f0bb9c26 100644 --- a/pkg/devfile/parser/writer_test.go +++ b/pkg/devfile/parser/writer_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 parser import ( diff --git a/pkg/devfile/validate/validate.go b/pkg/devfile/validate/validate.go index a1fa0026..4b646062 100644 --- a/pkg/devfile/validate/validate.go +++ b/pkg/devfile/validate/validate.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 validate import ( diff --git a/pkg/testingutil/containers.go b/pkg/testingutil/containers.go index 3c9433bb..00720ea1 100644 --- a/pkg/testingutil/containers.go +++ b/pkg/testingutil/containers.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 testingutil import corev1 "k8s.io/api/core/v1" diff --git a/pkg/testingutil/devfile.go b/pkg/testingutil/devfile.go index 74831a2b..21a9ec2c 100644 --- a/pkg/testingutil/devfile.go +++ b/pkg/testingutil/devfile.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 testingutil import ( diff --git a/pkg/testingutil/filesystem/singleton.go b/pkg/testingutil/filesystem/singleton.go index a8dcea8f..1d16ade7 100644 --- a/pkg/testingutil/filesystem/singleton.go +++ b/pkg/testingutil/filesystem/singleton.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 filesystem var singleFs Filesystem diff --git a/pkg/testingutil/k8sClient.go b/pkg/testingutil/k8sClient.go index 93394fd3..68f877c2 100644 --- a/pkg/testingutil/k8sClient.go +++ b/pkg/testingutil/k8sClient.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 testingutil import ( diff --git a/pkg/testingutil/resources.go b/pkg/testingutil/resources.go index e6495a71..7e70cf9f 100644 --- a/pkg/testingutil/resources.go +++ b/pkg/testingutil/resources.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 testingutil import ( diff --git a/pkg/util/httpcache.go b/pkg/util/httpcache.go index 8c140601..8efa0a94 100644 --- a/pkg/util/httpcache.go +++ b/pkg/util/httpcache.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 util import ( diff --git a/pkg/util/util.go b/pkg/util/util.go index 709ae330..b6fe1a4c 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 util import ( @@ -42,10 +57,9 @@ import ( ) const ( - HTTPRequestTimeout = 30 * time.Second // HTTPRequestTimeout configures timeout of all HTTP requests - ResponseHeaderTimeout = 30 * time.Second // ResponseHeaderTimeout is the timeout to retrieve the server's response headers - ModeReadWriteFile = 0600 // default Permission for a file - CredentialPrefix = "odo-" // CredentialPrefix is the prefix of the credential that uses to access secure registry + HTTPRequestResponseTimeout = 30 * time.Second // HTTPRequestTimeout configures timeout of all HTTP requests + ModeReadWriteFile = 0600 // default Permission for a file + CredentialPrefix = "odo-" // CredentialPrefix is the prefix of the credential that uses to access secure registry ) // httpCacheDir determines directory where odo will cache HTTP respones @@ -72,8 +86,9 @@ type ResourceRequirementInfo struct { // HTTPRequestParams holds parameters of forming http request type HTTPRequestParams struct { - URL string - Token string + URL string + Token string + Timeout *int } // DownloadParams holds parameters of forming file download request @@ -729,11 +744,26 @@ func HTTPGetRequest(request HTTPRequestParams, cacheFor int) ([]byte, error) { req.Header.Add("Authorization", bearer) } + overriddenTimeout := HTTPRequestResponseTimeout + timeout := request.Timeout + if timeout != nil { + //if value is invalid, the default will be used + if *timeout > 0 { + //convert timeout to seconds + overriddenTimeout = time.Duration(*timeout) * time.Second + klog.V(4).Infof("HTTP request and response timeout overridden value is %v ", overriddenTimeout) + } else { + klog.V(4).Infof("Invalid httpTimeout is passed in, using default value") + } + + } + httpClient := &http.Client{ Transport: &http.Transport{ - ResponseHeaderTimeout: ResponseHeaderTimeout, + Proxy: http.ProxyFromEnvironment, + ResponseHeaderTimeout: overriddenTimeout, }, - Timeout: HTTPRequestTimeout, + Timeout: overriddenTimeout, } klog.V(4).Infof("HTTPGetRequest: %s", req.URL.String()) @@ -1028,8 +1058,8 @@ func DownloadFile(params DownloadParams) error { // DownloadFileInMemory uses the url to download the file and return bytes func DownloadFileInMemory(url string) ([]byte, error) { var httpClient = &http.Client{Transport: &http.Transport{ - ResponseHeaderTimeout: ResponseHeaderTimeout, - }, Timeout: HTTPRequestTimeout} + ResponseHeaderTimeout: HTTPRequestResponseTimeout, + }, Timeout: HTTPRequestResponseTimeout} resp, err := httpClient.Get(url) if err != nil { return nil, err diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index b55c1079..c8c1b1e0 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -731,6 +731,9 @@ func TestGetRemoteFilesMarkedForDeletion(t *testing.T) { } func TestHTTPGetRequest(t *testing.T) { + invalidHTTPTimeout := -1 + validHTTPTimeout := 20 + // Start a local HTTP server server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { // Send response to be tested @@ -743,9 +746,10 @@ func TestHTTPGetRequest(t *testing.T) { defer server.Close() tests := []struct { - name string - url string - want []byte + name string + url string + want []byte + timeout *int }{ { name: "Case 1: Input url is valid", @@ -759,12 +763,25 @@ func TestHTTPGetRequest(t *testing.T) { url: "invalid", want: nil, }, + { + name: "Case 3: Test invalid httpTimeout, default timeout will be used", + url: server.URL, + timeout: &invalidHTTPTimeout, + want: []byte{79, 75}, + }, + { + name: "Case 4: Test valid httpTimeout", + url: server.URL, + timeout: &validHTTPTimeout, + want: []byte{79, 75}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { request := HTTPRequestParams{ - URL: tt.url, + URL: tt.url, + Timeout: tt.timeout, } got, err := HTTPGetRequest(request, 0) diff --git a/replaceSchemaFile.go b/replaceSchemaFile.go index 5607c893..2457fc3f 100644 --- a/replaceSchemaFile.go +++ b/replaceSchemaFile.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 main import ( diff --git a/tests/v2/libraryTest/library_test.go b/tests/v2/libraryTest/library_test.go index 3e0ead84..0b881114 100644 --- a/tests/v2/libraryTest/library_test.go +++ b/tests/v2/libraryTest/library_test.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 api import ( diff --git a/tests/v2/utils/library/command_test_utils.go b/tests/v2/utils/library/command_test_utils.go index 2a539b1b..020f3a57 100644 --- a/tests/v2/utils/library/command_test_utils.go +++ b/tests/v2/utils/library/command_test_utils.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 utils import ( diff --git a/tests/v2/utils/library/component_test_utils.go b/tests/v2/utils/library/component_test_utils.go index d92f1a9d..45afc239 100644 --- a/tests/v2/utils/library/component_test_utils.go +++ b/tests/v2/utils/library/component_test_utils.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 utils import ( diff --git a/tests/v2/utils/library/project_test_utils.go b/tests/v2/utils/library/project_test_utils.go index 799d751b..cac9c7df 100644 --- a/tests/v2/utils/library/project_test_utils.go +++ b/tests/v2/utils/library/project_test_utils.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 utils import ( diff --git a/tests/v2/utils/library/test_utils.go b/tests/v2/utils/library/test_utils.go index e93f97ad..8a2d42ed 100644 --- a/tests/v2/utils/library/test_utils.go +++ b/tests/v2/utils/library/test_utils.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// 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 utils import (