diff --git a/cmd/arduino-app-cli/app/new.go b/cmd/arduino-app-cli/app/new.go index 066f9a7b..fec533b9 100644 --- a/cmd/arduino-app-cli/app/new.go +++ b/cmd/arduino-app-cli/app/new.go @@ -32,7 +32,6 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command { icon string description string bricks []string - noPyton bool noSketch bool fromApp string ) @@ -44,7 +43,7 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { cobra.MinimumNArgs(1) name := args[0] - return createHandler(cmd.Context(), cfg, name, icon, description, noPyton, noSketch, fromApp) + return createHandler(cmd.Context(), cfg, name, icon, description, noSketch, fromApp) }, } @@ -52,14 +51,12 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command { cmd.Flags().StringVarP(&description, "description", "d", "", "Description for the app") cmd.Flags().StringVarP(&fromApp, "from-app", "", "", "Create the new app from the path of an existing app") cmd.Flags().StringArrayVarP(&bricks, "bricks", "b", []string{}, "List of bricks to include in the app") - cmd.Flags().BoolVarP(&noPyton, "no-python", "", false, "Do not include Python files") cmd.Flags().BoolVarP(&noSketch, "no-sketch", "", false, "Do not include Sketch files") - cmd.MarkFlagsMutuallyExclusive("no-python", "no-sketch") return cmd } -func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noPython, noSketch bool, fromApp string) error { +func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noSketch bool, fromApp string) error { if fromApp != "" { id, err := servicelocator.GetAppIDProvider().ParseID(fromApp) if err != nil { @@ -88,7 +85,6 @@ func createHandler(ctx context.Context, cfg config.Configuration, name string, i Name: name, Icon: icon, Description: description, - SkipPython: noPython, SkipSketch: noSketch, }, servicelocator.GetAppIDProvider(), cfg) if err != nil { diff --git a/cmd/gendoc/docs.go b/cmd/gendoc/docs.go index 8e85e2a8..0b36ffe8 100644 --- a/cmd/gendoc/docs.go +++ b/cmd/gendoc/docs.go @@ -609,7 +609,6 @@ Contains a JSON object with the details of an error. Path: "/v1/apps", Request: handlers.CreateAppRequest{}, Parameters: (*struct { - SkipPython bool `query:"skip-python" description:"If true, the app will not be created with the python part."` SkipSketch bool `query:"skip-sketch" description:"If true, the app will not be created with the sketch part."` })(nil), CustomSuccessResponse: &CustomResponseDef{ diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index f32c9a76..b4373058 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -45,12 +45,6 @@ paths: description: Creates a new app in the default app location. operationId: createApp parameters: - - description: If true, the app will not be created with the python part. - in: query - name: skip-python - schema: - description: If true, the app will not be created with the python part. - type: boolean - description: If true, the app will not be created with the sketch part. in: query name: skip-sketch diff --git a/internal/api/handlers/app_create.go b/internal/api/handlers/app_create.go index ed26ee61..9e757bfe 100644 --- a/internal/api/handlers/app_create.go +++ b/internal/api/handlers/app_create.go @@ -44,17 +44,9 @@ func HandleAppCreate( defer r.Body.Close() queryParams := r.URL.Query() - skipPythonStr := queryParams.Get("skip-python") skipSketchStr := queryParams.Get("skip-sketch") - - skipPython := queryParamsValidator(skipPythonStr) skipSketch := queryParamsValidator(skipSketchStr) - if skipPython && skipSketch { - render.EncodeResponse(w, http.StatusBadRequest, models.ErrorResponse{Details: "cannot skip both python and sketch"}) - return - } - var req CreateAppRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { slog.Error("unable to decode app create request", slog.String("error", err.Error())) @@ -68,7 +60,6 @@ func HandleAppCreate( Name: req.Name, Icon: req.Icon, Description: req.Description, - SkipPython: skipPython, SkipSketch: skipSketch, }, idProvider, diff --git a/internal/e2e/client/client.gen.go b/internal/e2e/client/client.gen.go index 496680c9..97b51af8 100644 --- a/internal/e2e/client/client.gen.go +++ b/internal/e2e/client/client.gen.go @@ -408,9 +408,6 @@ type GetAppsParams struct { // CreateAppParams defines parameters for CreateApp. type CreateAppParams struct { - // SkipPython If true, the app will not be created with the python part. - SkipPython *bool `form:"skip-python,omitempty" json:"skip-python,omitempty"` - // SkipSketch If true, the app will not be created with the sketch part. SkipSketch *bool `form:"skip-sketch,omitempty" json:"skip-sketch,omitempty"` } @@ -1272,22 +1269,6 @@ func NewCreateAppRequestWithBody(server string, params *CreateAppParams, content if params != nil { queryValues := queryURL.Query() - if params.SkipPython != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "skip-python", runtime.ParamLocationQuery, *params.SkipPython); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - if params.SkipSketch != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "skip-sketch", runtime.ParamLocationQuery, *params.SkipSketch); err != nil { diff --git a/internal/e2e/daemon/app_test.go b/internal/e2e/daemon/app_test.go index b62b882b..86479fc9 100644 --- a/internal/e2e/daemon/app_test.go +++ b/internal/e2e/daemon/app_test.go @@ -93,7 +93,6 @@ func TestCreateApp(t *testing.T) { { name: "should return 400 bad request when icon is not a single emoji", parameters: client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, body: client.CreateAppRequest{ @@ -107,7 +106,6 @@ func TestCreateApp(t *testing.T) { { name: "should create app successfully when icon is empty", parameters: client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, body: client.CreateAppRequest{ @@ -121,7 +119,6 @@ func TestCreateApp(t *testing.T) { { name: "should return 201 Created on first successful creation", parameters: client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, body: defaultRequestBody, @@ -130,30 +127,15 @@ func TestCreateApp(t *testing.T) { { name: "should return 409 Conflict when creating a duplicate app", parameters: client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, body: defaultRequestBody, expectedStatusCode: http.StatusConflict, expectedErrorDetails: f.Ptr("app already exists"), }, - { - name: "should return 201 Created on successful creation with skip_python", - parameters: client.CreateAppParams{ - SkipPython: f.Ptr(true), - SkipSketch: f.Ptr(false), - }, - body: client.CreateAppRequest{ - Icon: f.Ptr("🌎"), - Name: "HelloWorld_2", - Description: f.Ptr("My HelloWorld_2 description"), - }, - expectedStatusCode: http.StatusCreated, - }, { name: "should return 201 Created on successful creation with skip_sketch", parameters: client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(true), }, body: client.CreateAppRequest{ @@ -163,16 +145,6 @@ func TestCreateApp(t *testing.T) { }, expectedStatusCode: http.StatusCreated, }, - { - name: "should return 400 Bad Request when creating an app with both filters set to true", - parameters: client.CreateAppParams{ - SkipPython: f.Ptr(true), - SkipSketch: f.Ptr(true), - }, - body: defaultRequestBody, - expectedStatusCode: http.StatusBadRequest, - expectedErrorDetails: f.Ptr("cannot skip both python and sketch"), - }, } for _, tc := range testCases { @@ -985,7 +957,6 @@ func TestAppList(t *testing.T) { expectedAppNumber := 5 for i := 0; i < expectedAppNumber; i++ { r, err := httpClient.CreateApp(t.Context(), &client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, client.CreateAppRequest{ Icon: f.Ptr("🌎"), @@ -1003,7 +974,6 @@ func TestAppList(t *testing.T) { t.Run("AppListDefault_success", func(t *testing.T) { r, err := httpClient.CreateApp(t.Context(), &client.CreateAppParams{ - SkipPython: f.Ptr(false), SkipSketch: f.Ptr(false), }, client.CreateAppRequest{ Icon: f.Ptr("🌎"), diff --git a/internal/orchestrator/app/generator/app_generator.go b/internal/orchestrator/app/generator/app_generator.go index 0eec26ae..e77a48f7 100644 --- a/internal/orchestrator/app/generator/app_generator.go +++ b/internal/orchestrator/app/generator/app_generator.go @@ -33,35 +33,22 @@ import ( const templateRoot = "app_template" -type Opts int - -const ( - None Opts = 0 - SkipSketch Opts = 1 << iota - SkipPython -) - //go:embed all:app_template var fsApp embed.FS -func GenerateApp(basePath *paths.Path, app app.AppDescriptor, options Opts) error { +func GenerateApp(basePath *paths.Path, app app.AppDescriptor, skipSketch bool) error { if err := basePath.MkdirAll(); err != nil { return fmt.Errorf("failed to create app directory: %w", err) } - isSkipSketchSet := options&SkipSketch != 0 - isSkipPythonSet := options&SkipPython != 0 - - if !isSkipSketchSet { + if !skipSketch { if err := generateSketch(basePath); err != nil { return fmt.Errorf("failed to create sketch: %w", err) } } - if !isSkipPythonSet { - if err := generatePython(basePath); err != nil { - return fmt.Errorf("failed to create python: %w", err) - } - } + if err := generatePython(basePath); err != nil { + return fmt.Errorf("failed to create python: %w", err) + } if err := generateApp(basePath, app); err != nil { return fmt.Errorf("failed to create app.yaml: %w", err) } diff --git a/internal/orchestrator/app/generator/app_generator_test.go b/internal/orchestrator/app/generator/app_generator_test.go index 5763d386..729ce950 100644 --- a/internal/orchestrator/app/generator/app_generator_test.go +++ b/internal/orchestrator/app/generator/app_generator_test.go @@ -40,31 +40,25 @@ func TestGenerateApp(t *testing.T) { testCases := []struct { name string - options Opts + skipSketch bool goldenPath string }{ { name: "generate complete app", - options: None, goldenPath: "testdata/app-all.golden", }, { name: "skip sketch", - options: SkipSketch, + skipSketch: true, goldenPath: "testdata/app-no-sketch.golden", }, - { - name: "skip python", - options: SkipPython, - goldenPath: "testdata/app-no-python.golden", - }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { tempDir := t.TempDir() - err := GenerateApp(paths.New(tempDir), baseApp, tc.options) + err := GenerateApp(paths.New(tempDir), baseApp, tc.skipSketch) require.NoError(t, err) if os.Getenv("UPDATE_GOLDEN") == "true" { diff --git a/internal/orchestrator/app/generator/testdata/app-no-python.golden/.gitignore b/internal/orchestrator/app/generator/testdata/app-no-python.golden/.gitignore deleted file mode 100644 index 90ae0403..00000000 --- a/internal/orchestrator/app/generator/testdata/app-no-python.golden/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore app cache folder -.cache/ diff --git a/internal/orchestrator/app/generator/testdata/app-no-python.golden/README.md b/internal/orchestrator/app/generator/testdata/app-no-python.golden/README.md deleted file mode 100644 index d1bf5cce..00000000 --- a/internal/orchestrator/app/generator/testdata/app-no-python.golden/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# 🚀 test app all - -### Description - -test description. - -Available application ports: 8080, 9000, 90 diff --git a/internal/orchestrator/app/generator/testdata/app-no-python.golden/app.yaml b/internal/orchestrator/app/generator/testdata/app-no-python.golden/app.yaml deleted file mode 100644 index 7d1f9868..00000000 --- a/internal/orchestrator/app/generator/testdata/app-no-python.golden/app.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# app.yaml: The main configuration file for your Arduino App. -# This file describes the application's metadata and properties. - -# The user-visible name of the application. -name: test app all - -# A brief description of what the application does. -description: "test description." - -# The icon for the application, can be an emoji or a short string. -icon: 🚀 - -# A list of network ports that the application exposes. -# Example: [80, 443] -ports: [8080, 9000, 90] - -# A list of bricks used by this application. -bricks: [] diff --git a/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.ino b/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.ino deleted file mode 100644 index 95c2b6eb..00000000 --- a/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.ino +++ /dev/null @@ -1,9 +0,0 @@ -void setup() { - // put your setup code here, to run once: - -} - -void loop() { - // put your main code here, to run repeatedly: - -} diff --git a/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.yaml b/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.yaml deleted file mode 100644 index d9fe917e..00000000 --- a/internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.yaml +++ /dev/null @@ -1,11 +0,0 @@ -profiles: - default: - fqbn: arduino:zephyr:unoq - platforms: - - platform: arduino:zephyr - libraries: - - MsgPack (0.4.2) - - DebugLog (0.8.4) - - ArxContainer (0.7.0) - - ArxTypeTraits (0.3.1) -default_profile: default diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go index 74851180..83457640 100644 --- a/internal/orchestrator/orchestrator.go +++ b/internal/orchestrator/orchestrator.go @@ -749,7 +749,6 @@ type CreateAppRequest struct { Name string Icon string Description string - SkipPython bool SkipSketch bool } @@ -763,9 +762,6 @@ func CreateApp( idProvider *app.IDProvider, cfg config.Configuration, ) (CreateAppResponse, error) { - if req.SkipPython && req.SkipSketch { - return CreateAppResponse{}, fmt.Errorf("cannot skip both python and sketch") - } if req.Name == "" { return CreateAppResponse{}, fmt.Errorf("app name cannot be empty") } @@ -784,16 +780,8 @@ func CreateApp( if err := newApp.IsValid(); err != nil { return CreateAppResponse{}, fmt.Errorf("%w: %v", app.ErrInvalidApp, err) } - var options appgenerator.Opts = 0 - - if req.SkipSketch { - options |= appgenerator.SkipSketch - } - if req.SkipPython { - options |= appgenerator.SkipPython - } - if err := appgenerator.GenerateApp(basePath, newApp, options); err != nil { + if err := appgenerator.GenerateApp(basePath, newApp, req.SkipSketch); err != nil { return CreateAppResponse{}, fmt.Errorf("failed to create app: %w", err) } id, err := idProvider.IDFromPath(basePath)