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

stack: add enable + disable commands #107

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

lexton
Copy link
Contributor

@lexton lexton commented Dec 17, 2022

No description provided.

}

return authenticated.Client.Mutate(cliCtx.Context, &mutation, variables)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about this? A bit less code duplication.

func enable(cliCtx *cli.Context) error {
	return enableDisable[stackEnableMutation](cliCtx)
}

func disable(cliCtx *cli.Context) error {
	return enableDisable[stackDisableMutation](cliCtx)
}

func enableDisable[T any](cliCtx *cli.Context) error {
	stackID := cliCtx.String(flagStackID.Name)

	if nArgs := cliCtx.NArg(); nArgs != 0 {
		return fmt.Errorf("expected zero arguments but got %d", nArgs)
	}

	var mutation T
	variables := map[string]interface{}{
		"stack": graphql.ID(stackID),
	}

	return authenticated.Client.Mutate(cliCtx.Context, &mutation, variables)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good - I'm not fussed, easy enough to keep clean. I copied the lock.go code to implement this.

@peterdeme
Copy link
Collaborator

@lexton thanks for the contribution 🙏

@peterdeme peterdeme merged commit ae87fda into spacelift-io:main Dec 20, 2022
@peterdeme
Copy link
Collaborator

Released in v0.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants