Skip to content

Commit daec04a

Browse files
committed
🌱 Remove unused hrobot:// prefix support and clean up constants
1 parent d6353f7 commit daec04a

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

internal/providerid/providerid.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@ const (
1212
// It MUST not be changed, otherwise existing nodes will not be recognized anymore.
1313
prefixCloud = "hcloud://"
1414

15-
// prefixRobot is the prefix for Robot Server provider IDs.
16-
//
17-
// It MUST not be changed, otherwise existing nodes will not be recognized anymore.
18-
prefixRobot = "hrobot://"
19-
20-
// prefixRobot is the prefix used by the Syself Fork for Robot Server provider IDs.
21-
// This Prefix is no longer used for new nodes, instead [prefixRobot] should be used.
15+
// prefixRobotLegacy is the prefix used by the Syself Fork for Robot Server provider IDs.
16+
// This Prefix is no longer used for new nodes, instead prefix "hrobot://" should be used.
2217
//
2318
// It MUST not be changed, otherwise existing nodes will not be recognized anymore.
2419
prefixRobotLegacy = "hcloud://bm-"
@@ -30,9 +25,8 @@ type UnkownPrefixError struct {
3025

3126
func (e *UnkownPrefixError) Error() string {
3227
return fmt.Sprintf(
33-
"Provider ID does not have one of the the expected prefixes (%s, %s, %s): %s",
28+
"Provider ID does not have one of the the expected prefixes (%s, %s): %s",
3429
prefixCloud,
35-
prefixRobot,
3630
prefixRobotLegacy,
3731
e.ProviderID,
3832
)
@@ -46,9 +40,6 @@ func (e *UnkownPrefixError) Error() string {
4640
func ToServerID(providerID string) (id int64, isCloudServer bool, err error) {
4741
idString := ""
4842
switch {
49-
case strings.HasPrefix(providerID, prefixRobot):
50-
idString = strings.ReplaceAll(providerID, prefixRobot, "")
51-
5243
case strings.HasPrefix(providerID, prefixRobotLegacy):
5344
// This case needs to be before [prefixCloud], as [prefixCloud] is a superset of [prefixRobotLegacy]
5445
idString = strings.ReplaceAll(providerID, prefixRobotLegacy, "")

internal/providerid/providerid_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ func TestToServerID(t *testing.T) {
9292
wantIsCloudServer: false,
9393
wantErr: errors.New("providerID is missing a serverID: hcloud://"),
9494
},
95-
{
96-
name: "[robot] simple id",
97-
providerID: "hrobot://4321",
98-
wantID: 4321,
99-
wantIsCloudServer: false,
100-
wantErr: nil,
101-
},
102-
{
103-
name: "[robot] invalid id",
104-
providerID: "hrobot://my-robot",
105-
wantID: 0,
106-
wantIsCloudServer: false,
107-
wantErr: errors.New("unable to parse server id: hrobot://my-robot"),
108-
},
109-
{
110-
name: "[robot] missing id",
111-
providerID: "hrobot://",
112-
wantID: 0,
113-
wantIsCloudServer: false,
114-
wantErr: errors.New("providerID is missing a serverID: hrobot://"),
115-
},
11695
{
11796
name: "[robot-syself] simple id",
11897
providerID: "hcloud://bm-4321",
@@ -206,7 +185,6 @@ func FuzzRoundTripRobot(f *testing.F) {
206185

207186
func FuzzToServerId(f *testing.F) {
208187
f.Add("hcloud://123123123")
209-
f.Add("hrobot://123123123")
210188
f.Add("hcloud://bm-123123123")
211189

212190
f.Fuzz(func(t *testing.T, providerID string) {

0 commit comments

Comments
 (0)