Skip to content

Commit cd237c9

Browse files
authored
Merge pull request #5 from rsmitty/master
fix: better secret detection and update talos
2 parents 60baf9a + 6778a95 commit cd237c9

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

controllers/secrets.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ func (r *TalosConfigReconciler) fetchInputSecret(ctx context.Context, config *bo
4141
return inputSecret, nil
4242
}
4343

44-
func (r *TalosConfigReconciler) writeInputSecret(ctx context.Context, config *bootstrapv1alpha2.TalosConfig, clusterName string, input *generate.Input) error {
44+
func (r *TalosConfigReconciler) writeInputSecret(ctx context.Context, config *bootstrapv1alpha2.TalosConfig, clusterName string, input *generate.Input) (*corev1.Secret, error) {
4545

4646
certMarshal, err := yaml.Marshal(input.Certs)
4747
if err != nil {
48-
return err
48+
return nil, err
4949
}
5050

5151
kubeTokenMarshal, err := yaml.Marshal(input.KubeadmTokens)
5252
if err != nil {
53-
return err
53+
return nil, err
5454
}
5555

5656
trustdInfoMarshal, err := yaml.Marshal(input.TrustdInfo)
5757
if err != nil {
58-
return err
58+
return nil, err
5959
}
6060

6161
certSecret := &corev1.Secret{
@@ -72,7 +72,7 @@ func (r *TalosConfigReconciler) writeInputSecret(ctx context.Context, config *bo
7272

7373
err = r.Client.Create(ctx, certSecret)
7474
if err != nil {
75-
return err
75+
return nil, err
7676
}
77-
return nil
77+
return certSecret, nil
7878
}

controllers/talosconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (r *TalosConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, rerr
148148

149149
inputSecret, err := r.fetchInputSecret(ctx, config, cluster.ObjectMeta.Name)
150150
if machineType == generate.TypeInit && k8serrors.IsNotFound(err) {
151-
err = r.writeInputSecret(ctx, config, cluster.ObjectMeta.Name, input)
151+
inputSecret, err = r.writeInputSecret(ctx, config, cluster.ObjectMeta.Name, input)
152152
if err != nil {
153153
return ctrl.Result{}, err
154154
}

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ require (
66
github.com/go-logr/logr v0.1.0
77
github.com/onsi/ginkgo v1.8.0
88
github.com/onsi/gomega v1.5.0
9-
github.com/talos-systems/talos v0.3.0-alpha.4
10-
gopkg.in/yaml.v2 v2.2.2
11-
k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
12-
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655
9+
github.com/talos-systems/talos v0.3.0-alpha.5
10+
gopkg.in/yaml.v2 v2.2.4
11+
k8s.io/api v0.0.0-20191016110408-35e52d86657a
12+
k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8
1313
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
1414
sigs.k8s.io/cluster-api v0.2.5
1515
sigs.k8s.io/controller-runtime v0.3.0

go.sum

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ github.com/talos-systems/talos v0.3.0-alpha.1.0.20191016174505-d0111fe617bb h1:b
260260
github.com/talos-systems/talos v0.3.0-alpha.1.0.20191016174505-d0111fe617bb/go.mod h1:22KcKkZ3l69bN1STZ4g4dzs3FapgnFxnNY8xEQOK694=
261261
github.com/talos-systems/talos v0.3.0-alpha.4 h1:eCIAjzji5cCgIpD8HxWu8qGPnj1gA+y2jEpvfR1vIWg=
262262
github.com/talos-systems/talos v0.3.0-alpha.4/go.mod h1:22KcKkZ3l69bN1STZ4g4dzs3FapgnFxnNY8xEQOK694=
263+
github.com/talos-systems/talos v0.3.0-alpha.5 h1:lH8azTDAukRyZI1zENww1IBW93u1pIn2wfeuikziwDM=
264+
github.com/talos-systems/talos v0.3.0-alpha.5/go.mod h1:o2aQ668ToodnHREccDTZi6dVxKHRmr0vlcsCDVHkn7Q=
265+
github.com/talos-systems/talos v0.3.0-alpha.5.0.20191105183433-4b3cc34ab044 h1:gi+hLvwB0oGPKi165T4fliiui42m3ReF+QfxmvXGx1s=
266+
github.com/talos-systems/talos v0.3.0-alpha.5.0.20191105183433-4b3cc34ab044/go.mod h1:o2aQ668ToodnHREccDTZi6dVxKHRmr0vlcsCDVHkn7Q=
263267
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
264268
github.com/u-root/u-root v6.0.0+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
265269
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
@@ -394,6 +398,7 @@ gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa
394398
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
395399
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
396400
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
401+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
397402
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
398403
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
399404
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

0 commit comments

Comments
 (0)