Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification checks against VM (Tasks for the user) #149

Closed
wants to merge 14 commits into from
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hobbyfarm/gargantua/pkg/rbacserver"
tls2 "github.com/hobbyfarm/gargantua/pkg/tls"
"github.com/hobbyfarm/gargantua/pkg/webhook/conversion"
"github.com/hobbyfarm/gargantua/pkg/webhook/conversion/scenario"
"github.com/hobbyfarm/gargantua/pkg/webhook/conversion/user"
"golang.org/x/sync/errgroup"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -44,7 +45,7 @@ import (
"github.com/hobbyfarm/gargantua/pkg/courseclient"
"github.com/hobbyfarm/gargantua/pkg/courseserver"
"github.com/hobbyfarm/gargantua/pkg/environmentserver"
"github.com/hobbyfarm/gargantua/pkg/predefinedserviceserver"
predefinedservicesserver "github.com/hobbyfarm/gargantua/pkg/predefinedserviceserver"
"github.com/hobbyfarm/gargantua/pkg/progressserver"
"github.com/hobbyfarm/gargantua/pkg/scenarioclient"
"github.com/hobbyfarm/gargantua/pkg/scenarioserver"
Expand Down Expand Up @@ -313,6 +314,7 @@ func main() {
// shell server does not serve webhook endpoint, so don't start it
if !shellServer {
user.Init()
scenario.Init()
conversionRouter := mux.NewRouter()
conversion.New(conversionRouter, apiExtensionsClient, string(ca))

Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/hobbyfarm.io/v2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&User{},
&UserList{},
&Scenario{},
&ScenarioList{},
)

metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
Expand Down
48 changes: 48 additions & 0 deletions pkg/apis/hobbyfarm.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,51 @@ type UserSpec struct {
AccessCodes []string `json:"access_codes"`
Settings map[string]string `json:"settings"`
}

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Scenario struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ScenarioSpec `json:"spec"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ScenarioList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Scenario `json:"items"`
}

type ScenarioSpec struct {
Name string `json:"name"`
Description string `json:"description"`
Steps []ScenarioStep `json:"steps"`
Categories []string `json:"categories"`
Tags []string `json:"tags"`
VirtualMachines []map[string]string `json:"virtualmachines"`
KeepAliveDuration string `json:"keepalive_duration"`
PauseDuration string `json:"pause_duration"`
Pauseable bool `json:"pauseable"`
Tasks []VirtualMachineTasks `json:"vm_tasks"`

}

type VirtualMachineTasks struct{
VMName string `json:"vm_name"`
Tasks []Task `json:"task_command"`
}
type Task struct{
Name string `json:"name"`
Description string `json:"description"`
Command string `json:"command"`
ExpectedOutputValue string `json:"expected_output_value"`
ExpectedReturnCode int `json:"expected_return_code"`
}

type ScenarioStep struct {
Title string `json:"title"`
Content string `json:"content"`
}
164 changes: 164 additions & 0 deletions pkg/apis/hobbyfarm.io/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading