@@ -50,6 +50,7 @@ import (
50
50
dbobjectv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/dbobject/v1"
51
51
dbobjectimportrulev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/dbobjectimportrule/v1"
52
52
devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1"
53
+ headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
53
54
loginrulepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/loginrule/v1"
54
55
machineidv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
55
56
pluginsv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/plugins/v1"
@@ -3756,6 +3757,13 @@ func (rc *ResourceCommand) createAutoUpdateConfig(ctx context.Context, client *a
3756
3757
return trace .Wrap (err )
3757
3758
}
3758
3759
3760
+ if config .GetMetadata () == nil {
3761
+ config .Metadata = & headerv1.Metadata {}
3762
+ }
3763
+ if config .GetMetadata ().GetName () == "" {
3764
+ config .Metadata .Name = types .MetaNameAutoUpdateConfig
3765
+ }
3766
+
3759
3767
if rc .IsForced () {
3760
3768
_ , err = client .UpsertAutoUpdateConfig (ctx , config )
3761
3769
} else {
@@ -3774,6 +3782,14 @@ func (rc *ResourceCommand) updateAutoUpdateConfig(ctx context.Context, client *a
3774
3782
if err != nil {
3775
3783
return trace .Wrap (err )
3776
3784
}
3785
+
3786
+ if config .GetMetadata () == nil {
3787
+ config .Metadata = & headerv1.Metadata {}
3788
+ }
3789
+ if config .GetMetadata ().GetName () == "" {
3790
+ config .Metadata .Name = types .MetaNameAutoUpdateConfig
3791
+ }
3792
+
3777
3793
if _ , err := client .UpdateAutoUpdateConfig (ctx , config ); err != nil {
3778
3794
return trace .Wrap (err )
3779
3795
}
@@ -3787,6 +3803,13 @@ func (rc *ResourceCommand) createAutoUpdateVersion(ctx context.Context, client *
3787
3803
return trace .Wrap (err )
3788
3804
}
3789
3805
3806
+ if version .GetMetadata () == nil {
3807
+ version .Metadata = & headerv1.Metadata {}
3808
+ }
3809
+ if version .GetMetadata ().GetName () == "" {
3810
+ version .Metadata .Name = types .MetaNameAutoUpdateVersion
3811
+ }
3812
+
3790
3813
if rc .IsForced () {
3791
3814
_ , err = client .UpsertAutoUpdateVersion (ctx , version )
3792
3815
} else {
@@ -3805,6 +3828,14 @@ func (rc *ResourceCommand) updateAutoUpdateVersion(ctx context.Context, client *
3805
3828
if err != nil {
3806
3829
return trace .Wrap (err )
3807
3830
}
3831
+
3832
+ if version .GetMetadata () == nil {
3833
+ version .Metadata = & headerv1.Metadata {}
3834
+ }
3835
+ if version .GetMetadata ().GetName () == "" {
3836
+ version .Metadata .Name = types .MetaNameAutoUpdateVersion
3837
+ }
3838
+
3808
3839
if _ , err := client .UpdateAutoUpdateVersion (ctx , version ); err != nil {
3809
3840
return trace .Wrap (err )
3810
3841
}
@@ -3813,15 +3844,22 @@ func (rc *ResourceCommand) updateAutoUpdateVersion(ctx context.Context, client *
3813
3844
}
3814
3845
3815
3846
func (rc * ResourceCommand ) createAutoUpdateAgentRollout (ctx context.Context , client * authclient.Client , raw services.UnknownResource ) error {
3816
- version , err := services.UnmarshalProtoResource [* autoupdatev1pb.AutoUpdateAgentRollout ](raw .Raw )
3847
+ rollout , err := services.UnmarshalProtoResource [* autoupdatev1pb.AutoUpdateAgentRollout ](raw .Raw )
3817
3848
if err != nil {
3818
3849
return trace .Wrap (err )
3819
3850
}
3820
3851
3852
+ if rollout .GetMetadata () == nil {
3853
+ rollout .Metadata = & headerv1.Metadata {}
3854
+ }
3855
+ if rollout .GetMetadata ().GetName () == "" {
3856
+ rollout .Metadata .Name = types .MetaNameAutoUpdateAgentRollout
3857
+ }
3858
+
3821
3859
if rc .IsForced () {
3822
- _ , err = client .UpsertAutoUpdateAgentRollout (ctx , version )
3860
+ _ , err = client .UpsertAutoUpdateAgentRollout (ctx , rollout )
3823
3861
} else {
3824
- _ , err = client .CreateAutoUpdateAgentRollout (ctx , version )
3862
+ _ , err = client .CreateAutoUpdateAgentRollout (ctx , rollout )
3825
3863
}
3826
3864
if err != nil {
3827
3865
return trace .Wrap (err )
@@ -3832,11 +3870,19 @@ func (rc *ResourceCommand) createAutoUpdateAgentRollout(ctx context.Context, cli
3832
3870
}
3833
3871
3834
3872
func (rc * ResourceCommand ) updateAutoUpdateAgentRollout (ctx context.Context , client * authclient.Client , raw services.UnknownResource ) error {
3835
- version , err := services.UnmarshalProtoResource [* autoupdatev1pb.AutoUpdateAgentRollout ](raw .Raw )
3873
+ rollout , err := services.UnmarshalProtoResource [* autoupdatev1pb.AutoUpdateAgentRollout ](raw .Raw )
3836
3874
if err != nil {
3837
3875
return trace .Wrap (err )
3838
3876
}
3839
- if _ , err := client .UpdateAutoUpdateAgentRollout (ctx , version ); err != nil {
3877
+
3878
+ if rollout .GetMetadata () == nil {
3879
+ rollout .Metadata = & headerv1.Metadata {}
3880
+ }
3881
+ if rollout .GetMetadata ().GetName () == "" {
3882
+ rollout .Metadata .Name = types .MetaNameAutoUpdateAgentRollout
3883
+ }
3884
+
3885
+ if _ , err := client .UpdateAutoUpdateAgentRollout (ctx , rollout ); err != nil {
3840
3886
return trace .Wrap (err )
3841
3887
}
3842
3888
fmt .Println ("autoupdate_version has been updated" )
0 commit comments