Skip to content

Commit fd997ea

Browse files
authored
Merge pull request #11 from FortnoxAB/feature/curl
Add curl in image
2 parents 7431331 + 1e88316 commit fd997ea

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM alpine:3.21
2-
RUN apk add --no-cache tzdata ca-certificates
2+
RUN apk add --no-cache tzdata ca-certificates curl
33
WORKDIR /
44
COPY gmc gmc
55
USER nobody

pkg/master/cloner.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package master
2+
3+
import (
4+
"context"
5+
"net/url"
6+
"os"
7+
"path/filepath"
8+
9+
"github.com/fluxcd/pkg/git"
10+
"github.com/fluxcd/pkg/git/repository"
11+
"github.com/sirupsen/logrus"
12+
)
13+
14+
type Cloner interface {
15+
Clone(ctx context.Context, url string, cloneOpts repository.CloneConfig) (*git.Commit, error)
16+
Close()
17+
}
18+
19+
type testCloner struct {
20+
dir string
21+
}
22+
23+
func (tc *testCloner) Clone(ctx context.Context, URL string, cloneOpts repository.CloneConfig) (*git.Commit, error) {
24+
25+
u, err := url.Parse(URL)
26+
if err != nil {
27+
return nil, err
28+
}
29+
cwd, err := os.Getwd()
30+
if err != nil {
31+
return nil, err
32+
}
33+
34+
from := filepath.Join(cwd, u.Path)
35+
logrus.Infof("testCloner: copy %s to %s", from, tc.dir)
36+
err = os.CopyFS(tc.dir, os.DirFS(from))
37+
return nil, err
38+
}
39+
func (tc *testCloner) Close() {
40+
41+
}

pkg/master/master.go

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ import (
2727
"k8s.io/apimachinery/pkg/labels"
2828
)
2929

30-
/*
31-
TODO
32-
Think about HA?
33-
HA
34-
* clients connect to prefered master
35-
* admin command knows all masters
36-
* do we want leaderelection so only one syncs from git? Probably!
37-
* how to ensure clients fetches from the current leader?
38-
39-
*/
40-
4130
type websocketRequestResponse struct {
4231
list map[string]chan *websocketRequest
4332
mutex *sync.RWMutex
@@ -264,13 +253,6 @@ func (m *Master) run(ctx context.Context) error {
264253
}
265254
}
266255

267-
// if ref := obj.Spec.Reference; ref != nil {
268-
// https://github.com/fluxcd/source-controller/blob/16fed8995d1f5ba818697220fd2020f78e2cc630/controllers/gitrepository_controller.go#L733
269-
// cloneOpts.Branch = ref.Branch
270-
// cloneOpts.Commit = ref.Commit
271-
// cloneOpts.Tag = ref.Tag
272-
// cloneOpts.SemVer = ref.SemVer
273-
// }
274256
}
275257

276258
func (m *Master) stateRunner(ctx context.Context, ch chan *types.Machine, websocketCh chan *websocketRequest, machineUpd chan machineUpdate) {
@@ -474,7 +456,7 @@ func (m *Master) handleRequest(ctx context.Context, machines map[string]*types.M
474456
machineUpdateCh <- machineUpdate{Machine: machine, Source: protocol.ManualSource}
475457

476458
case "agent-aqure-lock":
477-
if admin, _ := sess.Get("allowed"); !admin.(bool) {
459+
if allowed, _ := sess.Get("allowed"); !allowed.(bool) {
478460
return fmt.Errorf("agent-aqure-lock permission denied")
479461
}
480462
l := &protocol.AgentLock{}
@@ -566,35 +548,6 @@ func sendIsLast(sess *melody.Session, reqID string) {
566548
}
567549
}
568550

569-
type Cloner interface {
570-
Clone(ctx context.Context, url string, cloneOpts repository.CloneConfig) (*git.Commit, error)
571-
Close()
572-
}
573-
574-
type testCloner struct {
575-
dir string
576-
}
577-
578-
func (tc *testCloner) Clone(ctx context.Context, URL string, cloneOpts repository.CloneConfig) (*git.Commit, error) {
579-
580-
u, err := url.Parse(URL)
581-
if err != nil {
582-
return nil, err
583-
}
584-
cwd, err := os.Getwd()
585-
if err != nil {
586-
return nil, err
587-
}
588-
589-
from := filepath.Join(cwd, u.Path)
590-
logrus.Infof("testCloner: copy %s to %s", from, tc.dir)
591-
err = os.CopyFS(tc.dir, os.DirFS(from))
592-
return nil, err
593-
}
594-
func (tc *testCloner) Close() {
595-
596-
}
597-
598551
func (m *Master) clone(ctx context.Context, authOpts *git.AuthOptions, cloneOpts repository.CloneConfig, manifestCh chan machineUpdate) error {
599552
dir, err := os.MkdirTemp("", "gmc")
600553
if err != nil {

0 commit comments

Comments
 (0)