Skip to content

Commit

Permalink
feat: implement talosctl config new command
Browse files Browse the repository at this point in the history
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
  • Loading branch information
AlekSi committed Jun 17, 2021
1 parent fa15a66 commit 4ba3285
Show file tree
Hide file tree
Showing 61 changed files with 2,330 additions and 1,716 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
!hack
!internal
!pkg
!vendor
!website
!.golangci.yml
!.markdownlint.json
Expand Down
3 changes: 0 additions & 3 deletions api/cluster/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package cluster;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/cluster";
option java_multiple_files = true;
option java_outer_classname = "ClusterApi";
option java_package = "com.cluster.api";

import "google/protobuf/duration.proto";
import "common/common.proto";
Expand Down
1 change: 1 addition & 0 deletions api/health/health.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/talos-systems/talos/pkg/machinery/api/health";

import "google/protobuf/empty.proto";

// The health service definition.
service Health {
rpc Check(google.protobuf.Empty) returns (HealthCheckResponse);
rpc Watch(HealthWatchRequest) returns (stream HealthCheckResponse);
Expand Down
3 changes: 0 additions & 3 deletions api/inspect/inspect.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package inspect;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/inspect";
option java_multiple_files = true;
option java_outer_classname = "InspectApi";
option java_package = "com.inspect.api";

import "google/protobuf/empty.proto";
import "common/common.proto";
Expand Down
32 changes: 27 additions & 5 deletions api/machine/machine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ syntax = "proto3";
package machine;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/machine";
option java_multiple_files = true;
option java_outer_classname = "MachineApi";
option java_package = "com.machine.api";

import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "common/common.proto";

// The machine service definition.
Expand Down Expand Up @@ -82,6 +80,9 @@ service MachineService {
rpc SystemStat(google.protobuf.Empty) returns (SystemStatResponse);
rpc Upgrade(UpgradeRequest) returns (UpgradeResponse);
rpc Version(google.protobuf.Empty) returns (VersionResponse);

// GenerateClientConfiguration generates talosctl client configuration (talosconfig).
rpc GenerateClientConfiguration(GenerateClientConfigurationRequest) returns (GenerateClientConfigurationResponse);
}

// rpc applyConfiguration
Expand Down Expand Up @@ -486,8 +487,6 @@ message DmesgRequest {
}

// rpc processes
message ProcessesRequest {}

message ProcessesResponse { repeated Process messages = 1; }

message Process {
Expand Down Expand Up @@ -910,3 +909,26 @@ message GenerateConfigurationResponse {
// RemoveBootkubeInitializedKeyResponse describes the response to a RemoveBootkubeInitializedKey request.
message RemoveBootkubeInitializedKey { common.Metadata metadata = 1; }
message RemoveBootkubeInitializedKeyResponse { repeated RemoveBootkubeInitializedKey messages = 1; }

message GenerateClientConfigurationRequest {
// Roles in the generated client certificate.
repeated string roles = 1;
// Client certificate TTL.
google.protobuf.Duration crt_ttl = 2;
}

message GenerateClientConfiguration {
common.Metadata metadata = 1;
// PEM-encoded CA certificate.
bytes ca = 2;
// PEM-encoded generated client certificate.
bytes crt = 3;
// PEM-encoded generated client key.
bytes key = 4;
// Client configuration (talosconfig) file content.
bytes talosconfig = 5;
}

message GenerateClientConfigurationResponse {
repeated GenerateClientConfiguration messages = 1;
}
3 changes: 0 additions & 3 deletions api/network/network.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package network;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/network";
option java_multiple_files = true;
option java_outer_classname = "NetworkApi";
option java_package = "com.network.api";

import "google/protobuf/empty.proto";
import "common/common.proto";
Expand Down
3 changes: 0 additions & 3 deletions api/resource/resource.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package resource;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/resource";
option java_multiple_files = true;
option java_outer_classname = "ResourceApi";
option java_package = "com.resource.api";

import "common/common.proto";

Expand Down
3 changes: 0 additions & 3 deletions api/security/security.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package securityapi;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/security";
option java_multiple_files = true;
option java_outer_classname = "SecurityApi";
option java_package = "com.security.api";

// The security service definition.
service SecurityService {
Expand Down
3 changes: 0 additions & 3 deletions api/storage/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package storage;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/storage";
option java_multiple_files = true;
option java_outer_classname = "StorageApi";
option java_package = "com.storage.api";

import "google/protobuf/empty.proto";
import "common/common.proto";
Expand Down
3 changes: 0 additions & 3 deletions api/time/time.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ syntax = "proto3";
package time;

option go_package = "github.com/talos-systems/talos/pkg/machinery/api/time";
option java_multiple_files = true;
option java_outer_classname = "TimeApi";
option java_package = "com.time.api";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
Expand Down
6 changes: 3 additions & 3 deletions cmd/talosctl/cmd/mgmt/gen/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ var genCSRCmd = &cobra.Command{
return fmt.Errorf("invalid IP: %s", genCSRCmdFlags.ip)
}

roles, err := role.Parse(genCSRCmdFlags.roles)
if err != nil {
return err
roles, unknownRoles := role.Parse(genCSRCmdFlags.roles)
if len(unknownRoles) != 0 {
return fmt.Errorf("unknown roles: %s", strings.Join(unknownRoles, ", "))
}

ips := []net.IP{parsed}
Expand Down
4 changes: 2 additions & 2 deletions cmd/talosctl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/talos-systems/talos/cmd/talosctl/cmd/mgmt"
"github.com/talos-systems/talos/cmd/talosctl/cmd/talos"
"github.com/talos-systems/talos/pkg/machinery/client/config"
clientconfig "github.com/talos-systems/talos/pkg/machinery/client/config"
)

// rootCmd represents the base command when called without any subcommands.
Expand All @@ -29,7 +29,7 @@ var rootCmd = &cobra.Command{
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() error {
defaultTalosConfig, err := config.GetDefaultPath()
defaultTalosConfig, err := clientconfig.GetDefaultPath()
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/talosctl/cmd/talos/apply-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/spf13/cobra"
"github.com/talos-systems/crypto/x509"

"github.com/talos-systems/talos/cmd/talosctl/pkg/talos/helpers"
"github.com/talos-systems/talos/internal/pkg/tui/installer"
"github.com/talos-systems/talos/pkg/cli"
machineapi "github.com/talos-systems/talos/pkg/machinery/api/machine"
Expand Down Expand Up @@ -71,8 +72,8 @@ var applyConfigCmd = &cobra.Command{
if applyConfigCmdFlags.insecure {
ctx := context.Background()

if len(Nodes) != 1 {
return fmt.Errorf("insecure mode requires one and only one node, got %d", len(Nodes))
if err := helpers.FailIfMultiNodes(ctx, "apply-config"); err != nil {
return err
}

c, err := client.New(ctx, client.WithTLSConfig(&tls.Config{
Expand Down
Loading

0 comments on commit 4ba3285

Please sign in to comment.