Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

parse parent via kube crd reference #78

Merged
merged 11 commits into from
Apr 13, 2021
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/fatih/color v1.7.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gobwas/glob v0.2.3
github.com/google/go-cmp v0.4.0
github.com/google/go-cmp v0.5.2
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
github.com/mattn/go-colorable v0.1.2 // indirect
Expand All @@ -17,8 +17,10 @@ require (
github.com/spf13/afero v1.2.2
github.com/stretchr/testify v1.6.1
github.com/xeipuuv/gojsonschema v1.2.0
k8s.io/api v0.19.0
k8s.io/apimachinery v0.19.0
k8s.io/api v0.19.2
k8s.io/apimachinery v0.19.2
k8s.io/client-go v0.19.2
k8s.io/klog v1.0.0
sigs.k8s.io/controller-runtime v0.7.0
sigs.k8s.io/yaml v1.2.0
)
225 changes: 225 additions & 0 deletions go.sum

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions pkg/devfile/parser/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ type DevfileCtx struct {

// filesystem for devfile
fs filesystem.Filesystem

// trace of all url referenced
uriMap map[string]bool

// registry URLs list
registryURLs []string
}

// NewDevfileCtx returns a new DevfileCtx type object
Expand Down Expand Up @@ -87,13 +81,6 @@ func (d *DevfileCtx) Populate() (err error) {
return err
}
klog.V(4).Infof("absolute devfile path: '%s'", d.absPath)
if d.uriMap == nil {
d.uriMap = make(map[string]bool)
}
if d.uriMap[d.absPath] {
return fmt.Errorf("URI %v is recursively referenced", d.absPath)
}
d.uriMap[d.absPath] = true
// Read and save devfile content
if err := d.SetDevfileContent(); err != nil {
return err
Expand All @@ -107,13 +94,6 @@ func (d *DevfileCtx) PopulateFromURL() (err error) {
if err != nil {
return err
}
if d.uriMap == nil {
d.uriMap = make(map[string]bool)
}
if d.uriMap[d.url] {
return fmt.Errorf("URI %v is recursively referenced", d.url)
}
d.uriMap[d.url] = true
// Read and save devfile content
if err := d.SetDevfileContent(); err != nil {
return err
Expand Down Expand Up @@ -154,23 +134,3 @@ func (d *DevfileCtx) SetAbsPath() (err error) {
return nil

}

// GetURIMap func returns current devfile uri map
func (d *DevfileCtx) GetURIMap() map[string]bool {
return d.uriMap
}

// SetURIMap set uri map in the devfile ctx
func (d *DevfileCtx) SetURIMap(uriMap map[string]bool) {
d.uriMap = uriMap
}

// GetRegistryURLs func returns current devfile registry URLs
func (d *DevfileCtx) GetRegistryURLs() []string {
return d.registryURLs
}

// SetRegistryURLs set registry URLs in the devfile ctx
func (d *DevfileCtx) SetRegistryURLs(registryURLs []string) {
d.registryURLs = registryURLs
}
4 changes: 4 additions & 0 deletions pkg/devfile/parser/data/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type supportedApiVersion string
const (
APIVersion200 supportedApiVersion = "2.0.0"
APIVersion210 supportedApiVersion = "2.1.0"
V2APIVersion supportedApiVersion = "v1alpha2"
maysunfaisal marked this conversation as resolved.
Show resolved Hide resolved
)

// ------------- Init functions ------------- //
Expand All @@ -27,6 +28,7 @@ func init() {
apiVersionToDevfileStruct = make(map[supportedApiVersion]reflect.Type)
apiVersionToDevfileStruct[APIVersion200] = reflect.TypeOf(v2.DevfileV2{})
apiVersionToDevfileStruct[APIVersion210] = reflect.TypeOf(v2.DevfileV2{})
apiVersionToDevfileStruct[V2APIVersion] = reflect.TypeOf(v2.DevfileV2{})
}

// Map to store mappings between supported devfile API versions and respective devfile JSON schemas
Expand All @@ -37,4 +39,6 @@ func init() {
devfileApiVersionToJSONSchema = make(map[supportedApiVersion]string)
devfileApiVersionToJSONSchema[APIVersion200] = v200.JsonSchema200
devfileApiVersionToJSONSchema[APIVersion210] = v210.JsonSchema210
// should use hightest v2 schema version since it is expected to be backward compatible with the same api version
devfileApiVersionToJSONSchema[V2APIVersion] = v210.JsonSchema210
}
Loading