Skip to content

Commit

Permalink
chore: remove deprecated "join" term
Browse files Browse the repository at this point in the history
Closes #3910.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@talos-systems.com>
  • Loading branch information
AlekSi committed Sep 27, 2021
1 parent 0e18e28 commit d2cf021
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 60 deletions.
13 changes: 0 additions & 13 deletions cmd/talosctl/cmd/mgmt/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ var (
configPatch string
configPatchControlPlane string
configPatchWorker string
configPatchJoin string
badRTC bool
)

Expand All @@ -125,14 +124,6 @@ var createCmd = &cobra.Command{

//nolint:gocyclo,cyclop
func create(ctx context.Context) (err error) {
if configPatchJoin != "" {
if configPatchWorker != "" {
return fmt.Errorf("both --config-patch-join and --config-patch-worker are passed")
}

configPatchWorker = configPatchJoin
}

if masters < 1 {
return fmt.Errorf("number of masters can't be less than 1")
}
Expand Down Expand Up @@ -845,9 +836,5 @@ func init() {
createCmd.Flags().StringVar(&configPatchWorker, "config-patch-worker", "", "patch generated machineconfigs (applied to 'worker' type)")
createCmd.Flags().BoolVar(&badRTC, "bad-rtc", false, "launch VM with bad RTC state (QEMU only)")

// remove in 0.13: https://github.com/talos-systems/talos/issues/3910
createCmd.Flags().StringVar(&configPatchJoin, "config-patch-join", "", "")
cli.Should(createCmd.Flags().MarkDeprecated("config-patch-join", "use --config-patch-worker instead"))

Cmd.AddCommand(createCmd)
}
14 changes: 0 additions & 14 deletions cmd/talosctl/cmd/mgmt/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/talos-systems/talos/cmd/talosctl/cmd/mgmt/gen"
"github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
"github.com/talos-systems/talos/pkg/cli"
"github.com/talos-systems/talos/pkg/images"
"github.com/talos-systems/talos/pkg/machinery/config"
"github.com/talos-systems/talos/pkg/machinery/config/encoder"
Expand All @@ -42,7 +41,6 @@ var genConfigCmdFlags struct {
configPatch string
configPatchControlPlane string
configPatchWorker string
configPatchJoin string
registryMirrors []string
persistConfig bool
withExamples bool
Expand All @@ -59,14 +57,6 @@ this is the port that the API server binds to on every control plane node. For a
setup, usually involving a load balancer, use the IP and port of the load balancer.`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
if genConfigCmdFlags.configPatchJoin != "" {
if genConfigCmdFlags.configPatchWorker != "" {
return fmt.Errorf("both --config-patch-join and --config-patch-worker are passed")
}

genConfigCmdFlags.configPatchWorker = genConfigCmdFlags.configPatchJoin
}

// Validate url input to ensure it has https:// scheme before we attempt to gen
u, err := url.Parse(args[1])
if err != nil {
Expand Down Expand Up @@ -284,9 +274,5 @@ func init() {
genConfigCmd.Flags().BoolVarP(&genConfigCmdFlags.withExamples, "with-examples", "", true, "renders all machine configs with the commented examples")
genConfigCmd.Flags().BoolVarP(&genConfigCmdFlags.withDocs, "with-docs", "", true, "renders all machine configs adding the documentation for each field")

// remove in 0.13: https://github.com/talos-systems/talos/issues/3910
genConfigCmd.Flags().StringVar(&genConfigCmdFlags.configPatchJoin, "config-patch-join", "", "")
cli.Should(genConfigCmd.Flags().MarkDeprecated("config-patch-join", "use --config-patch-worker instead"))

gen.Cmd.AddCommand(genConfigCmd)
}
3 changes: 0 additions & 3 deletions pkg/machinery/config/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ type ProviderBundle interface {
Init() Provider
ControlPlane() Provider
Worker() Provider
// Deprecated: use Worker instead; this method will be removed in 0.13
// (https://github.com/talos-systems/talos/issues/3910).
Join() Provider
TalosConfig() *clientconfig.Config
}
8 changes: 6 additions & 2 deletions pkg/machinery/config/types/v1alpha1/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ func NewConfigBundle(opts ...Option) (*v1alpha1.ConfigBundle, error) {
return bundle, err
}

switch configType { //nolint:exhaustive
switch configType {
case machine.TypeInit:
bundle.InitCfg = unmarshalledConfig
case machine.TypeControlPlane:
bundle.ControlPlaneCfg = unmarshalledConfig
case machine.TypeWorker:
bundle.WorkerCfg = unmarshalledConfig
case machine.TypeUnknown:
fallthrough
default:
panic("unreachable")
}
Expand Down Expand Up @@ -116,13 +118,15 @@ func NewConfigBundle(opts ...Option) (*v1alpha1.ConfigBundle, error) {
return bundle, err
}

switch configType { //nolint:exhaustive
switch configType {
case machine.TypeInit:
bundle.InitCfg = generatedConfig
case machine.TypeControlPlane:
bundle.ControlPlaneCfg = generatedConfig
case machine.TypeWorker:
bundle.WorkerCfg = generatedConfig
case machine.TypeUnknown:
fallthrough
default:
panic("unreachable")
}
Expand Down
12 changes: 0 additions & 12 deletions pkg/machinery/config/types/v1alpha1/bundle/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,3 @@ func WithJSONPatchWorker(patch jsonpatch.Patch) Option {
return nil
}
}

// WithJSONPatchJoin is WithJSONPatchWorker.
//
// Deprecated: use WithJSONPatchWorker instead; this function will be removed in 0.13
// (https://github.com/talos-systems/talos/issues/3910).
func WithJSONPatchJoin(patch jsonpatch.Patch) Option {
return func(o *Options) error {
o.JSONPatchWorker = append(o.JSONPatchWorker, patch...)

return nil
}
}
6 changes: 0 additions & 6 deletions pkg/machinery/config/types/v1alpha1/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ const (
// TypeWorker designates the node as a worker node.
// This means it will be an available compute node for scheduling workloads.
TypeWorker // worker

// TypeJoin is the same as TypeWorker.
//
// Deprecated: use TypeWorker instead; this constant will be removed in 0.13
// (https://github.com/talos-systems/talos/issues/3910).
TypeJoin = TypeWorker
)

// ParseType parses string constant as Type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestParseType(t *testing.T) {
assert.EqualValues(t, machineapi.MachineConfig_TYPE_INIT, machine.TypeInit)
assert.EqualValues(t, machineapi.MachineConfig_TYPE_CONTROL_PLANE, machine.TypeControlPlane)
assert.EqualValues(t, machineapi.MachineConfig_TYPE_WORKER, machine.TypeWorker)
assert.EqualValues(t, machineapi.MachineConfig_TYPE_JOIN, machine.TypeJoin) //nolint:staticcheck
assert.EqualValues(t, machineapi.MachineConfig_TYPE_JOIN, machine.TypeWorker) //nolint:staticcheck
})

validTests := []struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ func (c *ConfigBundle) Worker() config.Provider {
return c.WorkerCfg
}

// Join implements the ProviderBundle interface.
//
// Deprecated: use Worker instead; this method will be removed in 0.13
// (https://github.com/talos-systems/talos/issues/3910).
func (c *ConfigBundle) Join() config.Provider {
return c.WorkerCfg
}

// TalosConfig implements the ProviderBundle interface.
func (c *ConfigBundle) TalosConfig() *clientconfig.Config {
return c.TalosCfg
Expand Down
5 changes: 4 additions & 1 deletion pkg/machinery/config/types/v1alpha1/v1alpha1_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c *Config) Validate(mode config.RuntimeMode, options ...config.ValidationO
warnings = append(warnings, fmt.Sprintf("use %q instead of %q for machine type", t.String(), c.MachineConfig.MachineType))
}

switch c.Machine().Type() { //nolint:exhaustive
switch c.Machine().Type() {
case machine.TypeInit, machine.TypeControlPlane:
warn, err := ValidateCNI(c.Cluster().Network().CNI())
warnings = append(warnings, warn...)
Expand All @@ -118,6 +118,9 @@ func (c *Config) Validate(mode config.RuntimeMode, options ...config.ValidationO
}
}

case machine.TypeUnknown:
fallthrough

default:
result = multierror.Append(result, fmt.Errorf("unknown machine type %q", c.MachineConfig.MachineType))
}
Expand Down

0 comments on commit d2cf021

Please sign in to comment.