Skip to content

Commit

Permalink
Merge pull request #85 from yangcao77/import-attribute-from-apiRepo
Browse files Browse the repository at this point in the history
update source attribute to use the one imported from devfile/api
  • Loading branch information
yangcao77 authored May 7, 2021
2 parents 6be752c + 53645d2 commit c59cfa4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/devfile/library
go 1.13

require (
github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292
github.com/devfile/api/v2 v2.0.0-20210507143755-39103b31c0f3
github.com/fatih/color v1.7.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gobwas/glob v0.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292 h1:XNtHHNf041XmYSbz8u4ZhLbebjhdoY79wDW0HT3Y9UI=
github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292/go.mod h1:Cot4snybn3qhIh48oIFi9McocnIx7zY5fFbjfrIpPvg=
github.com/devfile/api/v2 v2.0.0-20210507143755-39103b31c0f3 h1:gm67QZRqq8vCtrpxXlTNPf7xss5rjn9CFcPtAUr+nqo=
github.com/devfile/api/v2 v2.0.0-20210507143755-39103b31c0f3/go.mod h1:Cot4snybn3qhIh48oIFi9McocnIx7zY5fFbjfrIpPvg=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
Expand Down
3 changes: 2 additions & 1 deletion pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,7 @@ const JsonSchema210 = `{
}
},
"registryUrl": {
"description": "Registry URL to pull the parent devfile from when using id in the parent reference. To ensure the parent devfile gets resolved consistently in different environments, it is recommended to always specify the 'regsitryURL' when 'Id' is used.",
"type": "string"
},
"starterProjects": {
Expand Down Expand Up @@ -1535,7 +1536,7 @@ const JsonSchema210 = `{
}
},
"uri": {
"description": "Uri of a Devfile yaml file",
"description": "URI Reference of a parent devfile YAML file. It can be a full URL or a relative URI with the current devfile as the base URI.",
"type": "string"
},
"variables": {
Expand Down
13 changes: 7 additions & 6 deletions pkg/devfile/parser/sourceAttribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"fmt"
v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/api/v2/pkg/attributes"
"github.com/devfile/api/v2/pkg/validation"
)

const (
importSourceAttribute = "library.devfile.io/imported-from"
parentOverrideAttribute = "library.devfile.io/parent-override-from"
pluginOverrideAttribute = "library.devfile.io/plugin-override-from"
importSourceAttribute = validation.ImportSourceAttribute
parentOverrideAttribute = validation.ParentOverrideAttribute
pluginOverrideAttribute = validation.PluginOverrideAttribute
)

// addSourceAttributesForParentOverride adds an attribute 'library.devfile.io/imported-from=<source reference>'
// addSourceAttributesForParentOverride adds an attribute 'api.devfile.io/imported-from=<source reference>'
// to all elements of template spec content that support attributes.
func addSourceAttributesForTemplateSpecContent(sourceImportReference v1.ImportReference, template *v1.DevWorkspaceTemplateSpecContent) {
for idx, component := range template.Components {
Expand Down Expand Up @@ -41,7 +42,7 @@ func addSourceAttributesForTemplateSpecContent(sourceImportReference v1.ImportRe
}
}

// addSourceAttributesForParentOverride adds an attribute 'library.devfile.io/parent-override-from=<source reference>'
// addSourceAttributesForParentOverride adds an attribute 'api.devfile.io/parent-override-from=<source reference>'
// to all elements of parent override that support attributes.
func addSourceAttributesForParentOverride(sourceImportReference v1.ImportReference, parentOverrides *v1.ParentOverrides) {
for idx, component := range parentOverrides.Components {
Expand Down Expand Up @@ -71,7 +72,7 @@ func addSourceAttributesForParentOverride(sourceImportReference v1.ImportReferen

}

// addSourceAttributesForPluginOverride adds an attribute 'library.devfile.io/plugin-override-from=<source reference>'
// addSourceAttributesForPluginOverride adds an attribute 'api.devfile.io/plugin-override-from=<source reference>'
// to all elements of plugin override that support attributes.
func addSourceAttributesForPluginOverride(sourceImportReference v1.ImportReference, pluginOverrides *v1.PluginOverrides) {
for idx, component := range pluginOverrides.Components {
Expand Down

0 comments on commit c59cfa4

Please sign in to comment.