@@ -75,6 +75,8 @@ func (c HTTP) call(ctx context.Context) error {
75
75
76
76
os .MkdirAll (c .GetHome (), os .ModePerm )
77
77
dest := filepath .Join (c .GetHome (), filepath .Base (c .URL ))
78
+
79
+ log .Printf ("[DEBUG] http: %s: copying %q to %q" , c .GetName (), c .URL , dest )
78
80
file , err := os .Create (dest )
79
81
if err != nil {
80
82
return err
@@ -102,17 +104,6 @@ func (c HTTP) Install(ctx context.Context, status chan<- Status) error {
102
104
// Go installing step!
103
105
}
104
106
105
- url , err := templates .New (data .New (data .WithPackage (c ))).
106
- Replace (c .Templates .Replacements ).
107
- Apply (c .URL )
108
- if err != nil {
109
- return err
110
- }
111
- if url != c .URL {
112
- log .Printf ("[DEBUG] %s: templating url %s" , c .GetName (), url )
113
- c .URL = url
114
- }
115
-
116
107
ctx , cancel := context .WithCancel (ctx )
117
108
defer cancel ()
118
109
@@ -252,3 +243,18 @@ func (c HTTP) GetDependsOn() []string {
252
243
func (c HTTP ) GetResource () state.Resource {
253
244
return getResource (c )
254
245
}
246
+
247
+ func (c * HTTP ) ParseURL () {
248
+ templated , err := templates .New (data .New (data .WithPackage (c ))).
249
+ Replace (c .Templates .Replacements ).
250
+ Apply (c .URL )
251
+ if err != nil {
252
+ log .Printf ("[ERROR] %s: failed to parse URL" , c .GetName ())
253
+ return
254
+ }
255
+ if templated != c .URL {
256
+ log .Printf ("[TRACE] %s: templating URL %q to %q" , c .GetName (), c .URL , templated )
257
+ c .URL = templated
258
+ }
259
+ return
260
+ }
0 commit comments