diff --git a/internal/config/config.go b/internal/config/config.go index cb822d9..ec93307 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -20,8 +20,7 @@ type Config = struct { WoodpeckerAgentVersion string `default:"latest" env:"WOODPECKER_AUTOSCALER_WOODPECKER_AGENT_VERSION"` HcloudToken string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_TOKEN"` HcloudInstanceType string `default:"cpx21" env:"WOODPECKER_AUTOSCALER_HCLOUD_INSTANCE_TYPE"` - HcloudRegion string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_REGION"` - HcloudDatacenter string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_DATACENTER"` + HcloudLocation string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_LOCATION"` HcloudSSHKeys string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_SSH_KEYS"` HcloudIPv6Only bool `default:"false" env:"WOODPECKER_AUTOSCALER_HCLOUD_IPV6_ONLY"` } diff --git a/internal/hetzner/hetzneragent.go b/internal/hetzner/hetzneragent.go index 33f9537..3d83db5 100644 --- a/internal/hetzner/hetzneragent.go +++ b/internal/hetzner/hetzneragent.go @@ -83,12 +83,10 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) { } img, _, err := client.Image.GetByNameAndArchitecture(context.Background(), "docker-ce", "x86") utils.CheckError(err, "GetImageByNameAndArchitecture") - loc, _, err := client.Location.GetByName(context.Background(), cfg.HcloudRegion) + loc, _, err := client.Location.GetByName(context.Background(), cfg.HcloudLocation) utils.CheckError(err, "GetRegionByName") pln, _, err := client.ServerType.GetByName(context.Background(), cfg.HcloudInstanceType) utils.CheckError(err, "GetServerTypeByName") - dc, _, err := client.Datacenter.GetByName(context.Background(), cfg.HcloudDatacenter) - utils.CheckError(err, "GetDatacenterByName") labels := map[string]string{} labels["Role"] = "WoodpeckerAgent" labels["ControledBy"] = "WoodpeckerAutoscaler" @@ -104,7 +102,6 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) { Image: img, SSHKeys: keys, Location: loc, - Datacenter: dc, UserData: userdata, StartAfterCreate: utils.BoolPointer(true), Labels: labels, diff --git a/internal/hetzner/hetzneragent_test.go b/internal/hetzner/hetzneragent_test.go index 5be20d2..3cc53ab 100644 --- a/internal/hetzner/hetzneragent_test.go +++ b/internal/hetzner/hetzneragent_test.go @@ -19,8 +19,7 @@ func TestGenerateUserData(t *testing.T) { WoodpeckerAgentVersion: "latest", HcloudToken: "EvenMoreGeheim1!", HcloudInstanceType: "cpx21", - HcloudRegion: "eu-central", - HcloudDatacenter: "fsn1-dc14", + HcloudLocation: "fsn1", HcloudSSHKeys: "test-key", } wanted := `