Skip to content

Commit

Permalink
Merge pull request #52 from rebuy-de/release-v3
Browse files Browse the repository at this point in the history
Release Branch for v3
  • Loading branch information
svenwltr authored Oct 7, 2020
2 parents 6a21644 + bc19049 commit a3017da
Show file tree
Hide file tree
Showing 45 changed files with 61 additions and 221 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor
/dist
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ before_install:
- go get golang.org/x/lint/golint

install:
- cd v2
- go mod vendor

script:
Expand All @@ -21,4 +20,4 @@ cache:
directories:
- $GOPATH/pkg
- $HOME/.cache/go-build
- v2/vendor
- vendor
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY . /sdk
# --mount=type=cache,id=go-pkg-cache,target=/go/pkg \
RUN \
set -e \
&& cd /sdk/v2 \
&& cd /sdk \
&& ./buildutil \
&& cp ./dist/buildutil /usr/local/bin \
&& buildutil version \
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ Library for our Golang projects
> **Development Status** *rebuy-go-sdk* is designed for internal use. Since it
> uses [Semantic Versioning](https://semver.org/) it is safe to use, but expect
> big changes between major version updates.

## Major Release Notes

Note: `vN` is the new release (eg `v3`) and `vP` is the previous one (eg `v2`).

1. Create a new branch `release-vN` to avoid breaking changes getting into the previous release.
2. Do your breaking changes in the branch.
3. Update the imports everywhere:
* `find . -type f -exec sed -i 's#github.com/rebuy-de/rebuy-go-sdk/vO#github.com/rebuy-de/rebuy-go-sdk/vP#g' {} +`
4. Merge your branch.
5. Add Release on GitHub.
File renamed without changes.
6 changes: 3 additions & 3 deletions v2/cmd/buildutil/info.go → cmd/buildutil/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"time"

"github.com/pkg/errors"
"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/executil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/executil"
"github.com/sirupsen/logrus"
"golang.org/x/tools/go/packages"
)
Expand All @@ -32,7 +32,7 @@ func ParseVersion(s string) (Version, error) {
err error

reCore = regexp.MustCompile(`^v?([0-9]+)\.([0-9]+)\.([0-9]+)([\-\+].+)?$`)
rePreRelease = regexp.MustCompile(`^\+(alpha|beta|rc)\.[0-9]+$`)
rePreRelease = regexp.MustCompile(`^[\-\+](alpha|beta|rc)\.?[0-9]+$`)
reDescribe = regexp.MustCompile(`\-([0-9]+)-g?([0-9a-f]+)(-dirty)?$`)
)

Expand Down
5 changes: 5 additions & 0 deletions v2/cmd/buildutil/info_test.go → cmd/buildutil/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func TestParseVersion(t *testing.T) {
in: "v1.6.0+alpha.1-20-gb9e9373-dirty",
out: "v1.6.0+dirty.20.b9e9373",
},
{
name: "release-candidate",
in: "v3.0.0-rc2",
out: "v3.0.0+rc2",
},
}

for _, tc := range cases {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/typeutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/typeutil"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion v2/cmd/buildutil/logutil.go → cmd/buildutil/logutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil"
"github.com/tidwall/pretty"
)

Expand Down
2 changes: 1 addition & 1 deletion v2/cmd/buildutil/main.go → cmd/buildutil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions v2/cmd/buildutil/runner.go → cmd/buildutil/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/executil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/executil"
)

func call(ctx context.Context, command string, args ...string) {
Expand Down Expand Up @@ -189,7 +189,7 @@ func (r *Runner) RunBuild(ctx context.Context, cmd *cobra.Command, args []string
ldFlags := []string{}
for _, entry := range ldData {
ldFlags = append(ldFlags, fmt.Sprintf(
`-X 'github.com/rebuy-de/rebuy-go-sdk/v2/pkg/cmdutil.%s=%s'`,
`-X 'github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil.%s=%s'`,
entry.name, entry.value,
))
}
Expand Down
2 changes: 1 addition & 1 deletion v2/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/rebuy-de/rebuy-go-sdk/v2
module github.com/rebuy-de/rebuy-go-sdk/v3

go 1.15

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package testutil_test
import (
"testing"

"github.com/rebuy-de/rebuy-go-sdk/v2/pkg/testutil"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/testutil"
)

type exampleData struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 30 additions & 7 deletions v2/pkg/webutil/session.go → pkg/webutil/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package webutil

import (
"context"
"fmt"
"net/http"

"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
"github.com/pkg/errors"
"github.com/rebuy-de/rebuy-go-sdk/v3/pkg/cmdutil"
"github.com/sirupsen/logrus"
)

type sessionContextKeyType int

const (
sessionName = `rebuy-go-sdk`

sessionContextKey sessionContextKeyType = 0
)

Expand Down Expand Up @@ -46,17 +46,40 @@ func SessionFromRequest(r *http.Request) (*sessions.Session, error) {

// SessionMiddleware inizializes the session store and injects it into the
// context of the requests.
func SessionMiddleware(secret SessionSecret) Middleware {
func SessionMiddleware(secret SessionSecret, opts ...SessionMiddlewareOption) Middleware {
return func(next http.Handler) http.Handler {
return sessionMiddlewareFunc(next, secret)
return sessionMiddlewareFunc(next, secret, opts...)
}
}

func sessionMiddlewareFunc(next http.Handler, secret SessionSecret) http.Handler {
store := sessions.NewCookieStore(secret)
type sessionMiddlewareConfig struct {
name string
store *sessions.CookieStore
}

type SessionMiddlewareOption func(c *sessionMiddlewareConfig)

func SessionMiddlewareCookieDomain(domain string) SessionMiddlewareOption {
return func(c *sessionMiddlewareConfig) {
c.store.Options.Domain = domain
}
}

func sessionMiddlewareFunc(next http.Handler, secret SessionSecret, opts ...SessionMiddlewareOption) http.Handler {
config := sessionMiddlewareConfig{
name: fmt.Sprintf("%s-session", cmdutil.Name),
store: sessions.NewCookieStore(secret),
}

config.store.Options.HttpOnly = true
config.store.Options.Secure = true

for _, o := range opts {
o(&config)
}

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session, err := store.Get(r, sessionName)
session, err := config.store.Get(r, config.name)
if err != nil {
logrus.WithError(err).Warn("failed to restore session; creating new one")
session.Save(r, w)
Expand Down
2 changes: 0 additions & 2 deletions v2/.gitignore

This file was deleted.

81 changes: 0 additions & 81 deletions v2/cmd/regenerator/generator.go

This file was deleted.

16 changes: 0 additions & 16 deletions v2/cmd/regenerator/generator_test.go

This file was deleted.

31 changes: 0 additions & 31 deletions v2/cmd/regenerator/main.go

This file was deleted.

28 changes: 0 additions & 28 deletions v2/cmd/regenerator/runner.go

This file was deleted.

Loading

0 comments on commit a3017da

Please sign in to comment.