Skip to content

Commit

Permalink
Apply Outerloop PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Maysun J Faisal <[email protected]>
  • Loading branch information
maysunfaisal committed Sep 8, 2021
1 parent 81da7da commit 24e26b5
Show file tree
Hide file tree
Showing 37 changed files with 1,842 additions and 1,642 deletions.
298 changes: 156 additions & 142 deletions crds/workspace.devfile.io_devworkspaces.v1beta1.yaml

Large diffs are not rendered by default.

298 changes: 156 additions & 142 deletions crds/workspace.devfile.io_devworkspaces.yaml

Large diffs are not rendered by default.

285 changes: 148 additions & 137 deletions crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml

Large diffs are not rendered by default.

285 changes: 148 additions & 137 deletions crds/workspace.devfile.io_devworkspacetemplates.yaml

Large diffs are not rendered by default.

73 changes: 37 additions & 36 deletions pkg/apis/workspaces/v1alpha1/commands_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,47 +58,48 @@ func getGroup(dc v1alpha2.Command) *v1alpha2.CommandGroup {
}

func convertCommandFrom_v1alpha2(src *v1alpha2.Command, dest *Command) error {
if src != nil {
id := src.Key()
if src == nil {
return nil
}

srcCmdGroup := getGroup(*src)
if srcCmdGroup != nil && srcCmdGroup.Kind == v1alpha2.DeployCommandGroupKind {
// skip converting deploy kind commands as deploy kind commands are not supported in v1alpha1
return nil
}
id := src.Key()

jsonCommand, err := json.Marshal(src)
if err != nil {
return err
}
err = json.Unmarshal(jsonCommand, dest)
srcCmdGroup := getGroup(*src)
if srcCmdGroup != nil && srcCmdGroup.Kind == v1alpha2.DeployCommandGroupKind {
// skip converting deploy kind commands as deploy kind commands are not supported in v1alpha1
return nil
}

jsonCommand, err := json.Marshal(src)
if err != nil {
return err
}
err = json.Unmarshal(jsonCommand, dest)
if err != nil {
return err
}
var destAttributes map[string]string
if src.Attributes != nil {
destAttributes = make(map[string]string)
err = convertAttributesFrom_v1alpha2(&src.Attributes, destAttributes)
if err != nil {
return err
}
var destAttributes map[string]string
if src.Attributes != nil {
destAttributes = make(map[string]string)
err = convertAttributesFrom_v1alpha2(&src.Attributes, destAttributes)
if err != nil {
return err
}
}
}

switch {
case dest.Apply != nil:
dest.Apply.Attributes = destAttributes
dest.Apply.Id = id
case dest.Composite != nil:
dest.Composite.Attributes = destAttributes
dest.Composite.Id = id
case dest.Custom != nil:
dest.Custom.Attributes = destAttributes
dest.Custom.Id = id
case dest.Exec != nil:
dest.Exec.Attributes = destAttributes
dest.Exec.Id = id
}
return err
switch {
case dest.Apply != nil:
dest.Apply.Attributes = destAttributes
dest.Apply.Id = id
case dest.Composite != nil:
dest.Composite.Attributes = destAttributes
dest.Composite.Id = id
case dest.Custom != nil:
dest.Custom.Attributes = destAttributes
dest.Custom.Id = id
case dest.Exec != nil:
dest.Exec.Attributes = destAttributes
dest.Exec.Id = id
}
return nil
return err
}
33 changes: 17 additions & 16 deletions pkg/apis/workspaces/v1alpha2/component_image_dockerfile.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package v1alpha2

// DockerfileLocationType describes the type of
// the location for the Dockerfile outerloop build.
// DockerfileSrcType describes the type of
// the src for the Dockerfile outerloop build.
// Only one of the following location type may be specified.
// +kubebuilder:validation:Enum=Uri;Registry;Git
type DockerfileLocationType string
// +kubebuilder:validation:Enum=Uri;DevfileRegistry;Git
type DockerfileSrcType string

const (
UriLikeDockerfileLocationType DockerfileLocationType = "Uri"
RegistryLikeDockerfileLocationType DockerfileLocationType = "Registry"
GitLikeDockerfileLocationType DockerfileLocationType = "Git"
UriLikeDockerfileSrcType DockerfileSrcType = "Uri"
DevfileRegistryLikeDockerfileSrcType DockerfileSrcType = "DevfileRegistry"
GitLikeDockerfileSrcType DockerfileSrcType = "Git"
)

// Dockerfile Image type to specify the outerloop build using a Dockerfile
type DockerfileImage struct {
BaseImage `json:",inline"`
DockerfileLocation `json:",inline"`
Dockerfile `json:",inline"`
BaseImage `json:",inline"`
DockerfileSrc `json:",inline"`
Dockerfile `json:",inline"`
}

// +union
type DockerfileLocation struct {
// Type of Dockerfile location
type DockerfileSrc struct {
// Type of Dockerfile src
// +
// +unionDiscriminator
// +optional
LocationType DockerfileLocationType `json:"locationType,omitempty"`
SrcType DockerfileSrcType `json:"srcType,omitempty"`

// URI Reference of a Dockerfile.
// It can be a full URL or a relative URI from the current devfile as the base URI.
Expand All @@ -34,7 +34,7 @@ type DockerfileLocation struct {

// Dockerfile's Devfile Registry source
// +optional
Registry *DockerfileDevfileRegistrySource `json:"registry,omitempty"`
DevfileRegistry *DockerfileDevfileRegistrySource `json:"devfileRegistry,omitempty"`

// Dockerfile's Git source
// +optional
Expand Down Expand Up @@ -66,7 +66,7 @@ type DockerfileDevfileRegistrySource struct {
// To ensure the Dockerfile gets resolved consistently in different environments,
// it is recommended to always specify the `devfileRegistryUrl` when `Id` is used.
// +optional
DevfileRegistryUrl string `json:"devfileRegistryUrl,omitempty"`
RegistryUrl string `json:"registryUrl,omitempty"`
}

type DockerfileGitProjectSource struct {
Expand All @@ -75,6 +75,7 @@ type DockerfileGitProjectSource struct {
GitProjectSource `json:",inline"`

// Location of the Dockerfile in the Git repository when using git as Dockerfile src.
// Defaults to Dockerfile.
// +optional
GitLocation string `json:"gitLocation,omitempty"`
FileLocation string `json:"fileLocation,omitempty"`
}
2 changes: 1 addition & 1 deletion pkg/apis/workspaces/v1alpha2/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type GitLikeProjectSource struct {
CheckoutFrom *CheckoutFrom `json:"checkoutFrom,omitempty"`

// The remotes map which should be initialized in the git project.
// Projects must have at least one remote configured while StarterProjects can only have at most one remote configured.
// Projects must have at least one remote configured while StarterProjects & Image Component's Git source can only have at most one remote configured.
Remotes map[string]string `json:"remotes"`
}

Expand Down
Loading

0 comments on commit 24e26b5

Please sign in to comment.