-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deploy): Add .rillcloud/project.yaml to store deployed info (#5146)
* Add dotrillcloud * Only add project_id * Swap around proto order * PR comments * Remove rillcloud info on delete * Update InferProjectName to look at rillcloud file * json=>yaml * Add a prefix if env is not prod * Fix lint * Safe delete rillcloud file * Move deployedProjectID before github access check * PR comments
- Loading branch information
1 parent
4f4c492
commit fe464ef
Showing
22 changed files
with
4,746 additions
and
3,831 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
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,29 @@ | ||
package adminenv | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var EnvURLs = map[string]string{ | ||
"prod": "https://admin.rilldata.com", | ||
"stage": "https://admin.rilldata.io", | ||
"test": "https://admin.rilldata.in", | ||
"dev": "http://localhost:9090", | ||
} | ||
|
||
func Infer(adminURL string) (string, error) { | ||
for env, url := range EnvURLs { | ||
if url == adminURL { | ||
return env, nil | ||
} | ||
} | ||
return "", fmt.Errorf("could not infer env from admin URL %q", adminURL) | ||
} | ||
|
||
func AdminURL(env string) string { | ||
u, ok := EnvURLs[env] | ||
if !ok { | ||
panic(fmt.Errorf("invalid environment %q", env)) | ||
} | ||
return u | ||
} |
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,83 @@ | ||
package dotrillcloud | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/rilldata/rill/cli/pkg/adminenv" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type Config struct { | ||
ProjectID string `yaml:"project_id"` | ||
} | ||
|
||
func GetAll(localProjectPath, adminURL string) (*Config, error) { | ||
confPath, err := getConfPath(localProjectPath, adminURL) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
data, err := os.ReadFile(confPath) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return nil, nil | ||
} | ||
return nil, err | ||
} | ||
|
||
conf := &Config{} | ||
err = yaml.Unmarshal(data, conf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return conf, nil | ||
} | ||
|
||
func SetAll(localProjectPath, adminURL string, conf *Config) error { | ||
err := os.MkdirAll(filepath.Join(localProjectPath, ".rillcloud"), os.ModePerm) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
data, err := yaml.Marshal(conf) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
confPath, err := getConfPath(localProjectPath, adminURL) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return os.WriteFile(confPath, data, 0o644) | ||
} | ||
|
||
func Delete(localProjectPath, adminURL string) error { | ||
confPath, err := getConfPath(localProjectPath, adminURL) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = os.Remove(confPath) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return nil | ||
} | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func getConfPath(localProjectPath, adminURL string) (string, error) { | ||
env, err := adminenv.Infer(adminURL) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if env != "prod" { | ||
return filepath.Join(localProjectPath, ".rillcloud", fmt.Sprintf("project_%s.yaml", env)), nil | ||
} | ||
return filepath.Join(localProjectPath, ".rillcloud", "project.yaml"), nil | ||
} |
Oops, something went wrong.
fe464ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ui.rilldata.in as production
🚀 Deployed on https://6683c2808397371b1fb6e377--rill-ui-dev.netlify.app