Skip to content

Commit

Permalink
Merge pull request #11 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
srisco authored Jul 25, 2022
2 parents 78a315a + 0d949ff commit bad3fd5
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 343 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand All @@ -92,7 +92,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand All @@ -117,7 +117,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The easy way to download OSCAR-CLI is through the github [releases page](https:/
If you have [go](https://golang.org/doc/install) installed and [configured](https://github.com/golang/go/wiki/SettingGOPATH), you can get it from source directly by executing:

```sh
go get github.com/grycap/oscar-cli
go install github.com/grycap/oscar-cli@latest
```

## Available commands
Expand Down
56 changes: 50 additions & 6 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ func applyFunc(cmd *cobra.Command, args []string) error {
return err
}

// Pre-loop to check all clusters and get its MinIO storage provider
clusters := map[string]types.Cluster{}
minioProviders := map[string]*types.MinIOProvider{}
for _, element := range fdl.Functions.Oscar {
for clusterName := range element {
// Check if cluster is defined
err := conf.CheckCluster(clusterName)
if err != nil {
return err
}

// Get cluster info
clusterInfo, err := conf.Oscar[clusterName].GetClusterConfig()
if err != nil {
return err
}

// Append cluster
clusters[clusterName] = types.Cluster{
Endpoint: conf.Oscar[clusterName].Endpoint,
AuthUser: conf.Oscar[clusterName].AuthUser,
AuthPassword: conf.Oscar[clusterName].AuthPassword,
SSLVerify: conf.Oscar[clusterName].SSLVerify,
}

// Append MinIO provider
minioProviders[clusterName] = clusterInfo.MinIOProvider
}
}

fmt.Printf("Applying file \"%s\"...\n", path.Base(args[0]))

for _, element := range fdl.Functions.Oscar {
Expand All @@ -62,12 +92,26 @@ func applyFunc(cmd *cobra.Command, args []string) error {
s.FinalMSG = fmt.Sprintf("%s%s\n", successString, msg)
s.Start()

// Check if cluster is defined
err := conf.CheckCluster(clusterName)
if err != nil {
s.FinalMSG = fmt.Sprintf("%s%s\n", failureString, msg)
s.Stop()
return err
// Add (and overwrite) clusters
if svc.Clusters == nil {
// Initialize map
svc.Clusters = map[string]types.Cluster{}
}
for cn, c := range clusters {
svc.Clusters[cn] = c
}

// Add (and overwrite) MinIO providers
if svc.StorageProviders == nil {
// Initialize StorageProviders
svc.StorageProviders = &types.StorageProviders{}
}
if svc.StorageProviders.MinIO == nil {
// Initialize map
svc.StorageProviders.MinIO = map[string]*types.MinIOProvider{}
}
for cn, m := range minioProviders {
svc.StorageProviders.MinIO[cn] = m
}

// Check if service exists in cluster in order to create or edit it
Expand Down
52 changes: 28 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
module github.com/grycap/oscar-cli

go 1.17
go 1.18

require (
github.com/aws/aws-sdk-go v1.43.15
github.com/aws/aws-sdk-go v1.44.59
github.com/briandowns/spinner v1.18.1
github.com/fatih/color v1.13.0
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/goccy/go-yaml v1.9.5
github.com/google/go-cmp v0.5.7 // indirect
github.com/grycap/oscar/v2 v2.4.1
github.com/grycap/oscar/v2 v2.5.0
github.com/json-iterator/go v1.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/spf13/cobra v1.3.0
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
github.com/spf13/cobra v1.5.0
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/text v0.3.7 // indirect
k8s.io/api v0.23.4 // indirect
k8s.io/klog/v2 v2.40.1 // indirect
k8s.io/api v0.24.3 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grycap/cdmi-client-go v0.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/onsi/gomega v1.14.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/oauth2 v0.0.0-20220718184931-c8730f7fcb92 // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apimachinery v0.23.4 // indirect
k8s.io/client-go v0.23.4 // indirect
k8s.io/kube-openapi v0.0.0-20220310132336-3f90b8c54bbb // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.24.3 // indirect
k8s.io/client-go v0.24.3 // indirect
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 // indirect
k8s.io/utils v0.0.0-20220713171938-56c0de1e6f5e // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit bad3fd5

Please sign in to comment.