-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #20
- Loading branch information
Showing
10 changed files
with
321 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package profile | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/octoberswimmer/force-md/internal" | ||
"github.com/octoberswimmer/force-md/profile" | ||
) | ||
|
||
var apexClassName string | ||
|
||
func init() { | ||
deleteApexClassCmd.Flags().StringVarP(&apexClassName, "class", "c", "", "apex classname") | ||
deleteApexClassCmd.MarkFlagRequired("class") | ||
|
||
ApexCmd.AddCommand(deleteApexClassCmd) | ||
} | ||
|
||
var ApexCmd = &cobra.Command{ | ||
Use: "apex", | ||
Short: "Manage apex class visibility", | ||
} | ||
|
||
var deleteApexClassCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete apex class visibility", | ||
Long: "Delete apex class visibility in profiles", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, file := range args { | ||
deleteApexClassVisibility(file, apexClassName) | ||
} | ||
}, | ||
} | ||
|
||
func deleteApexClassVisibility(file string, apexClassName string) { | ||
p, err := profile.Open(file) | ||
if err != nil { | ||
log.Warn("parsing profile failed: " + err.Error()) | ||
return | ||
} | ||
err = p.DeleteApexClassAccess(apexClassName) | ||
if err != nil { | ||
log.Warn(fmt.Sprintf("update failed for %s: %s", file, err.Error())) | ||
return | ||
} | ||
err = internal.WriteToFile(p, file) | ||
if err != nil { | ||
log.Warn("update failed: " + err.Error()) | ||
return | ||
} | ||
} |
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,55 @@ | ||
package profile | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/octoberswimmer/force-md/internal" | ||
"github.com/octoberswimmer/force-md/profile" | ||
) | ||
|
||
var applicationName string | ||
|
||
func init() { | ||
deleteApplicationCmd.Flags().StringVarP(&applicationName, "application", "a", "", "application name") | ||
deleteApplicationCmd.MarkFlagRequired("application") | ||
|
||
ApplicationCmd.AddCommand(deleteApplicationCmd) | ||
} | ||
|
||
var ApplicationCmd = &cobra.Command{ | ||
Use: "application", | ||
Short: "Manage application visibility", | ||
} | ||
|
||
var deleteApplicationCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete application visibility", | ||
Long: "Delete application visibility in profiles", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, file := range args { | ||
deleteApplicationVisibility(file, applicationName) | ||
} | ||
}, | ||
} | ||
|
||
func deleteApplicationVisibility(file string, applicationName string) { | ||
p, err := profile.Open(file) | ||
if err != nil { | ||
log.Warn("parsing profile failed: " + err.Error()) | ||
return | ||
} | ||
err = p.DeleteApplicationVisibility(applicationName) | ||
if err != nil { | ||
log.Warn(fmt.Sprintf("update failed for %s: %s", file, err.Error())) | ||
return | ||
} | ||
err = internal.WriteToFile(p, file) | ||
if err != nil { | ||
log.Warn("update failed: " + err.Error()) | ||
return | ||
} | ||
} |
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,55 @@ | ||
package profile | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/octoberswimmer/force-md/internal" | ||
"github.com/octoberswimmer/force-md/profile" | ||
) | ||
|
||
var flowName string | ||
|
||
func init() { | ||
deleteFlowCmd.Flags().StringVarP(&flowName, "flow", "f", "", "flow name") | ||
deleteFlowCmd.MarkFlagRequired("flow") | ||
|
||
FlowCmd.AddCommand(deleteFlowCmd) | ||
} | ||
|
||
var FlowCmd = &cobra.Command{ | ||
Use: "flow", | ||
Short: "Manage flow visibility", | ||
} | ||
|
||
var deleteFlowCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete flow access", | ||
Long: "Delete flow access in profiles", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, file := range args { | ||
deleteFlowVisibility(file, flowName) | ||
} | ||
}, | ||
} | ||
|
||
func deleteFlowVisibility(file string, flowName string) { | ||
p, err := profile.Open(file) | ||
if err != nil { | ||
log.Warn("parsing profile failed: " + err.Error()) | ||
return | ||
} | ||
err = p.DeleteFlowAccess(flowName) | ||
if err != nil { | ||
log.Warn(fmt.Sprintf("update failed for %s: %s", file, err.Error())) | ||
return | ||
} | ||
err = internal.WriteToFile(p, file) | ||
if err != nil { | ||
log.Warn("update failed: " + err.Error()) | ||
return | ||
} | ||
} |
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,55 @@ | ||
package profile | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/octoberswimmer/force-md/internal" | ||
"github.com/octoberswimmer/force-md/profile" | ||
) | ||
|
||
var pageName string | ||
|
||
func init() { | ||
deleteVisualforcePageCmd.Flags().StringVarP(&pageName, "page", "p", "", "visualforce page name") | ||
deleteVisualforcePageCmd.MarkFlagRequired("page") | ||
|
||
VisualforceCmd.AddCommand(deleteVisualforcePageCmd) | ||
} | ||
|
||
var VisualforceCmd = &cobra.Command{ | ||
Use: "visualforce", | ||
Short: "Manage visualforce page visibility", | ||
} | ||
|
||
var deleteVisualforcePageCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete visualforce page access", | ||
Long: "Delete visualforce page access in profiles", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, file := range args { | ||
deleteVisualforceAccess(file, pageName) | ||
} | ||
}, | ||
} | ||
|
||
func deleteVisualforceAccess(file string, pageName string) { | ||
p, err := profile.Open(file) | ||
if err != nil { | ||
log.Warn("parsing profile failed: " + err.Error()) | ||
return | ||
} | ||
err = p.DeleteVisualforcePageAccess(pageName) | ||
if err != nil { | ||
log.Warn(fmt.Sprintf("update failed for %s: %s", file, err.Error())) | ||
return | ||
} | ||
err = internal.WriteToFile(p, file) | ||
if err != nil { | ||
log.Warn("update failed: " + err.Error()) | ||
return | ||
} | ||
} |
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,22 @@ | ||
package profile | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (p *Profile) DeleteApexClassAccess(apexClassName string) error { | ||
found := false | ||
newClasses := p.ClassAccesses[:0] | ||
for _, f := range p.ClassAccesses { | ||
if f.ApexClass.Text == apexClassName { | ||
found = true | ||
} else { | ||
newClasses = append(newClasses, f) | ||
} | ||
} | ||
if !found { | ||
return errors.New("class not found") | ||
} | ||
p.ClassAccesses = newClasses | ||
return nil | ||
} |
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,22 @@ | ||
package profile | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (p *Profile) DeleteApplicationVisibility(applicationName string) error { | ||
found := false | ||
newApps := p.ApplicationVisibilities[:0] | ||
for _, f := range p.ApplicationVisibilities { | ||
if f.Application.Text == applicationName { | ||
found = true | ||
} else { | ||
newApps = append(newApps, f) | ||
} | ||
} | ||
if !found { | ||
return errors.New("application not found") | ||
} | ||
p.ApplicationVisibilities = newApps | ||
return nil | ||
} |
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,22 @@ | ||
package profile | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (p *Profile) DeleteFlowAccess(flowName string) error { | ||
found := false | ||
newFlows := p.FlowAccesses[:0] | ||
for _, f := range p.FlowAccesses { | ||
if f.Flow.Text == flowName { | ||
found = true | ||
} else { | ||
newFlows = append(newFlows, f) | ||
} | ||
} | ||
if !found { | ||
return errors.New("flow not found") | ||
} | ||
p.FlowAccesses = newFlows | ||
return nil | ||
} |
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,22 @@ | ||
package profile | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (p *Profile) DeleteVisualforcePageAccess(pageName string) error { | ||
found := false | ||
newPages := p.PageAccesses[:0] | ||
for _, f := range p.PageAccesses { | ||
if f.ApexPage.Text == pageName { | ||
found = true | ||
} else { | ||
newPages = append(newPages, f) | ||
} | ||
} | ||
if !found { | ||
return errors.New("page not found") | ||
} | ||
p.PageAccesses = newPages | ||
return nil | ||
} |