Remove state file

This commit is contained in:
katexochen 2022-10-11 12:24:33 +02:00 committed by Paul Meyer
parent 0d1fd8fb2a
commit 1556e239ca
28 changed files with 381 additions and 319 deletions

View file

@ -6,7 +6,10 @@ SPDX-License-Identifier: AGPL-3.0-only
package cloudprovider
import "strings"
import (
"encoding/json"
"strings"
)
//go:generate stringer -type=Provider
@ -21,6 +24,21 @@ const (
QEMU
)
// MarshalJSON marshals the Provider to JSON string.
func (p Provider) MarshalJSON() ([]byte, error) {
return json.Marshal(p.String())
}
// UnmarshalJSON unmarshals the Provider from JSON string.
func (p *Provider) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
*p = FromString(s)
return nil
}
// FromString returns cloud provider from string.
func FromString(s string) Provider {
s = strings.ToLower(s)