Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #118 from keptn/release-0.4.0
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
christian-kreuzberger-dtx authored Nov 20, 2019
2 parents 75f8571 + 90c5bfc commit fcd0bbb
Show file tree
Hide file tree
Showing 22 changed files with 747 additions and 238 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can find our [contribution guide](https://github.com/keptn/keptn/blob/master/CONTRIBUTING.md) as well as our
[code of conduct](https://github.com/keptn/keptn/blob/master/CODE_OF_CONDUCT.md) in the
[keptn repo](https://github.com/keptn/keptn).
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,65 @@
# Keptn go-utils
[![Build Status](https://travis-ci.org/keptn/go-utils.svg?branch=master)](https://travis-ci.org/keptn/go-utils)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/keptn/go-utils)
[![Go Report Card](https://goreportcard.com/badge/github.com/keptn/go-utils)](https://goreportcard.com/report/github.com/keptn/go-utils)

This repo serves as a util package for common functionalities such as logging of the [Keptn Project](https://github.com/keptn).

Please post any issues with this package to the [keptn/keptn repository](https://github.com/keptn/keptn/issues) and label them with `area:go-utils`.

## Usage
## Installation

Get the latest version using
```console
go get github.com/keptn/go-utils
```
Also consider browsing our [Releases Page](https://github.com/keptn/go-utils/releases) to find out about all releases.

## Usage

Below we have listed some basic examples. You can find more information about the usage within the [docs/](docs/) folder.

### Utils
If you need to access several utility functions:

```go
import {
keptnutils "github.com/keptn/go-utils/pkg/utils"
}
```

## Logging

```
Logging Example:
```go
keptnutils.Debug(keptncontext, message)
keptnutils.Info(keptncontext, message)
keptnutils.Error(keptncontext, message)
```

### CloudEvent Data
If you need to access data within CloudEvents:

```go
import {
keptnevents "github.com/keptn/go-utils/pkg/events"
)
```
Example:
```go
func parseCloudEvent(event cloudevents.Event) (keptnevents.TestFinishedEventData, error) {
eventData := &keptnevents.TestsFinishedEventData{}
err := event.DataAs(eventData)

return eventData, err
}
```
### Models
If you need to access Models for YAML files:
```go
import {
keptnmodels "github.com/keptn/go-utils/pkg/models"
)
```
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Work in Progress
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/alecthomas/jsonschema v0.0.0-20191017121752-4bb6e3fae4f2 h1:swGeCLPiUQ647AIRnFxnAHdzlg6IPpmU6QdkOPZINt8=
github.com/alecthomas/jsonschema v0.0.0-20191017121752-4bb6e3fae4f2/go.mod h1:Juc2PrI3wtNfUwptSvAIeNx+HrETwHQs6nf+TkOJlOA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
Expand Down Expand Up @@ -252,6 +254,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
15 changes: 6 additions & 9 deletions pkg/configuration-service/utils/resourceUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,15 @@ func (r *ResourceHandler) deleteResource(uri string) error {

// GetAllStageResources returns a list of all resources.
func (r *ResourceHandler) GetAllStageResources(project string, stage string) ([]*models.Resource, error) {

url, err := url.Parse(r.Scheme + "://" + r.getBaseURL() + "/v1/project/" + project + "/stage/" + stage + "/resource")
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
return r.getAllResources(url)
}

// GetAllStageResources returns a list of all resources.
// GetAllServiceResources returns a list of all resources.
func (r *ResourceHandler) GetAllServiceResources(project string, stage string, service string) ([]*models.Resource, error) {

url, err := url.Parse(r.Scheme + "://" + r.getBaseURL() + "/v1/project/" + project + "/stage/" + stage +
"/service/" + service + "/resource/")
if err != nil {
Expand All @@ -312,19 +307,20 @@ func (r *ResourceHandler) GetAllServiceResources(project string, stage string, s
return r.getAllResources(url)
}

func (r *ResourceHandler) getAllResources(url *url.URL) ([]*models.Resource, error) {
func (r *ResourceHandler) getAllResources(u *url.URL) ([]*models.Resource, error) {

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
resources := []*models.Resource{}

nextPageKey := ""

for {
q := url.Query()
if nextPageKey != "" {
q := u.Query()
q.Set("nextPageKey", nextPageKey)
u.RawQuery = q.Encode()
}
req, err := http.NewRequest("GET", url.String(), nil)
req, err := http.NewRequest("GET", u.String(), nil)
req.Header.Set("Content-Type", "application/json")
addAuthHeader(req, r)

Expand All @@ -351,6 +347,7 @@ func (r *ResourceHandler) getAllResources(url *url.URL) ([]*models.Resource, err
break
}
nextPageKey = received.NextPageKey

} else {
var respErr models.Error
err = json.Unmarshal(body, &respErr)
Expand Down
Loading

0 comments on commit fcd0bbb

Please sign in to comment.