Skip to content

Commit

Permalink
move apptypes into Connect client
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchetti committed Dec 4, 2023
1 parent 89065b0 commit 77399fb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions internal/bundles/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"testing"
"time"

"github.com/rstudio/connect-client/internal/apptypes"
"github.com/rstudio/connect-client/internal/bundles/bundlestest"
"github.com/rstudio/connect-client/internal/clients/connect"
"github.com/rstudio/connect-client/internal/events"
"github.com/rstudio/connect-client/internal/logging"
"github.com/rstudio/connect-client/internal/logging/loggingtest"
Expand Down Expand Up @@ -160,7 +160,7 @@ func (s *BundlerSuite) SetupTest() {
s.cwd.MkdirAll(0700)

s.manifest = NewManifest()
s.manifest.Metadata.AppMode = apptypes.StaticMode
s.manifest.Metadata.AppMode = connect.StaticMode
s.manifest.Metadata.Entrypoint = "subdir/testfile"
}

Expand Down
48 changes: 24 additions & 24 deletions internal/bundles/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"io"
"sort"

"github.com/rstudio/connect-client/internal/apptypes"
"github.com/rstudio/connect-client/internal/clients/connect"
"github.com/rstudio/connect-client/internal/config"
"github.com/rstudio/connect-client/internal/util"
)
Expand Down Expand Up @@ -43,12 +43,12 @@ type Manifest struct {

// Metadata contains details about this deployment (type, etc).
type Metadata struct {
AppMode apptypes.AppMode `json:"appmode" help:"Type of content being deployed. Default is to auto detect."` // Selects the runtime for this content.
ContentCategory string `json:"content_category,omitempty"` // A refinement of the AppMode used by plots and sites
Entrypoint string `json:"entrypoint,omitempty"` // The main file being deployed.
PrimaryRmd string `json:"primary_rmd,omitempty"` // The rendering target for Rmd deployments.
PrimaryHtml string `json:"primary_html,omitempty"` // The default document for static deployments.
HasParameters bool `json:"has_parameters,omitempty"` // True if this is content allows parameter customization.
AppMode connect.AppMode `json:"appmode" help:"Type of content being deployed. Default is to auto detect."` // Selects the runtime for this content.
ContentCategory string `json:"content_category,omitempty"` // A refinement of the AppMode used by plots and sites
Entrypoint string `json:"entrypoint,omitempty"` // The main file being deployed.
PrimaryRmd string `json:"primary_rmd,omitempty"` // The rendering target for Rmd deployments.
PrimaryHtml string `json:"primary_html,omitempty"` // The default document for static deployments.
HasParameters bool `json:"has_parameters,omitempty"` // True if this is content allows parameter customization.
}

type Environment struct {
Expand Down Expand Up @@ -154,28 +154,28 @@ func NewManifest() *Manifest {
}
}

var connectContentTypeMap = map[config.ContentType]apptypes.AppMode{
config.ContentTypeHTML: apptypes.StaticMode,
config.ContentTypeJupyterNotebook: apptypes.StaticJupyterMode,
config.ContentTypeJupyterVoila: apptypes.JupyterVoilaMode,
config.ContentTypePythonBokeh: apptypes.PythonBokehMode,
config.ContentTypePythonDash: apptypes.PythonDashMode,
config.ContentTypePythonFastAPI: apptypes.PythonFastAPIMode,
config.ContentTypePythonFlask: apptypes.PythonAPIMode,
config.ContentTypePythonShiny: apptypes.PythonShinyMode,
config.ContentTypePythonStreamlit: apptypes.PythonStreamlitMode,
config.ContentTypeQuartoShiny: apptypes.ShinyQuartoMode,
config.ContentTypeQuarto: apptypes.StaticQuartoMode,
config.ContentTypeRPlumber: apptypes.PlumberAPIMode,
config.ContentTypeRShiny: apptypes.ShinyMode,
config.ContentTypeRMarkdownShiny: apptypes.ShinyRmdMode,
config.ContentTypeRMarkdown: apptypes.StaticRmdMode,
var connectContentTypeMap = map[config.ContentType]connect.AppMode{
config.ContentTypeHTML: connect.StaticMode,
config.ContentTypeJupyterNotebook: connect.StaticJupyterMode,
config.ContentTypeJupyterVoila: connect.JupyterVoilaMode,
config.ContentTypePythonBokeh: connect.PythonBokehMode,
config.ContentTypePythonDash: connect.PythonDashMode,
config.ContentTypePythonFastAPI: connect.PythonFastAPIMode,
config.ContentTypePythonFlask: connect.PythonAPIMode,
config.ContentTypePythonShiny: connect.PythonShinyMode,
config.ContentTypePythonStreamlit: connect.PythonStreamlitMode,
config.ContentTypeQuartoShiny: connect.ShinyQuartoMode,
config.ContentTypeQuarto: connect.StaticQuartoMode,
config.ContentTypeRPlumber: connect.PlumberAPIMode,
config.ContentTypeRShiny: connect.ShinyMode,
config.ContentTypeRMarkdownShiny: connect.ShinyRmdMode,
config.ContentTypeRMarkdown: connect.StaticRmdMode,
}

func NewManifestFromConfig(cfg *config.Config) *Manifest {
contentType, ok := connectContentTypeMap[cfg.Type]
if !ok {
contentType = apptypes.UnknownMode
contentType = connect.UnknownMode
}
m := &Manifest{
Version: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apptypes
package connect

// Copyright (C) 2022 by Posit Software, PBC.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apptypes
package connect

// Copyright (C) 2023 by Posit Software, PBC.

Expand Down
3 changes: 1 addition & 2 deletions internal/clients/connect/client_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/rstudio/connect-client/internal/accounts"
"github.com/rstudio/connect-client/internal/apptypes"
"github.com/rstudio/connect-client/internal/clients/http_client"
"github.com/rstudio/connect-client/internal/config"
"github.com/rstudio/connect-client/internal/events"
Expand Down Expand Up @@ -127,7 +126,7 @@ type connectGetContentDTO struct {
Created types.Time `json:"created_time"`
LastDeployed types.Time `json:"last_deployed_time"`
BundleId types.NullInt64Str `json:"bundle_id"`
AppMode apptypes.AppMode `json:"app_mode"`
AppMode AppMode `json:"app_mode"`
ContentCategory string `json:"content_category"`
Parameterized bool `json:"parameterized"`
ClusterName types.NullString `json:"cluster_name"`
Expand Down

0 comments on commit 77399fb

Please sign in to comment.