@@ -5,12 +5,12 @@ import (
5
5
"os"
6
6
"os/signal"
7
7
"path/filepath"
8
+ "strings"
8
9
"syscall"
9
10
"time"
10
11
11
12
dockersync "github.com/Altinity/docker-sync"
12
13
"github.com/Altinity/docker-sync/config"
13
- "github.com/Altinity/docker-sync/logging"
14
14
"github.com/Altinity/docker-sync/structs"
15
15
"github.com/rs/zerolog/log"
16
16
"github.com/spf13/cobra"
@@ -20,6 +20,7 @@ import (
20
20
type syncImage struct {
21
21
Source string `yaml:"source"`
22
22
Targets []string `yaml:"targets"`
23
+ Tags []string `yaml:"tags"`
23
24
MutableTags []string `yaml:"mutableTags"`
24
25
IgnoredTags []string `yaml:"ignoredTags"`
25
26
}
@@ -63,21 +64,21 @@ var syncCmd = &cobra.Command{
63
64
os .Exit (0 )
64
65
}()
65
66
66
- logging .ReloadGlobalLogger ()
67
-
68
67
log .Info ().Msg ("Starting Docker Sync" )
69
68
70
69
cnf := syncConfig {}
71
70
cnf .Ecr .Region , _ = cmd .Flags ().GetString ("ecr-region" )
72
71
73
72
source , _ := cmd .Flags ().GetString ("source" )
74
73
target , _ := cmd .Flags ().GetString ("target" )
74
+ tags , _ := cmd .Flags ().GetStringSlice ("tags" )
75
75
mutableTags , _ := cmd .Flags ().GetStringSlice ("mutableTags" )
76
76
ignoredTags , _ := cmd .Flags ().GetStringSlice ("ignoredTags" )
77
77
78
78
cnf .Sync .Images = append (cnf .Sync .Images , syncImage {
79
79
Source : source ,
80
80
Targets : []string {target },
81
+ Tags : tags ,
81
82
MutableTags : mutableTags ,
82
83
IgnoredTags : ignoredTags ,
83
84
})
@@ -97,7 +98,6 @@ var syncCmd = &cobra.Command{
97
98
imgHelper := structs.Image {}
98
99
99
100
sourceUrl := imgHelper .GetRegistry (source )
100
- targetUrl := imgHelper .GetRegistry (target )
101
101
102
102
if sourceUrl != "" && (sourceUsername != "" || sourcePassword != "" || sourceToken != "" || sourceHelper != "" ) {
103
103
registries = append (registries , syncRegistry {
@@ -112,6 +112,14 @@ var syncCmd = &cobra.Command{
112
112
})
113
113
}
114
114
115
+ var targetUrl string
116
+ if strings .HasPrefix (target , "r2:" ) || strings .HasPrefix (target , "s3:" ) {
117
+ fields := strings .Split (target , ":" )
118
+ targetUrl = strings .Join (fields [:3 ], ":" )
119
+ } else {
120
+ targetUrl = imgHelper .GetRegistry (target )
121
+ }
122
+
115
123
if targetUrl != "" && (targetUsername != "" || targetPassword != "" || targetToken != "" || targetHelper != "" ) {
116
124
registries = append (registries , syncRegistry {
117
125
Auth : syncAuth {
@@ -138,7 +146,7 @@ var syncCmd = &cobra.Command{
138
146
log .Fatal ().Err (err ).Msg ("Failed to marshal configuration" )
139
147
}
140
148
141
- if err := os .WriteFile (filepath .Join (tmpDir , "config.yaml" ), b , 0644 ); err != nil {
149
+ if err := os .WriteFile (filepath .Join (tmpDir , "config.yaml" ), b , 0o644 ); err != nil {
142
150
log .Fatal ().Err (err ).Msg ("Failed to write configuration" )
143
151
}
144
152
@@ -171,6 +179,7 @@ func init() {
171
179
syncCmd .MarkFlagRequired ("source" )
172
180
syncCmd .MarkFlagRequired ("target" )
173
181
182
+ syncCmd .Flags ().StringSliceP ("tags" , "o" , []string {}, "Sync only these tags" )
174
183
syncCmd .Flags ().StringSliceP ("mutable-tags" , "m" , []string {}, "Mutable tags" )
175
184
syncCmd .Flags ().StringSliceP ("ignored-tags" , "i" , []string {}, "Ignored tags" )
176
185
0 commit comments