-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from fabi200123/version-v3
Add provider interface versioning
- Loading branch information
Showing
84 changed files
with
1,614 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2022 Cloudbase Solutions SRL | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. You may obtain | ||
// a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package common | ||
|
||
import "github.com/cloudbase/garm/params" | ||
|
||
// Constants used for the provider interface version. | ||
const ( | ||
Version010 = "v0.1.0" | ||
Version011 = "v0.1.1" | ||
) | ||
|
||
// Each struct is a wrapper for the actual parameters struct for a specific version. | ||
// Version 0.1.0 doesn't have any specific parameters, so there is no need for a struct for it. | ||
type CreateInstanceParams struct { | ||
CreateInstanceV011 CreateInstanceV011Params | ||
} | ||
|
||
type DeleteInstanceParams struct { | ||
DeleteInstanceV011 DeleteInstanceV011Params | ||
} | ||
|
||
type GetInstanceParams struct { | ||
GetInstanceV011 GetInstanceV011Params | ||
} | ||
|
||
type ListInstancesParams struct { | ||
ListInstancesV011 ListInstancesV011Params | ||
} | ||
|
||
type RemoveAllInstancesParams struct { | ||
RemoveAllInstancesV011 RemoveAllInstancesV011Params | ||
} | ||
|
||
type StopParams struct { | ||
StopV011 StopV011Params | ||
} | ||
|
||
type StartParams struct { | ||
StartV011 StartV011Params | ||
} | ||
|
||
// Struct for the base provider parameters. | ||
type ProviderBaseParams struct { | ||
PoolInfo params.Pool | ||
ControllerInfo params.ControllerInfo | ||
} | ||
|
||
// Structs for version v0.1.1. | ||
type CreateInstanceV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type DeleteInstanceV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type GetInstanceV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type ListInstancesV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type RemoveAllInstancesV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type StopV011Params struct { | ||
ProviderBaseParams | ||
} | ||
|
||
type StartV011Params struct { | ||
ProviderBaseParams | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package common | ||
|
||
import ( | ||
garmErrors "github.com/cloudbase/garm-provider-common/errors" | ||
commonParams "github.com/cloudbase/garm-provider-common/params" | ||
"github.com/cloudbase/garm/runner/providers/util" | ||
) | ||
|
||
func ValidateResult(inst commonParams.ProviderInstance) error { | ||
if inst.ProviderID == "" { | ||
return garmErrors.NewProviderError("missing provider ID") | ||
} | ||
|
||
if inst.Name == "" { | ||
return garmErrors.NewProviderError("missing instance name") | ||
} | ||
|
||
if !util.IsValidProviderStatus(inst.Status) { | ||
return garmErrors.NewProviderError("invalid status returned (%s)", inst.Status) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.