Skip to content

Commit

Permalink
Set replicas using devfile library (#5413)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmit committed Feb 14, 2022
1 parent 21ea375 commit 32d8a04
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/Netflix/go-expect v0.0.0-20201125194554-85d881c3777e
github.com/Xuanwo/go-locale v1.0.0
github.com/blang/semver v3.5.1+incompatible
github.com/devfile/api/v2 v2.0.0-20220126144139-f6d7cd85a481
github.com/devfile/library v1.2.1-0.20220201022328-58ef0b78c0fe
github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c
github.com/devfile/library v1.2.1-0.20220201144851-0749c7fa35a1
github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f
github.com/devfile/registry-support/registry-library v0.0.0-20211125162259-d7edf148d3e2
github.com/fatih/color v1.10.0
Expand Down Expand Up @@ -76,5 +76,4 @@ replace (
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20211006165314-dacad8cb3fcb
k8s.io/kubectl => github.com/openshift/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20210831004331-1199c36daed6
k8s.io/metrics => k8s.io/metrics v0.0.0-20211006171351-de75bc981086

)
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,11 @@ github.com/deislabs/oras v0.8.1/go.mod h1:Mx0rMSbBNaNfY9hjpccEnxkOqJL6KGjtxNHPLC
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
github.com/devfile/api/v2 v2.0.0-20210910153124-da620cd1a7a1/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c h1:sjghKUov/WT71dBreHYQcTgQctxHT/p4uAhUFdGQfSU=
github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q=
github.com/devfile/api/v2 v2.0.0-20220126144139-f6d7cd85a481 h1:G4trvnLOua7AsSetNa8k4u9VUNavPIwXa3CNfBwQwx4=
github.com/devfile/api/v2 v2.0.0-20220126144139-f6d7cd85a481/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec/go.mod h1:svPWwWb+BP15SXCHl0dyOeE4Sohrjl5a2BaOzc/riLc=
github.com/devfile/library v1.2.1-0.20220201022328-58ef0b78c0fe h1:IzpRD2XS7m7k+6lFLYjaFAPYy0CSv0861teFvzNFkdM=
github.com/devfile/library v1.2.1-0.20220201022328-58ef0b78c0fe/go.mod h1:Fp8wxWPVA5pz8geGIp0DioGVgnZAdwyqsgohvRaR5rk=
github.com/devfile/library v1.2.1-0.20220201144851-0749c7fa35a1 h1:cenRsPWEfoCvKit8AtYnPtVlxA5z9EyVDqK3JW62er4=
github.com/devfile/library v1.2.1-0.20220201144851-0749c7fa35a1/go.mod h1:nZ9P4D8QxHdWe/czYx9sn+BxzsTOXMj/LAUfcqkvvuU=
github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f h1:fKNUmoOPh7yAs69uMRZWHvev+m3e7T4jBL/hOXZB9ys=
github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f/go.mod h1:bLGagbW2SFn7jo5+kUPlCMehIGqWkRtLKc5O0OyJMJM=
github.com/devfile/registry-support/registry-library v0.0.0-20211125162259-d7edf148d3e2 h1:Rwuc0bdx8xSZWdIwXjAxaKYnZIWHneJmDAAZ6a5jXzY=
Expand Down
6 changes: 3 additions & 3 deletions pkg/devfile/adapters/kubernetes/component/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package component
import (
"fmt"
"io"
"k8s.io/utils/pointer"
"os"
"reflect"
"strings"
"time"

"github.com/pkg/errors"

"github.com/devfile/library/pkg/devfile/generator"
"github.com/redhat-developer/odo/pkg/component"
componentlabels "github.com/redhat-developer/odo/pkg/component/labels"
"github.com/redhat-developer/odo/pkg/devfile"
Expand All @@ -26,7 +28,6 @@ import (
"github.com/redhat-developer/odo/pkg/util"

devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/library/pkg/devfile/generator"
parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common"
dfutil "github.com/devfile/library/pkg/util"

Expand All @@ -35,7 +36,6 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
"k8s.io/utils/pointer"
)

const supervisorDStatusWaitTimeInterval = 1
Expand Down Expand Up @@ -532,13 +532,13 @@ func (a *Adapter) createOrUpdateComponent(componentExists bool, ei envinfo.EnvSp
Containers: containers,
Volumes: allVolumes,
PodSelectorLabels: selectorLabels,
Replicas: pointer.Int32Ptr(1),
}

deployment, err := generator.GetDeployment(a.Devfile, deployParams)
if err != nil {
return err
}
deployment.Spec.Replicas = pointer.Int32Ptr(1)
if deployment.Annotations == nil {
deployment.Annotations = make(map[string]string)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ github.com/deislabs/oras/pkg/artifact
github.com/deislabs/oras/pkg/content
github.com/deislabs/oras/pkg/context
github.com/deislabs/oras/pkg/oras
# github.com/devfile/api/v2 v2.0.0-20220126144139-f6d7cd85a481
# github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c
## explicit
github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2
github.com/devfile/api/v2/pkg/attributes
Expand All @@ -105,7 +105,7 @@ github.com/devfile/api/v2/pkg/utils/overriding
github.com/devfile/api/v2/pkg/utils/unions
github.com/devfile/api/v2/pkg/validation
github.com/devfile/api/v2/pkg/validation/variables
# github.com/devfile/library v1.2.1-0.20220201022328-58ef0b78c0fe
# github.com/devfile/library v1.2.1-0.20220201144851-0749c7fa35a1
## explicit
github.com/devfile/library/pkg/devfile
github.com/devfile/library/pkg/devfile/generator
Expand Down

0 comments on commit 32d8a04

Please sign in to comment.