Skip to content

Commit 658f48a

Browse files
committed
feat: support getting cluster template files by http urls
This is required if we want capi-utils to use our templates repo. Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
1 parent e0cadf5 commit 658f48a

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

pkg/capi/deploy.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"io/ioutil"
1111
"log"
12-
"os"
1312
"strconv"
1413
"time"
1514

@@ -37,6 +36,7 @@ type DeployOptions struct {
3736
ClusterNamespace string
3837
TalosVersion string
3938
KubernetesVersion string
39+
TemplateFile string
4040
Template []byte
4141
ControlPlaneNodes int64
4242
WorkerNodes int64
@@ -110,17 +110,7 @@ func WithKubernetesVersion(version string) DeployOption {
110110
// WithTemplateFile load cluster template from the file.
111111
func WithTemplateFile(path string) DeployOption {
112112
return func(o *DeployOptions) error {
113-
f, err := os.Open(path)
114-
if err != nil {
115-
return err
116-
}
117-
118-
defer f.Close() //nolint:errcheck
119-
120-
o.Template, err = ioutil.ReadAll(f)
121-
if err != nil {
122-
return err
123-
}
113+
o.TemplateFile = path
124114

125115
return nil
126116
}
@@ -232,6 +222,10 @@ func (clusterAPI *Manager) DeployCluster(ctx context.Context, clusterName string
232222
}
233223

234224
defer file.Close() //nolint:errcheck
225+
} else if options.TemplateFile != "" {
226+
templateOptions.URLSource = &client.URLSourceOptions{
227+
URL: options.TemplateFile,
228+
}
235229
}
236230

237231
vars, err := provider.ClusterVars(options.providerOptions)

pkg/capi/infrastructure/aws.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type AWSDeployOptions struct {
7373
VPCID string
7474
Subnet string
7575
CloudProviderVersion string
76+
CalicoVersion string
7677
ControlPlaneVolSize int64
7778
NodeVolSize int64
7879
}
@@ -87,6 +88,7 @@ func NewAWSDeployOptions() *AWSDeployOptions {
8788
NodeMachineType: "t3.large",
8889
NodeIAMProfile: "CAPI_AWS_Worker",
8990
CloudProviderVersion: "v1.20.0-alpha.0",
91+
CalicoVersion: "3.18",
9092
}
9193
}
9294

@@ -182,6 +184,7 @@ func (s *AWSProvider) ClusterVars(opts interface{}) (Variables, error) {
182184
"AWS_NODE_IAM_PROFILE": deployOptions.NodeIAMProfile,
183185
"AWS_NODE_AMI_ID": deployOptions.NodeAMIID,
184186
"AWS_CLOUD_PROVIDER_VERSION": deployOptions.CloudProviderVersion,
187+
"CALICO_VERSION": deployOptions.CalicoVersion,
185188
}
186189

187190
return vars, nil

0 commit comments

Comments
 (0)