Skip to content

Commit 5de5d59

Browse files
committed
feat(builder): fmt code and add create_bucket script
1 parent a23d3d9 commit 5de5d59

18 files changed

Lines changed: 75 additions & 26 deletions

boot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
"github.com/drycc/builder/pkg/conf"
1515
"github.com/drycc/builder/pkg/gitreceive"
1616
"github.com/drycc/builder/pkg/healthsrv"
17+
"github.com/drycc/builder/pkg/k8s"
1718
"github.com/drycc/builder/pkg/sshd"
1819
"github.com/drycc/builder/pkg/sys"
1920
pkglog "github.com/drycc/pkg/log"
2021
"github.com/kelseyhightower/envconfig"
21-
"github.com/drycc/builder/pkg/k8s"
2222
)
2323

2424
const (

pkg/cleaner/cleaner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
package cleaner
44

55
import (
6+
"context"
67
"fmt"
78
"io/ioutil"
89
"path/filepath"
910
"regexp"
1011
"strings"
1112
"time"
12-
"context"
1313

1414
//"github.com/docker/distribution/context"
1515
storagedriver "github.com/docker/distribution/registry/storage/driver"

pkg/gitreceive/build.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package gitreceive
22

33
import (
44
"bytes"
5+
ctx "context"
56
"encoding/json"
67
"fmt"
78
"io"
89
"io/ioutil"
910
"os"
1011
"os/exec"
1112
"path/filepath"
13+
"regexp"
1214
"strings"
13-
ctx "context"
1415

1516
"github.com/docker/distribution/context"
1617
storagedriver "github.com/docker/distribution/registry/storage/driver"
@@ -23,9 +24,10 @@ import (
2324
"github.com/drycc/controller-sdk-go/hooks"
2425
"github.com/drycc/pkg/log"
2526
"gopkg.in/yaml.v2"
26-
"k8s.io/client-go/kubernetes"
2727
corev1 "k8s.io/api/core/v1"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29+
"k8s.io/client-go/kubernetes"
30+
"k8s.io/client-go/kubernetes/scheme"
2931
)
3032

3133
// repoCmd returns exec.Command(first, others...) with its current working directory repoDir
@@ -57,6 +59,9 @@ func build(
5759
builderKey,
5860
rawGitSha string) error {
5961

62+
// Rewrite regular expression, compatible with slug type
63+
storagedriver.PathRegexp = regexp.MustCompile(`^([A-Za-z0-9._:-]*(/[A-Za-z0-9._:-]+)*)+$`)
64+
6065
dockerBuilderImagePullPolicy, err := k8s.PullPolicyFromString(conf.DockerBuilderImagePullPolicy)
6166
if err != nil {
6267
return err
@@ -222,6 +227,7 @@ func build(
222227
}
223228

224229
log.Info("Starting build... but first, coffee!")
230+
log.Debug("Use image %s: %s", stack["name"], stack["image"])
225231
log.Debug("Starting pod %s", buildPodName)
226232
json, err := prettyPrintJSON(pod)
227233
if err == nil {
@@ -249,7 +255,7 @@ func build(
249255
req := kubeClient.CoreV1().RESTClient().Get().Namespace(newPod.Namespace).Name(newPod.Name).Resource("pods").SubResource("log").VersionedParams(
250256
&corev1.PodLogOptions{
251257
Follow: true,
252-
}, metav1.ParameterCodec)
258+
}, scheme.ParameterCodec)
253259

254260
rc, err := req.Stream(ctx.TODO())
255261
if err != nil {

pkg/gitreceive/build_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package gitreceive
22

33
import (
44
"bytes"
5+
"context"
56
"errors"
67
"fmt"
8+
"github.com/arschles/assert"
79
"io/ioutil"
810
"os"
911
"os/exec"
1012
"path/filepath"
1113
"testing"
12-
"context"
13-
"github.com/arschles/assert"
1414
//"github.com/docker/distribution/context"
1515
"github.com/docker/distribution/registry/storage/driver/factory"
1616
_ "github.com/docker/distribution/registry/storage/driver/inmemory"

pkg/gitreceive/build_type.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"github.com/drycc/controller-sdk-go/api"
7+
"github.com/drycc/pkg/log"
78
"io/ioutil"
89
"os"
910
"strings"
@@ -60,6 +61,8 @@ func getStack(dirName string, config api.Config) map[string]string {
6061
if len(Stacks) == 0 {
6162
initStack()
6263
}
64+
log.Debug("Stacks: %s", Stacks)
65+
log.Debug("Config values %s", config.Values)
6366
if stackInterface, ok := config.Values["DRYCC_STACK"]; ok {
6467
if strStack, ok := stackInterface.(string); ok {
6568
for _, stack := range Stacks {

pkg/gitreceive/k8s_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88

99
"github.com/drycc/builder/pkg/k8s"
1010
"github.com/pborman/uuid"
11-
"k8s.io/apimachinery/pkg/util/wait"
1211
corev1 "k8s.io/api/core/v1"
1312
apierrors "k8s.io/apimachinery/pkg/api/errors"
1413
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
"k8s.io/apimachinery/pkg/labels"
15+
"k8s.io/apimachinery/pkg/util/wait"
1616
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
1717
)
1818

@@ -66,7 +66,7 @@ func dockerBuilderPod(
6666
registryEnv map[string]string,
6767
pullPolicy corev1.PullPolicy,
6868
nodeSelector map[string]string,
69-
//) *api.Pod {
69+
//) *api.Pod {
7070
) *corev1.Pod {
7171

7272
pod := buildPod(debug, name, namespace, pullPolicy, nodeSelector, env)

pkg/gitreceive/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package gitreceive
22

33
import (
4-
"strings"
54
"context"
5+
"strings"
66

7-
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
87
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
99
)
1010

1111
const (

pkg/healthsrv/healthz_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package healthsrv
22

33
import (
44
"bytes"
5+
"context"
56
"errors"
67
"fmt"
78
"io/ioutil"
89
"net/http"
910
"net/http/httptest"
1011
"strings"
1112
"testing"
12-
"context"
1313
//"github.com/docker/distribution/context"
1414

1515
"github.com/arschles/assert"

pkg/healthsrv/namespace_lister.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// for unit tests.
1515
type NamespaceLister interface {
1616
// List lists all namespaces that are selected by the given label and field selectors.
17-
List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error)
17+
List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error)
1818
}
1919

2020
type emptyNamespaceLister struct{}
@@ -31,7 +31,6 @@ func (e errNamespaceLister) List(ctx context.Context, opts metav1.ListOptions) (
3131
return nil, e.err
3232
}
3333

34-
3534
// listNamespaces calls nl.List(...) and sends the results back on the various given channels.
3635
// This func is intended to be run in a goroutine and communicates via the channels it's passed.
3736
//

pkg/k8s/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ func NewInCluster() (*kubernetes.Clientset, error) {
1717
panic(err.Error())
1818
}
1919
return clientset, nil
20-
}
20+
}

0 commit comments

Comments
 (0)