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

Fixes #4 - Adding dagger function for civo cluster creation #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions civo-cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ func (m *CivoCluster) ClusterShow(ctx context.Context,
Stdout(ctx)
}

// example usage: "dagger call cluster-create --api-token <env var name> --region <region> --name <cluster name> --node-count <node count> --node-size <node size> --version <cluster version>"
func (m *CivoCluster) ClusterCreate(ctx context.Context,
apiToken *Secret,
// the region in which the new cluster should reside
region string,
// the name of the cluster
name string,
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need an upgrade to the dagger engine to support this?

// +default="3"
// the number of nodes to create (the master also acts as a node)
nodeCount string,
// +optional
// +default="g4s.kube.medium"
// the size of nodes to create. You can list available kubernetes sizes by civo size list -s kubernetes
nodeSize string,
// +optional
// +default="latest"
// the k3s version to use on the cluster. Defaults to the latest. Example - '--version 1.21.2+k3s1'
version string,
) (string, error) {
c := civoContainer(apiToken)
return c.
WithEnvVariable("CACHE_BUSTER", time.Now().String()).
WithExec([]string{"k3s", "create", name, "--region", region, "--nodes", nodeCount, "--size", nodeSize, "--version", version, "--wait"}).
Stdout(ctx)
}

// example usage: "dagger call version"
func (m *CivoCluster) Version(ctx context.Context) (string, error) {
c := civoContainer(nil)
Expand Down